public MarginTradingAccount GetAccountById(string accountId) { if (string.IsNullOrWhiteSpace(accountId)) { throw new ArgumentNullException(nameof(accountId)); } if (_draftSnapshotKeeper.Initialized()) { _log.WriteInfoAsync(nameof(AccountsProvider), nameof(GetAccountById), _draftSnapshotKeeper.TradingDay.ToJson(), "Draft snapshot keeper initialized and will be used as accounts provider"); var accounts = _draftSnapshotKeeper .GetAccountsAsync() .GetAwaiter() .GetResult(); return(accounts .SingleOrDefault(a => a.Id == accountId)); } return(_accountsCacheService.TryGet(accountId)); }
public ICollection <Position> GetPositionsByAccountIds(params string[] accountIds) { if (accountIds == null || !accountIds.Any() || accountIds.Any(string.IsNullOrWhiteSpace)) { throw new ArgumentNullException(nameof(accountIds)); } if (_draftSnapshotKeeper.Initialized()) { _log.WriteInfoAsync(nameof(PositionsProvider), nameof(GetPositionsByAccountIds), _draftSnapshotKeeper.TradingDay.ToJson(), "Draft snapshot keeper initialized and will be used as positions provider"); var positions = _draftSnapshotKeeper.GetPositions(); return(positions .Where(p => accountIds.Contains(p.AccountId)) .ToList()); } return(_ordersCache.Positions.GetPositionsByAccountIds(accountIds)); }
public ICollection <Order> GetActiveOrdersByAccountIds(params string[] accountIds) { if (accountIds == null || !accountIds.Any() || accountIds.Any(string.IsNullOrWhiteSpace)) { throw new ArgumentNullException(nameof(accountIds)); } if (_draftSnapshotKeeper.Initialized()) { _log.WriteInfoAsync(nameof(OrdersProvider), nameof(GetActiveOrdersByAccountIds), _draftSnapshotKeeper.TradingDay.ToJson(), "Draft snapshot keeper initialized and will be used as orders provider"); var orders = _draftSnapshotKeeper.GetAllOrders(); return(orders .Where(o => o.Status == OrderStatus.Active && accountIds.Contains(o.AccountId)) .ToList()); } return(_ordersCache.Active.GetOrdersByAccountIds(accountIds)); }