Пример #1
0
        public async Task <IEnumerable <ConversionResult> > GetMarketAmountInBase(
            IEnumerable <AssetWithAmount> assetsFrom,
            string assetIdTo,
            OrderAction orderAction)
        {
            var assetPairsDict = _assetPairsReadModelRepository.GetAll();

            var assetsDict    = _assetsReadModelRepository.GetAll().ToDictionary(x => x.Id);
            var marketProfile = await GetMarketProfileRemoteAsync();

            var assetWithAmounts    = assetsFrom as AssetWithAmount[] ?? assetsFrom.ToArray();
            var assetPairsToProcess = assetWithAmounts
                                      .Select(assetFrom => GetPairWithAssets(assetPairsDict, assetFrom.AssetId, assetIdTo))
                                      .Where(p => p != null);

            var orderBooks = (await _orderBooksService.GetAllAsync(assetPairsToProcess)).ToArray();

            if (!orderBooks.Any())
            {
                return(Array.Empty <ConversionResult>());
            }

            return(assetWithAmounts.Select(item => GetMarketAmountInBase(
                                               orderAction,
                                               orderBooks,
                                               item,
                                               assetIdTo,
                                               assetsDict,
                                               assetPairsDict,
                                               marketProfile)));
        }
        public async Task <IActionResult> GetAllAsync([FromQuery] OrderBookRequestMany request, [FromRoute] string brokerId)
        {
            var sortOrder = request.Order == PaginationOrder.Asc
                ? ListSortDirection.Ascending
                : ListSortDirection.Descending;

            var accounts = _orderBooksService.GetAllAsync(brokerId, request.Symbol, sortOrder, request.Cursor, request.Limit);

            var result = _mapper.Map <OrderBookModel[]>(accounts);

            return(Ok(result.Paginate(request, Url, x => x.Symbol)));
        }
Пример #3
0
        public async Task <IActionResult> Get(string assetPairId = null)
        {
            assetPairId = string.IsNullOrEmpty(assetPairId)
                ? null
                : assetPairId.ToUpper();

            AssetPair pair = null;

            if (!string.IsNullOrEmpty(assetPairId))
            {
                pair = await _assetPairs.GetItemAsync(assetPairId);
            }

            if (!string.IsNullOrEmpty(assetPairId) && pair == null)
            {
                return(NotFound($"Asset pair {assetPairId} not found"));
            }

            IEnumerable <IOrderBook> result = string.IsNullOrEmpty(assetPairId)
                ? await _orderBooksService.GetAllAsync()
                : await _orderBooksService.GetAsync(assetPairId);

            return(Ok(result.ToApiModel()));
        }
        public async Task <IActionResult> GetOrderBooks()
        {
            var orderBooks = await _orderBooksService.GetAllAsync();

            return(Ok(orderBooks));
        }
 public Task <IEnumerable <IOrderBook> > Get()
 {
     return(_orderBooksService.GetAllAsync());
 }