public static AccountMarginEventMessage Create(IMarginTradingAccount account, bool isStopout, DateTime eventTime)
        {
            return(new AccountMarginEventMessage
            {
                EventId = Guid.NewGuid().ToString("N"),
                EventTime = eventTime,
                IsEventStopout = isStopout,

                ClientId = account.ClientId,
                AccountId = account.Id,
                TradingConditionId = account.TradingConditionId,
                BaseAssetId = account.BaseAssetId,
                Balance = account.Balance,
                WithdrawTransferLimit = account.WithdrawTransferLimit,

                MarginCall = account.GetMarginCallLevel(),
                StopOut = account.GetStopOutLevel(),
                TotalCapital = account.GetTotalCapital(),
                FreeMargin = account.GetFreeMargin(),
                MarginAvailable = account.GetMarginAvailable(),
                UsedMargin = account.GetUsedMargin(),
                MarginInit = account.GetMarginInit(),
                PnL = account.GetPnl(),
                OpenPositionsCount = account.GetOpenPositionsCount(),
                MarginUsageLevel = account.GetMarginUsageLevel(),
            });
        }
예제 #2
0
        public static AccountLevel GetAccountLevel(this IMarginTradingAccount account)
        {
            var marginUsageLevel = account.GetMarginUsageLevel();

            if (marginUsageLevel <= account.GetStopOutLevel())
            {
                return(AccountLevel.StopOUt);
            }

            if (marginUsageLevel <= account.GetMarginCallLevel())
            {
                return(AccountLevel.MarginCall);
            }

            return(AccountLevel.None);
        }
 public static AccountStatsContract ToRabbitMqContract(this IMarginTradingAccount account, bool isLive)
 {
     return(new AccountStatsContract
     {
         AccountId = account.Id,
         ClientId = account.ClientId,
         TradingConditionId = account.TradingConditionId,
         BaseAssetId = account.BaseAssetId,
         Balance = account.Balance,
         WithdrawTransferLimit = account.WithdrawTransferLimit,
         MarginCallLevel = account.GetMarginCallLevel(),
         StopOutLevel = account.GetStopOutLevel(),
         TotalCapital = account.GetTotalCapital(),
         FreeMargin = account.GetFreeMargin(),
         MarginAvailable = account.GetMarginAvailable(),
         UsedMargin = account.GetUsedMargin(),
         MarginInit = account.GetMarginInit(),
         PnL = account.GetPnl(),
         OpenPositionsCount = account.GetOpenPositionsCount(),
         MarginUsageLevel = account.GetMarginUsageLevel(),
         IsLive = isLive,
         LegalEntity = account.LegalEntity,
     });
 }
예제 #4
0
 public static MarginTradingAccountBackendContract ToFullBackendContract(this IMarginTradingAccount src, bool isLive)
 {
     return(new MarginTradingAccountBackendContract
     {
         Id = src.Id,
         ClientId = src.ClientId,
         TradingConditionId = src.TradingConditionId,
         BaseAssetId = src.BaseAssetId,
         Balance = src.Balance,
         WithdrawTransferLimit = src.WithdrawTransferLimit,
         MarginCall = src.GetMarginCallLevel(),
         StopOut = src.GetStopOutLevel(),
         TotalCapital = src.GetTotalCapital(),
         FreeMargin = src.GetFreeMargin(),
         MarginAvailable = src.GetMarginAvailable(),
         UsedMargin = src.GetUsedMargin(),
         MarginInit = src.GetMarginInit(),
         PnL = src.GetPnl(),
         OpenPositionsCount = src.GetOpenPositionsCount(),
         MarginUsageLevel = src.GetMarginUsageLevel(),
         IsLive = isLive,
         LegalEntity = src.LegalEntity,
     });
 }