Skip to content

Commit

Permalink
Added total
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew committed Jun 9, 2018
1 parent cdca85a commit aff01f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion blockfolio/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ func contentFrom(positions *AllPositionsResponse) string {
colorName := Config.UString("wtf.mods.blockfolio.colors.name")
colorGrows := Config.UString("wtf.mods.blockfolio.colors.grows")
colorDrop := Config.UString("wtf.mods.blockfolio.colors.drop")
totalFiat := 0
for i := 0; i < len(positions.PositionList); i++ {
colorForChange := colorGrows
if positions.PositionList[i].TwentyFourHourPercentChangeFiat <= 0 {
colorForChange = colorDrop
}
res = res + fmt.Sprintf("[%s]%6s - %3d ([%s]%.2f [%s]%.2f%)\n", colorName, positions.PositionList[i].Coin, positions.PositionList[i].Quantity, colorForChange, positions.PositionList[i].HoldingValueFiat/1000, colorForChange, positions.PositionList[i].TwentyFourHourPercentChangeFiat)
totalFiat += positions.PositionList[i].HoldingValueFiat
res = res + fmt.Sprintf("[%s]%6s - %5.2f ([%s]%.2fk [%s]%.2f%)\n", colorName, positions.PositionList[i].Coin, positions.PositionList[i].Quantity, colorForChange, positions.PositionList[i].HoldingValueFiat/1000, colorForChange, positions.PositionList[i].TwentyFourHourPercentChangeFiat)
}
res = res + fmt.Sprintf("\n[%s]Total value: $%.2f", "green", totalFiat/1000)

return res
}
Expand Down

0 comments on commit aff01f7

Please sign in to comment.