Improve Platform stats
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Application.Abstractions.Grains;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Application.Trading.Commands;
|
||||
using Managing.Common;
|
||||
@@ -13,7 +12,7 @@ namespace Managing.Application.Trading.Handlers
|
||||
IExchangeService exchangeService,
|
||||
IAccountService accountService,
|
||||
ITradingService tradingService,
|
||||
IGrainFactory? grainFactory = null)
|
||||
IGrainFactory grainFactory = null)
|
||||
: ICommandHandler<OpenPositionRequest, Position>
|
||||
{
|
||||
public async Task<Position> Handle(OpenPositionRequest request)
|
||||
@@ -106,29 +105,6 @@ namespace Managing.Application.Trading.Handlers
|
||||
if (!request.IsForPaperTrading)
|
||||
{
|
||||
await tradingService.InsertPositionAsync(position);
|
||||
|
||||
// Notify platform summary about the opened position
|
||||
try
|
||||
{
|
||||
var platformGrain = grainFactory?.GetGrain<IPlatformSummaryGrain>("platform-summary");
|
||||
if (platformGrain != null)
|
||||
{
|
||||
var positionOpenedEvent = new PositionOpenedEvent
|
||||
{
|
||||
PositionId = position.Identifier,
|
||||
Ticker = position.Ticker,
|
||||
Volume = position.Open.Price * position.Open.Quantity * position.Open.Leverage,
|
||||
Direction = position.OriginDirection
|
||||
};
|
||||
|
||||
await platformGrain.OnPositionOpenedAsync(positionOpenedEvent);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Log error but don't fail the position creation
|
||||
// This is a non-critical notification
|
||||
}
|
||||
}
|
||||
|
||||
return position;
|
||||
|
||||
Reference in New Issue
Block a user