Fix backtests
This commit is contained in:
@@ -292,7 +292,14 @@ public class TradingBot : Bot, ITradingBot
|
||||
foreach (var signal in Signals.Where(s => s.Status == SignalStatus.PositionOpen))
|
||||
{
|
||||
var positionForSignal = Positions.FirstOrDefault(p => p.SignalIdentifier == signal.Identifier);
|
||||
await UpdatePosition(signal, positionForSignal);
|
||||
if (positionForSignal == null)
|
||||
{
|
||||
await LogInformation($"Cannot find position for signal {signal.Identifier}");
|
||||
}
|
||||
else
|
||||
{
|
||||
await UpdatePosition(signal, positionForSignal);
|
||||
}
|
||||
}
|
||||
|
||||
// Open position for signal waiting for a position open
|
||||
@@ -456,7 +463,7 @@ public class TradingBot : Bot, ITradingBot
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, ex.Message);
|
||||
SentrySdk.CaptureException(ex);
|
||||
//SentrySdk.CaptureException(ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -519,7 +526,7 @@ public class TradingBot : Bot, ITradingBot
|
||||
}
|
||||
|
||||
await LogInformation(
|
||||
$"Open position - Date: {signal.Date:T} - SignalIdentifier : {signal.Identifier} - Strategie : {signal.StrategyType}");
|
||||
$"Open position - Date: {signal.Date:T} - SignalIdentifier : {signal.Identifier}");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -542,7 +549,6 @@ public class TradingBot : Bot, ITradingBot
|
||||
|
||||
if (position != null)
|
||||
{
|
||||
position.SignalIdentifier = signal.Identifier;
|
||||
Positions.Add(position);
|
||||
|
||||
if (position.Open.Status != TradeStatus.Cancelled)
|
||||
@@ -827,7 +833,7 @@ public class TradingBot : Bot, ITradingBot
|
||||
ScenarioName = data.ScenarioName;
|
||||
AccountName = data.AccountName;
|
||||
IsForWatchingOnly = data.IsForWatchingOnly;
|
||||
|
||||
|
||||
// Restore the startup time if it was previously saved
|
||||
if (data.StartupTime != DateTime.MinValue)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,8 @@ namespace Managing.Application.Trading
|
||||
}
|
||||
|
||||
var initiator = request.IsForPaperTrading ? PositionInitiator.PaperTrading : request.Initiator;
|
||||
var position = new Position(new Guid().ToString(), request.AccountName, request.Direction, request.Ticker,
|
||||
var position = new Position(Guid.NewGuid().ToString(), request.AccountName, request.Direction,
|
||||
request.Ticker,
|
||||
request.MoneyManagement,
|
||||
initiator, request.Date, request.User);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user