Improve portfolio, coverage and tool

This commit is contained in:
Adrian Gallagher
2017-08-17 11:56:54 +10:00
parent 0f55715987
commit 4f34b58d55
9 changed files with 532 additions and 116 deletions

19
main.go
View File

@@ -273,18 +273,27 @@ func SeedExchangeAccountInfo(data []exchange.AccountInfo) {
avail := data[i].Currencies[j].TotalValue
total := onHold + avail
if total <= 0 {
continue
}
if !port.ExchangeAddressExists(exchangeName, currencyName) {
if total <= 0 {
continue
}
log.Printf("Portfolio: Adding new exchange address: %s, %s, %f, %s\n",
exchangeName, currencyName, total, portfolio.PortfolioAddressExchange)
port.Addresses = append(
port.Addresses,
portfolio.Address{Address: exchangeName, CoinType: currencyName,
Balance: total, Description: portfolio.PortfolioAddressExchange},
)
} else {
port.UpdateExchangeAddressBalance(exchangeName, currencyName, total)
if total <= 0 {
log.Printf("Portfolio: Removing %s %s entry.\n", exchangeName,
currencyName)
port.RemoveExchangeAddress(exchangeName, currencyName)
} else {
log.Printf("Portfolio: Updating %s %s entry with balance %f.\n",
exchangeName, currencyName, total)
port.UpdateExchangeAddressBalance(exchangeName, currencyName, total)
}
}
}
}