コード例 #1
0
        public Task ProcessNewExternalOrderbookAsync(ExternalExchangeOrderbookMessage orderbook)
        {
            var quotesSource = _assetPairSourceTypeService.Get(orderbook.AssetPairId);

            if (quotesSource != AssetPairQuotesSourceTypeDomainEnum.External ||
                (orderbook.Bids?.Count ?? 0) == 0 || (orderbook.Asks?.Count ?? 0) == 0)
            {
                return(Task.CompletedTask);
            }

            var externalOrderbook = new ExternalOrderbook(orderbook.AssetPairId, orderbook.Source, _system.UtcNow,
                                                          orderbook.Bids.OrderByDescending(p => p.Price).Select(b => new OrderbookPosition(b.Price, b.Volume))
                                                          .ToImmutableArray(),
                                                          orderbook.Asks.OrderBy(p => p.Price).Select(b => new OrderbookPosition(b.Price, b.Volume))
                                                          .ToImmutableArray());
            var resultingOrderbook = _generateOrderbookService.OnNewOrderbook(externalOrderbook);

            if (resultingOrderbook == null)
            {
                return(Task.CompletedTask);
            }

            var orderbooksToSend = _crossRatesService.CalcDependentOrderbooks(resultingOrderbook)
                                   .Add(resultingOrderbook);

            return(SendOrderCommandsAsync(orderbooksToSend));
        }
コード例 #2
0
 public IReadOnlyList <AssetPairModel> List()
 {
     return(_assetPairSourceTypeService.Get()
            .OrderBy(d => d.Key)
            .Select(d => new AssetPairModel {
         SourceType = d.Value.ToString(), AssetPairId = d.Key
     })
            .ToList());
 }
コード例 #3
0
        public ImmutableList <Orderbook> CalcDependentOrderbooks([NotNull] Orderbook orderbook) // ex: (btcusd)
        {
            _orderbooks[orderbook.AssetPairId] = orderbook
                                                 ?? throw new ArgumentNullException(nameof(orderbook));
            var dependent = _crossRateCalcInfosService.GetDependentAssetPairs(orderbook.AssetPairId)
                            .Where(p => _assetPairSourceTypeService.Get(p.ResultingPairId) ==
                                   AssetPairQuotesSourceTypeDomainEnum.CrossRates); // ex: btceur

            return(dependent.Select(CalculateOrderbook).Where(o => o != null).ToImmutableList());
        }