Add agent fees
This commit is contained in:
@@ -406,10 +406,13 @@ public class TradingBotBase : ITradingBot
|
||||
|
||||
await UpdatePositionDatabase(internalPosition);
|
||||
|
||||
if (previousPositionStatus != PositionStatus.Filled && internalPosition.Status == PositionStatus.Filled)
|
||||
if (previousPositionStatus != PositionStatus.Filled &&
|
||||
internalPosition.Status == PositionStatus.Filled)
|
||||
{
|
||||
await NotifyAgentAndPlatformGrainAsync(NotificationEventType.PositionOpened, internalPosition);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
await NotifyAgentAndPlatformGrainAsync(NotificationEventType.PositionUpdated, internalPosition);
|
||||
}
|
||||
}
|
||||
@@ -750,8 +753,6 @@ public class TradingBotBase : ITradingBot
|
||||
currentPrice, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -763,10 +764,8 @@ public class TradingBotBase : ITradingBot
|
||||
|
||||
private async Task UpdatePositionDatabase(Position position)
|
||||
{
|
||||
await ServiceScopeHelpers.WithScopedService<ITradingService>(_scopeFactory, async tradingService =>
|
||||
{
|
||||
await tradingService.UpdatePositionAsync(position);
|
||||
});
|
||||
await ServiceScopeHelpers.WithScopedService<ITradingService>(_scopeFactory,
|
||||
async tradingService => { await tradingService.UpdatePositionAsync(position); });
|
||||
}
|
||||
|
||||
private async Task<Position> OpenPosition(LightSignal signal)
|
||||
@@ -1347,6 +1346,7 @@ public class TradingBotBase : ITradingBot
|
||||
// Update position in database with all trade changes
|
||||
if (!Config.IsForBacktest)
|
||||
{
|
||||
position.Status = PositionStatus.Finished;
|
||||
await UpdatePositionDatabase(position);
|
||||
await NotifyAgentAndPlatformGrainAsync(NotificationEventType.PositionClosed, position);
|
||||
}
|
||||
@@ -1468,10 +1468,13 @@ public class TradingBotBase : ITradingBot
|
||||
{
|
||||
if (Positions[identifier].ProfitAndLoss == null)
|
||||
{
|
||||
Positions[identifier].ProfitAndLoss = new ProfitAndLoss(){
|
||||
Positions[identifier].ProfitAndLoss = new ProfitAndLoss()
|
||||
{
|
||||
Realized = realized
|
||||
};
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
Positions[identifier].ProfitAndLoss.Realized = realized;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user