public async Task <IEnumerable <OrderBookResult> > BuildOrderBook() { var assetPairs = (await _assetPairsRepository.GetAllAsync()).ToDictionary(itm => itm.Id); var limitOrders = await _activeLimitOrdersRepository.GetAsync(); var result = new Dictionary <string, OrderBookResult>(); foreach (var limitOrder in limitOrders) { if (!assetPairs.ContainsKey(limitOrder.AssetPairId)) { continue; } var assetPair = assetPairs[limitOrder.AssetPairId]; if (!result.ContainsKey(limitOrder.AssetPairId)) { result.Add(limitOrder.AssetPairId, OrderBookResult.Create(assetPair)); } var orderbook = result[limitOrder.AssetPairId]; orderbook.AddLimitOrder(limitOrder); } return(result.Values); }
public static async Task <IAssetPair> GetAsync(this IAssetPairsRepository assetPairsRepository, string assetId1, string assetId2) { var assetPairs = await assetPairsRepository.GetAllAsync(); return(assetPairs.FirstOrDefault(itm => (itm.BaseAssetId == assetId1 && itm.QuotingAssetId == assetId2) || (itm.BaseAssetId == assetId2 && itm.QuotingAssetId == assetId1))); }
public async Task <ActionResult> Index() { var viewModel = new AssetPairsIndexViewModel { Assets = (await _assetsRepository.GetAssetsAsync()).ToDictionary(itm => itm.Id), AssetPairs = await _assetPairsRepository.GetAllAsync() }; return(View(viewModel)); }
private async Task LoadCache() { var assetPairs = await _assetPairsRepository.GetAllAsync(); _cache = assetPairs.ToDictionary(itm => itm.Id); }