Add start and enddate when fetching the position history

This commit is contained in:
2025-10-24 18:00:23 +07:00
parent 554cac7d89
commit fc4369a008
10 changed files with 352 additions and 32 deletions

View File

@@ -602,6 +602,7 @@ public class TradingBotBase : ITradingBot
await LogWarning(
$"❌ Position Never Filled\nNo position on exchange and no orders\nChecking position history before marking as canceled.");
// Position might be canceled by the broker
// Check if position exists in exchange history with PnL before canceling
bool positionFoundInHistory = await CheckPositionInExchangeHistory(positionForSignal);
@@ -1254,7 +1255,7 @@ public class TradingBotBase : ITradingBot
async exchangeService =>
{
// Get position history from the last 24 hours
var fromDate = DateTime.UtcNow.AddHours(-24);
var fromDate = DateTime.UtcNow.AddHours(-1);
var toDate = DateTime.UtcNow;
positionHistory =
await exchangeService.GetPositionHistory(Account, Config.Ticker, fromDate, toDate);
@@ -2536,7 +2537,7 @@ public class TradingBotBase : ITradingBot
async exchangeService =>
{
// Get position history from the last 24 hours
var fromDate = DateTime.UtcNow.AddHours(-24);
var fromDate = position.Date.AddMinutes(-5);
var toDate = DateTime.UtcNow;
positionHistory =
await exchangeService.GetPositionHistory(Account, Config.Ticker, fromDate, toDate);