Skip to content

Commit

Permalink
feat(nomics): add nomics change 24h
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius committed Dec 14, 2021
1 parent e4920d9 commit c2cf0f8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions external_services/generic_price_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,15 @@ func RetrievePercentChange24h(coin string) (string, string, string) {
if change24h == "0" {
change24h, date, provider = CoingeckoGetChange24h(coin)
}

if change24h == "0" {
change24h, date, provider = NomicsGetChange24h(coin)
}

if change24h == "0" {
change24h, date, provider = CoinpaprikaGetChange24h(coin)
}

if change24h != "0" {
return change24h, date, provider
} else {
Expand Down
16 changes: 16 additions & 0 deletions external_services/nomics_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,19 @@ func NomicsRetrieveCEXRatesFromPair(base string, rel string) (string, bool, stri
}
return price, true, date, "nomics"
}

func NomicsGetChange24h(coin string) (string, string, string) {
changePercent24h := "0"
dateStr := helpers.GetDateFromTimestampStandard(time.Now().UnixNano())
if cfg, cfgOk := config.GCFGRegistry[coin]; cfgOk && cfg.NomicsId != nil {
val, ok := NomicsPriceRegistry.Load(*cfg.NomicsId)
if ok {
resp := val.(NomicsAnswer)
changePercent24h = fmt.Sprintf("%s", resp.D.PriceChangePct)
changePercent24h = helpers.BigFloatMultiply(changePercent24h, "100", 3)
dateStr = helpers.GetDateFromTime(resp.PriceTimestamp)
}
return changePercent24h, dateStr, "nomics"
}
return changePercent24h, dateStr, "unknown"
}

0 comments on commit c2cf0f8

Please sign in to comment.