Add event
This commit is contained in:
@@ -377,6 +377,27 @@ public class TradingBotBase : ITradingBot
|
||||
if (position.Status.Equals(PositionStatus.New))
|
||||
{
|
||||
await SetPositionStatus(position.SignalIdentifier, PositionStatus.Filled);
|
||||
|
||||
// Notify platform summary about the executed trade
|
||||
try
|
||||
{
|
||||
await ServiceScopeHelpers.WithScopedService<IGrainFactory>(_scopeFactory, async grainFactory =>
|
||||
{
|
||||
var platformGrain = grainFactory.GetGrain<IPlatformSummaryGrain>("platform-summary");
|
||||
var tradeExecutedEvent = new TradeExecutedEvent
|
||||
{
|
||||
TradeId = position.Identifier,
|
||||
Ticker = position.Ticker,
|
||||
Volume = position.Open.Price * position.Open.Quantity * position.Open.Leverage
|
||||
};
|
||||
|
||||
await platformGrain.OnTradeExecutedAsync(tradeExecutedEvent);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Failed to notify platform summary about trade execution for position {PositionId}", position.Identifier);
|
||||
}
|
||||
}
|
||||
|
||||
position = brokerPosition;
|
||||
|
||||
Reference in New Issue
Block a user