Fix get current price

This commit is contained in:
2025-09-20 16:20:47 +07:00
parent d58672f879
commit 931c4661dc
9 changed files with 110 additions and 12 deletions

View File

@@ -441,12 +441,27 @@ public class EvmManager : IEvmManager
}
if (gmxPrices == null)
return null;
{
Console.WriteLine($"Warning: GMX API returned null for ticker {ticker}, timeframe {timeframe}, startDate {startDate:yyyy-MM-dd HH:mm:ss}");
return new List<Candle>();
}
if (gmxPrices.Candles == null || !gmxPrices.Candles.Any())
{
Console.WriteLine($"Warning: GMX API returned empty candles array for ticker {ticker}, timeframe {timeframe}, startDate {startDate:yyyy-MM-dd HH:mm:ss}");
return new List<Candle>();
}
var filteredCandles = gmxPrices.Candles.Where(p => p[0] >= startDate.AddMinutes(-1).ToUnixTimestamp()).ToList();
if (!filteredCandles.Any())
{
Console.WriteLine($"Warning: No candles found after filtering for ticker {ticker}, timeframe {timeframe}, startDate {startDate:yyyy-MM-dd HH:mm:ss}. Total candles before filtering: {gmxPrices.Candles.Count}");
return new List<Candle>();
}
var candles = new List<Candle>();
var timeBetweenCandles =
gmxPrices.Candles.Count > 2 ? gmxPrices.Candles[0][0] - gmxPrices.Candles[1][0] : 900; // Default 15 minutes
var timeBetweenCandles = CandleHelpers.GetBaseIntervalInSeconds(timeframe);
for (int i = 0; i < filteredCandles.Count; i++)
{