public static AccountStatContract ConvertToContract(this IMarginTradingAccount account)
 {
     return(new AccountStatContract
     {
         AccountId = account.Id,
         BaseAssetId = account.BaseAssetId,
         Balance = account.Balance,
         LastBalanceChangeTime = account.LastBalanceChangeTime,
         MarginCallLevel = account.GetMarginCall1Level(),
         StopOutLevel = account.GetStopOutLevel(),
         TotalCapital = account.GetTotalCapital(),
         FreeMargin = account.GetFreeMargin(),
         MarginAvailable = account.GetMarginAvailable(),
         UsedMargin = account.GetUsedMargin(),
         CurrentlyUsedMargin = account.GetCurrentlyUsedMargin(),
         InitiallyUsedMargin = account.GetInitiallyUsedMargin(),
         MarginInit = account.GetMarginInit(),
         PnL = account.GetPnl(),
         UnrealizedDailyPnl = account.GetUnrealizedDailyPnl(),
         OpenPositionsCount = account.GetOpenPositionsCount(),
         ActiveOrdersCount = account.GetActiveOrdersCount(),
         MarginUsageLevel = account.GetMarginUsageLevel(),
         LegalEntity = account.LegalEntity,
         IsInLiquidation = account.IsInLiquidation(),
         MarginNotificationLevel = account.GetAccountLevel().ToString()
     });
 }
        public static MarginEventMessage Create(IMarginTradingAccount account, MarginEventTypeContract eventType,
                                                DateTime eventTime)
        {
            return(new MarginEventMessage
            {
                EventId = Guid.NewGuid().ToString("N"),
                EventTime = eventTime,
                EventType = eventType,

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

                MarginCall1Level = account.GetMarginCall1Level(),
                MarginCall2Level = account.GetMarginCall2Level(),
                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(),
            });
        }
示例#3
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);
        }
示例#4
0
 public static AccountStatsContract ToRabbitMqContract(this IMarginTradingAccount account)
 {
     return(new AccountStatsContract
     {
         AccountId = account.Id,
         ClientId = account.ClientId,
         TradingConditionId = account.TradingConditionId,
         BaseAssetId = account.BaseAssetId,
         Balance = account.Balance,
         WithdrawTransferLimit = account.WithdrawTransferLimit,
         MarginCallLevel = account.GetMarginCall1Level(),
         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(),
         LegalEntity = account.LegalEntity,
     });
 }
示例#5
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,
     });
 }