Exemplo n.º 1
0
        public Task <List <OrderContract> > ListAsync([FromQuery] string accountId     = null,
                                                      [FromQuery] string assetPairId   = null, [FromQuery] string parentPositionId = null,
                                                      [FromQuery] string parentOrderId = null)
        {
            // do not call get by account, it's slower for single account
            IEnumerable <Order> orders = _ordersCache.GetAllOrders();

            if (!string.IsNullOrWhiteSpace(accountId))
            {
                orders = orders.Where(o => o.AccountId == accountId);
            }

            if (!string.IsNullOrWhiteSpace(assetPairId))
            {
                orders = orders.Where(o => o.AssetPairId == assetPairId);
            }

            if (!string.IsNullOrWhiteSpace(parentPositionId))
            {
                orders = orders.Where(o => o.ParentPositionId == parentPositionId);
            }

            if (!string.IsNullOrWhiteSpace(parentOrderId))
            {
                orders = orders.Where(o => o.ParentOrderId == parentOrderId);
            }

            return(Task.FromResult(orders.Select(o => o.ConvertToContract(_ordersCache)).ToList()));
        }
Exemplo n.º 2
0
        private async Task DumpOrdersToRepository()
        {
            try
            {
                var orders = _orderCache.GetAllOrders();

                if (orders != null)
                {
                    await _blobRepository.WriteAsync(LykkeConstants.StateBlobContainer, OrdersBlobName, orders);
                }
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(OrdersCache), "Save orders", "", ex);
            }
        }