Add test to check if backtest behavior changed

This commit is contained in:
2025-10-24 19:08:10 +07:00
parent fc4369a008
commit 38e6998ff3
12 changed files with 11797 additions and 38 deletions

View File

@@ -1250,15 +1250,14 @@ public class TradingBotBase : ITradingBot
Logger.LogDebug(
$"🔍 Fetching Position History from GMX\nPosition: `{position.Identifier}`\nTicker: `{Config.Ticker}`");
List<Position> positionHistory = null;
await ServiceScopeHelpers.WithScopedService<IExchangeService>(_scopeFactory,
var positionHistory = await ServiceScopeHelpers.WithScopedService<IExchangeService, List<Position>>(
_scopeFactory,
async exchangeService =>
{
// Get position history from the last 24 hours
var fromDate = DateTime.UtcNow.AddHours(-1);
var toDate = DateTime.UtcNow;
positionHistory =
await exchangeService.GetPositionHistory(Account, Config.Ticker, fromDate, toDate);
return await exchangeService.GetPositionHistory(Account, Config.Ticker, fromDate, toDate);
});
// Find the matching position in history based on the most recent closed position
@@ -1349,9 +1348,11 @@ public class TradingBotBase : ITradingBot
{
}
}
Logger.LogWarning(
$"⚠️ No GMX Position History Found\nPosition: `{position.Identifier}`\nFalling back to candle-based calculation");
else
{
Logger.LogWarning(
$"⚠️ No GMX Position History Found\nPosition: `{position.Identifier}`\nFalling back to candle-based calculation");
}
}
catch (Exception ex)
{
@@ -2537,7 +2538,7 @@ public class TradingBotBase : ITradingBot
async exchangeService =>
{
// Get position history from the last 24 hours
var fromDate = position.Date.AddMinutes(-5);
var fromDate = DateTime.UtcNow.AddMinutes(-10);
var toDate = DateTime.UtcNow;
positionHistory =
await exchangeService.GetPositionHistory(Account, Config.Ticker, fromDate, toDate);