Update account/position and platform summary
This commit is contained in:
@@ -21,7 +21,7 @@ namespace Managing.Application.Trading.Handlers
|
||||
var account = await accountService.GetAccount(request.AccountName, hideSecrets: false, getBalance: false);
|
||||
|
||||
var initiator = request.IsForPaperTrading ? PositionInitiator.PaperTrading : request.Initiator;
|
||||
var position = new Position(Guid.NewGuid(), request.AccountName, request.Direction,
|
||||
var position = new Position(Guid.NewGuid(), account.Id, request.Direction,
|
||||
request.Ticker,
|
||||
request.MoneyManagement,
|
||||
initiator, request.Date, request.User);
|
||||
@@ -45,9 +45,10 @@ namespace Managing.Application.Trading.Handlers
|
||||
}
|
||||
|
||||
// Gas fee check for EVM exchanges
|
||||
decimal gasFeeUsd = 0;
|
||||
if (account.Exchange == TradingExchanges.Evm || account.Exchange == TradingExchanges.GmxV2)
|
||||
{
|
||||
var gasFeeUsd = await exchangeService.GetFee(account);
|
||||
gasFeeUsd = await exchangeService.GetFee(account);
|
||||
if (gasFeeUsd > Constants.GMX.Config.MaximumGasFeeUsd)
|
||||
{
|
||||
throw new InsufficientFundsException(
|
||||
@@ -84,6 +85,22 @@ namespace Managing.Application.Trading.Handlers
|
||||
|
||||
position.Open = trade;
|
||||
|
||||
// Calculate and set fees for the position
|
||||
var positionSizeUsd = (position.Open.Price * position.Open.Quantity) * position.Open.Leverage;
|
||||
|
||||
// Set gas fees (only for EVM exchanges)
|
||||
if (account.Exchange == TradingExchanges.Evm || account.Exchange == TradingExchanges.GmxV2)
|
||||
{
|
||||
position.GasFees = gasFeeUsd;
|
||||
}
|
||||
else
|
||||
{
|
||||
position.GasFees = TradingHelpers.CalculateOpeningGasFees();
|
||||
}
|
||||
|
||||
// Set UI fees for opening
|
||||
position.UiFees = TradingHelpers.CalculateOpeningUiFees(positionSizeUsd);
|
||||
|
||||
var closeDirection = request.Direction == TradeDirection.Long
|
||||
? TradeDirection.Short
|
||||
: TradeDirection.Long;
|
||||
|
||||
Reference in New Issue
Block a user