]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/blobdiff - api/portfolio.go
Fix missing ticker.
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git] / api / portfolio.go
index 1e16426ac13a1873777205250a25bc5eca6c9593..8e4cdc6a6c1103bfb65bc6ef6f99b51a760a545a 100644 (file)
@@ -4,8 +4,8 @@ import (
        "fmt"
        "time"
 
-       "github.com/shopspring/decimal"
        "git.immae.eu/Cryptoportfolio/Front.git/db"
+       "github.com/shopspring/decimal"
 )
 
 func init() {
@@ -27,6 +27,10 @@ type ValuePerformance struct {
 func NewValuePerformance(fromValue, toValue decimal.Decimal) ValuePerformance {
        variation := toValue.Sub(fromValue)
 
+       if fromValue.Equals(decimal.Zero) {
+               return ValuePerformance{}
+       }
+
        return ValuePerformance{
                Value:      toValue,
                Variation:  variation,