Beispiel #1
0
 internal LineItem(OrderBookDto bookOrder, byte lineNum)
 {
     NumBooks  = bookOrder.NumBooks;
     BookId    = bookOrder.Book.BookId;
     BookPrice = bookOrder.Book.ActualPrice;
     BookView  = bookOrder.Book;
     LineNum   = lineNum;
 }
 public static OrderBook FromModel(OrderBookDto data)
 => new OrderBook()
 {
     Id     = data.Id,
     Symbol = data.Symbol,
     Price  = data.Price,
     Side   = data.Side,
     Size   = data.Size
 };
Beispiel #3
0
 public static OrderBook ToOrderBook(this OrderBookDto dto)
 {
     return(new OrderBook()
     {
         Time = ToDateTime(dto.timestamp),
         Asks = dto.asks.Select(arr => new Bet()
         {
             Price = (decimal)arr[0], Volume = (decimal)arr[1]
         }).ToArray(),
         Bids = dto.bids.Select(arr => new Bet()
         {
             Price = (decimal)arr[0], Volume = (decimal)arr[1]
         }).ToArray(),
     });
 }
Beispiel #4
0
        public async Task <OrderBook> OrderBook(string symbol, int depth)
        {
            if (depth <= 0 || depth > 2000)
            {
                throw new Exception($"Depth {depth} is outside bounds");
            }

            try
            {
                OrderBookDto orderBookDto = await _publicApi.OrderBook(symbol, depth);

                var res = new OrderBook()
                {
                    Code   = orderBookDto.Code,
                    Orders = new OrderBook.Order()
                    {
                        Asks = new List <OrderBook.Ask>(),
                        Bids = new List <OrderBook.Bid>()
                    }
                };

                foreach (var order in orderBookDto.Data.Asks)
                {
                    res.Orders.Asks.Add(new OrderBook.Ask
                    {
                        Price    = ParseDecimal(order.Price),
                        Quantity = ParseDecimal(order.Quantity),
                    });
                }

                foreach (var order in orderBookDto.Data.Bids)
                {
                    res.Orders.Bids.Add(new OrderBook.Bid
                    {
                        Price    = ParseDecimal(order.Price),
                        Quantity = ParseDecimal(order.Quantity),
                    });
                }

                return(res);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #5
0
        public async Task <OrderBook> OrderBook(string market, int limit, int offset = 0)
        {
            try
            {
                OrderBookDto sellOrders = await _publicApi.OrderBook(market, limit, 1, offset);

                OrderBookDto buyOrders = await _publicApi.OrderBook(market, limit, 2, offset);

                var res = new OrderBook()
                {
                    Error  = buyOrders.Error,
                    Id     = buyOrders.Id,
                    Bids   = new List <Order>(),
                    Asks   = new List <Order>(),
                    Limit  = limit,
                    Offset = offset,
                    Total  = sellOrders.Result.Total + buyOrders.Result.Total
                };

                foreach (var order in sellOrders.Result.Orders)
                {
                    res.Asks.Add(ParseOrder(order));
                }

                foreach (var order in buyOrders.Result.Orders)
                {
                    res.Bids.Add(ParseOrder(order));
                }

                return(res);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #6
0
 public static OrderBook mapToEntityOrderBook(OrderBookDto orderBookDto)
 {
     return(new OrderBook(orderBookDto.kolvo, orderBookDto.bookId));
 }