Exemplo n.º 1
0
 private OrderBookLevel ConvertLevel(BookLevel x, CryptoOrderSide side, string pair)
 {
     return(new OrderBookLevel(
                x.Price.ToString(CultureInfo.InvariantCulture),
                side,
                (double)x.Price,
                (double)x.Size,
                null, // TODO: really null?
                pair));
 }
        private void InsertNewBook(BookLevel book)
        {
            var id = book.Id;

            if (book.Side == CoinbaseSide.Buy)
            {
                _bids[id] = book;
                return;
            }

            _asks[id] = book;
        }
        private void RemoveBook(BookLevel book)
        {
            var id = book.Id;

            if (_bids.ContainsKey(id))
            {
                _bids.Remove(id);
            }
            if (_asks.ContainsKey(id))
            {
                _asks.Remove(id);
            }
        }
Exemplo n.º 4
0
 private OrderBookLevel ConvertLevel(BookLevel x, CryptoOrderSide side, string pair)
 {
     return(new OrderBookLevel
            (
                x.OrderId > 0 ?
                x.OrderId.ToString(CultureInfo.InvariantCulture) :
                x.Price.ToString(CultureInfo.InvariantCulture),
                side,
                x.Price,
                x.Amount,
                null,
                pair
            ));
 }
        public override object ReadJson(
            JsonReader reader,
            Type objectType,
            object?existingValue,
            JsonSerializer serializer)
        {
            var bookLevelList = new List <BookLevel>();
            var data          = JArray.Load(reader);

            foreach (var source in data)
            {
                var array = source.ToArray();
                if (array.Length == 2)
                {
                    var bookLevel = new BookLevel(_side, (decimal)array[0], (decimal)array[1]);
                    bookLevelList.Add(bookLevel);
                }
            }

            return(bookLevelList.ToArray());
        }
        private void UpdateBook(BookLevel book)
        {
            var       id    = book.Id;
            BookLevel found = null;

            if (_bids.ContainsKey(id))
            {
                found = _bids[id];
            }
            if (_asks.ContainsKey(id))
            {
                found = _asks[id];
            }

            if (found == null)
            {
                return;
            }

            found.Size = book.Size;
        }
Exemplo n.º 7
0
        public async Task <ProductBook> GetProductBook(ProductType productType, BookLevel level)
        {
            var parameters = new [] { new KeyValuePair <string, string>("level", ((int)level).ToString()) };

            return(await SendGetRequest <ProductBook>(string.Format(Constants.RestUrl.ProductBook, productType.EnumToString()), Method.GET, parameters));
        }
Exemplo n.º 8
0
 public Task <ProductBook> GetProductBook(ProductType productType, BookLevel level)
 {
     return(Task.FromResult <ProductBook>(null));
 }