Beispiel #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));
 }
 public static OrderBookLevel CreateLevel(string pair, double? price, CryptoOrderSide side, string key = null)
 {
     return new OrderBookLevel(
         key ?? CreateKey(price,side),
         side,
         null,
         null,
         null,
         pair == null ? null : CryptoPairsHelper.Clean(pair)
     );
 }
Beispiel #3
0
 private CryptoOrder GetOrderMock(string clientId, string pair, CryptoOrderSide side)
 {
     return(CryptoOrder.Mock(
                clientId,
                pair,
                side,
                _random.Next(10, 10000),
                _random.Next(1, 1000),
                CryptoOrderType.Market,
                DateTime.UtcNow
                ));
 }
Beispiel #4
0
        private OrderBookLevel[] ConvertLevels(Binance.Client.Websocket.Responses.Books.OrderBookLevel[] books,
                                               string pair, CryptoOrderSide side)
        {
            if (books == null)
            {
                return(new OrderBookLevel[0]);
            }

            return(books
                   .Select(x => ConvertLevel(x, pair, side))
                   .ToArray());
        }
Beispiel #5
0
        /// <summary>
        /// Level constructor
        /// </summary>
        public OrderBookLevel(string id, CryptoOrderSide side, double?price, double?amount, int?count, string pair)
        {
            Id     = id;
            Side   = side;
            Price  = price;
            Count  = count;
            Amount = amount;
            Pair   = pair == null ? null : CryptoPairsHelper.Clean(pair);

            Price  = Price;
            Amount = Abs(Amount);
            Count  = Abs(Count);
        }
Beispiel #6
0
 private OrderBookLevel ConvertLevel(Binance.Client.Websocket.Responses.Books.OrderBookLevel x,
                                     string pair, CryptoOrderSide side)
 {
     return(new OrderBookLevel
            (
                x.Price.ToString(CultureInfo.InvariantCulture),
                side,
                x.Price,
                x.Quantity,
                null,
                pair
            ));
 }
Beispiel #7
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 static string CreateKey(double? price, CryptoOrderSide side)
 {
     var sideSafe = side == CryptoOrderSide.Bid ? "bid" : "ask";
     return $"{price}-{sideSafe}";
 }
 public static OrderBookLevel CreateLevelById(string pair, double?price, double?amount, CryptoOrderSide side, int?count = 3, string key = null)
 {
     return(new OrderBookLevel(
                key ?? CreateKey(price, side),
                side,
                null,
                amount,
                count,
                pair == null ? null : CryptoPairsHelper.Clean(pair)
                ));
 }