Global fix (#9)

* Fix time for candle

* Fix out ouf range

* Fix pnl, fix custom money management

* Clean a bit
This commit is contained in:
Oda
2025-02-04 14:59:39 +07:00
committed by GitHub
parent ff0433c349
commit 0987fa76cf
26 changed files with 153 additions and 139 deletions

View File

@@ -10,7 +10,6 @@ using Managing.Domain.Statistics;
using Managing.Domain.Trades;
using Managing.Infrastructure.Evm.Abstractions;
using Managing.Infrastructure.Evm.Models;
using Managing.Infrastructure.Evm.Models.Gmx.v1;
using Managing.Infrastructure.Evm.Models.Gmx.v2;
using Managing.Infrastructure.Evm.Referentials;
using Managing.Infrastructure.Evm.Services;
@@ -318,7 +317,7 @@ public class EvmManager : IEvmManager
var geckoToken = geckoTokens.FirstOrDefault(x =>
string.Equals(x.Symbol, tokens[i].Symbol, StringComparison.InvariantCultureIgnoreCase));
evmTokens.Add((tokenBalance, geckoToken));
evmTokens.Add((tokenBalance, geckoToken)!);
}
}
@@ -379,14 +378,16 @@ public class EvmManager : IEvmManager
if (gmxPrices == null)
return null;
gmxPrices.Candles = gmxPrices.Candles.Where(p => p[0] >= startDate.ToUnixTimestamp()).ToList();
gmxPrices.Candles.RemoveAt(gmxPrices.Candles.Count - 1);
var filteredCandles = gmxPrices.Candles.Where(p => p[0] >= startDate.ToUnixTimestamp()).ToList();
var candles = new List<Candle>();
var timeBetweenCandles = gmxPrices.Candles[0][0] - gmxPrices.Candles[1][0];
for (int i = 0; i < gmxPrices.Candles.Count; i++)
var timeBetweenCandles =
gmxPrices.Candles.Count > 2 ? gmxPrices.Candles[0][0] - gmxPrices.Candles[1][0] : 900; // Default 15 minutes
for (int i = 0; i < filteredCandles.Count; i++)
{
var c = GmxV2Mappers.Map(gmxPrices.Candles[i], ticker, timeframe, (int)timeBetweenCandles);
var c = GmxV2Mappers.Map(filteredCandles[i], ticker, timeframe, (int)timeBetweenCandles);
candles.Add(c);
}

View File

@@ -110,7 +110,7 @@ internal static class GmxV2Mappers
{
return new Candle()
{
Date = DateHelpers.GetFromUnixTimestamp((int)marketPrices[0]).AddSeconds(timeBetween).AddSeconds(-1),
Date = DateHelpers.GetFromUnixTimestamp((int)marketPrices[0] + timeBetween).AddSeconds(-1),
OpenTime = DateHelpers.GetFromUnixTimestamp((int)marketPrices[0]),
Open = Convert.ToDecimal(marketPrices[1]),
High = Convert.ToDecimal(marketPrices[2]),