From 91e90dd8bc45aa02702238bb0d952ec237ccb0a3 Mon Sep 17 00:00:00 2001 From: Leonardo Araujo Date: Sun, 20 Oct 2024 15:14:43 -0300 Subject: [PATCH] fix: daily variation --- pkg/coinapi/coinapi.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/coinapi/coinapi.go b/pkg/coinapi/coinapi.go index e67f9b0..dccd91b 100644 --- a/pkg/coinapi/coinapi.go +++ b/pkg/coinapi/coinapi.go @@ -60,8 +60,9 @@ func FetchRate(currency string) (float64, error) { // FetchDailyVariation retrieves the daily variation in percentage of the Bitcoin price for a specified currency func FetchDailyVariation(currency string) (float64, error) { - symbolID := fmt.Sprintf("BITSTAMP_SPOT_BTC_%s", currency) // Adjust the exchange as needed - url := fmt.Sprintf("%sohlcv/%s/history?period_id=1DAY&time_start=%s&limit=1", BASE_URL, symbolID, time.Now().Format("2006-01-02T15:04:05")) + symbolID := fmt.Sprintf("BITSTAMP_SPOT_BTC_%s", currency) // Adjust the exchange as needed + yesterday := time.Now().AddDate(0, 0, -1).Format("2006-01-02T00:00:00") // Start from the beginning of the previous day + url := fmt.Sprintf("%sohlcv/%s/history?period_id=1DAY&time_start=%s&limit=1", BASE_URL, symbolID, yesterday) response, err := makeRequest(url) if err != nil { return 0, err