public void Throws()
        {
            var time = DateTimeOffset.FromUnixTimeMilliseconds(DateTime.UtcNow.ToTimestamp()).UtcDateTime;

            var           symbol = Symbol.BTC_USDT;
            const decimal price  = 4999;

            const OrderRejectedReason orderRejectedReason = OrderRejectedReason.None;
            const string newClientOrderId = "new-test-order";

            const long    tradeId          = 12345;
            const long    orderId          = 54321;
            const decimal quantity         = 1;
            const decimal commission       = 10;
            const string  commissionAsset  = "BNB";
            const bool    isBuyer          = true;
            const bool    isMaker          = true;
            const bool    isBestPriceMatch = true;

            var trade = new AccountTrade(symbol, tradeId, orderId, price, quantity, commission, commissionAsset, time, isBuyer, isMaker, isBestPriceMatch);

            decimal quantityOfLastFilledTrade = 1;

            using (var cts = new CancellationTokenSource())
            {
                Assert.Throws <ArgumentNullException>("order", () => new AccountTradeUpdateEventArgs(time, cts.Token, null, orderRejectedReason, newClientOrderId, trade, quantityOfLastFilledTrade));
            }
        }
Exemple #2
0
        public void Throws()
        {
            var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();

            var               user             = new BinanceApiUser("api-key");
            var               symbol           = Symbol.BTC_USDT;
            const long        id               = 123456;
            const string      clientOrderId    = "test-order";
            const decimal     price            = 4999;
            const decimal     originalQuantity = 1;
            const decimal     executedQuantity = 0.5m;
            const OrderStatus status           = OrderStatus.PartiallyFilled;
            const TimeInForce timeInForce      = TimeInForce.IOC;
            const OrderType   orderType        = OrderType.Market;
            const OrderSide   orderSide        = OrderSide.Sell;
            const decimal     stopPrice        = 5000;
            const decimal     icebergQuantity  = 0.1m;
            const bool        isWorking        = true;

            var order = new Order(user, symbol, id, clientOrderId, price, originalQuantity, executedQuantity, status, timeInForce, orderType, orderSide, stopPrice, icebergQuantity, timestamp, isWorking);

            const OrderExecutionType  orderExecutionType  = OrderExecutionType.New;
            const OrderRejectedReason orderRejectedReason = OrderRejectedReason.None;
            const string newClientOrderId = "new-test-order";

            using (var cts = new CancellationTokenSource())
            {
                Assert.Throws <ArgumentException>("timestamp", () => new OrderUpdateEventArgs(-1, cts.Token, order, orderExecutionType, orderRejectedReason, newClientOrderId));
                Assert.Throws <ArgumentException>("timestamp", () => new OrderUpdateEventArgs(0, cts.Token, order, orderExecutionType, orderRejectedReason, newClientOrderId));
                Assert.Throws <ArgumentNullException>("order", () => new OrderUpdateEventArgs(timestamp, cts.Token, null, orderExecutionType, orderRejectedReason, newClientOrderId));
            }
        }
        public void Properties()
        {
            var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();

            var               user             = new BinanceApiUser("api-key");
            var               symbol           = Symbol.BTC_USDT;
            const long        id               = 123456;
            const string      clientOrderId    = "test-order";
            const decimal     price            = 4999;
            const decimal     originalQuantity = 1;
            const decimal     executedQuantity = 0.5m;
            const OrderStatus status           = OrderStatus.PartiallyFilled;
            const TimeInForce timeInForce      = TimeInForce.IOC;
            const OrderType   orderType        = OrderType.Market;
            const OrderSide   orderSide        = OrderSide.Sell;
            const decimal     stopPrice        = 5000;
            const decimal     icebergQuantity  = 0.1m;

            var order = new Order(user, symbol, id, clientOrderId, price, originalQuantity, executedQuantity, status, timeInForce, orderType, orderSide, stopPrice, icebergQuantity, timestamp);

            const OrderExecutionType  orderExecutionType  = OrderExecutionType.New;
            const OrderRejectedReason orderRejectedReason = OrderRejectedReason.None;
            const string newClientOrderId = "new-test-order";

            using (var cts = new CancellationTokenSource())
            {
                var args = new OrderUpdateEventArgs(timestamp, cts.Token, order, orderExecutionType, orderRejectedReason, newClientOrderId);

                Assert.Equal(timestamp, args.Timestamp);
                Assert.Equal(order, args.Order);
                Assert.Equal(orderExecutionType, args.OrderExecutionType);
                Assert.Equal(orderRejectedReason, args.OrderRejectedReason);
                Assert.Equal(newClientOrderId, args.NewClientOrderId);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="timestamp">The event time.</param>
        /// <param name="token">The cancellation token.</param>
        /// <param name="order">The order.</param>
        /// <param name="orderExecutionType">The order execution type.</param>
        /// <param name="orderRejectedReason">The order rejected reason.</param>
        /// <param name="newClientOrderId">The new client order ID.</param>
        protected OrderExecutionEventArgs(long timestamp, CancellationToken token, Order order, OrderExecutionType orderExecutionType, OrderRejectedReason orderRejectedReason, string newClientOrderId)
            : base(timestamp, token)
        {
            Throw.IfNull(order, nameof(order));

            Order = order;
            OrderExecutionType  = orderExecutionType;
            OrderRejectedReason = orderRejectedReason;
            NewClientOrderId    = newClientOrderId;
        }
        public void Throws()
        {
            var time = DateTimeOffset.FromUnixTimeMilliseconds(DateTime.UtcNow.ToTimestamp()).UtcDateTime;

            const OrderExecutionType  orderExecutionType  = OrderExecutionType.New;
            const OrderRejectedReason orderRejectedReason = OrderRejectedReason.None;
            const string newClientOrderId = "new-test-order";

            using (var cts = new CancellationTokenSource())
            {
                Assert.Throws <ArgumentNullException>("order", () => new OrderUpdateEventArgs(time, cts.Token, null, orderExecutionType, orderRejectedReason, newClientOrderId));
            }
        }
        public void Properties()
        {
            var time = DateTimeOffset.FromUnixTimeMilliseconds(DateTime.UtcNow.ToTimestamp()).UtcDateTime;

            var               user             = new BinanceApiUser("api-key");
            var               symbol           = Symbol.BTC_USDT;
            const int         id               = 123456;
            const string      clientOrderId    = "test-order";
            const decimal     price            = 4999;
            const decimal     originalQuantity = 1;
            const decimal     executedQuantity = 0.5m;
            const OrderStatus status           = OrderStatus.PartiallyFilled;
            const TimeInForce timeInForce      = TimeInForce.IOC;
            const OrderType   orderType        = OrderType.Market;
            const OrderSide   orderSide        = OrderSide.Sell;
            const decimal     stopPrice        = 5000;
            const decimal     icebergQuantity  = 0.1m;
            const bool        isWorking        = true;

            var order = new Order(user, symbol, id, clientOrderId, price, originalQuantity, executedQuantity, status, timeInForce, orderType, orderSide, stopPrice, icebergQuantity, time, isWorking);

            const OrderRejectedReason orderRejectedReason = OrderRejectedReason.None;
            const string newClientOrderId = "new-test-order";

            const long    tradeId          = 12345;
            const long    orderId          = 54321;
            const decimal quantity         = 1;
            const decimal commission       = 10;
            const string  commissionAsset  = "BNB";
            const bool    isBuyer          = true;
            const bool    isMaker          = true;
            const bool    isBestPriceMatch = true;

            var trade = new AccountTrade(symbol, tradeId, orderId, price, quantity, commission, commissionAsset, time, isBuyer, isMaker, isBestPriceMatch);

            const decimal quantityOfLastFilledTrade = 1;

            using (var cts = new CancellationTokenSource())
            {
                var args = new AccountTradeUpdateEventArgs(time, cts.Token, order, orderRejectedReason, newClientOrderId, trade, quantityOfLastFilledTrade);

                Assert.Equal(time, args.Time);
                Assert.Equal(order, args.Order);
                Assert.Equal(OrderExecutionType.Trade, args.OrderExecutionType);
                Assert.Equal(orderRejectedReason, args.OrderRejectedReason);
                Assert.Equal(newClientOrderId, args.NewClientOrderId);
                Assert.Equal(trade, args.Trade);
                Assert.Equal(quantityOfLastFilledTrade, args.QuantityOfLastFilledTrade);
            }
        }
Exemple #7
0
        public void Throws()
        {
            var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();

            var               user             = new BinanceApiUser("api-key");
            var               symbol           = Symbol.BTC_USDT;
            const int         id               = 123456;
            const string      clientOrderId    = "test-order";
            const decimal     price            = 4999;
            const decimal     originalQuantity = 1;
            const decimal     executedQuantity = 0.5m;
            const OrderStatus status           = OrderStatus.PartiallyFilled;
            const TimeInForce timeInForce      = TimeInForce.IOC;
            const OrderType   orderType        = OrderType.Market;
            const OrderSide   orderSide        = OrderSide.Sell;
            const decimal     stopPrice        = 5000;
            const decimal     icebergQuantity  = 0.1m;

            var order = new Order(user, symbol, id, clientOrderId, price, originalQuantity, executedQuantity, status, timeInForce, orderType, orderSide, stopPrice, icebergQuantity, timestamp);

            const OrderRejectedReason orderRejectedReason = OrderRejectedReason.None;
            const string newClientOrderId = "new-test-order";

            const long    tradeId          = 12345;
            const long    orderId          = 54321;
            const decimal quantity         = 1;
            const decimal commission       = 10;
            const string  commissionAsset  = "BNB";
            const bool    isBuyer          = true;
            const bool    isMaker          = true;
            const bool    isBestPriceMatch = true;

            var trade = new AccountTrade(symbol, tradeId, orderId, price, quantity, commission, commissionAsset, timestamp, isBuyer, isMaker, isBestPriceMatch);

            decimal quantityOfLastFilledTrade = 1;

            using (var cts = new CancellationTokenSource())
            {
                Assert.Throws <ArgumentException>("timestamp", () => new AccountTradeUpdateEventArgs(-1, cts.Token, order, orderRejectedReason, newClientOrderId, trade, quantityOfLastFilledTrade));
                Assert.Throws <ArgumentException>("timestamp", () => new AccountTradeUpdateEventArgs(0, cts.Token, order, orderRejectedReason, newClientOrderId, trade, quantityOfLastFilledTrade));
                Assert.Throws <ArgumentNullException>("order", () => new AccountTradeUpdateEventArgs(timestamp, cts.Token, null, orderRejectedReason, newClientOrderId, trade, quantityOfLastFilledTrade));
            }
        }
Exemple #8
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="time">The event time.</param>
 /// <param name="token">The cancellation token.</param>
 /// <param name="order">The order.</param>
 /// <param name="executionType">The order execution type.</param>
 /// <param name="rejectedReason">The order rejected reason.</param>
 /// <param name="newClientOrderId">The new client order ID.</param>
 public OrderUpdateEventArgs(DateTime time, CancellationToken token, Order order, OrderExecutionType executionType, OrderRejectedReason rejectedReason, string newClientOrderId)
     : base(time, token, order, executionType, rejectedReason, newClientOrderId)
 {
 }
Exemple #9
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="timestamp">The event time.</param>
        /// <param name="token">The cancellation token.</param>
        /// <param name="order">The order.</param>
        /// <param name="rejectedReason">The order rejected reason.</param>
        /// <param name="newClientOrderId">The new client order ID.</param>
        /// <param name="trade">The trade.</param>
        /// <param name="quantityOfLastFilledTrade">The quantity of last filled trade.</param>
        public AccountTradeUpdateEventArgs(long timestamp, CancellationToken token, Order order, OrderRejectedReason rejectedReason, string newClientOrderId, AccountTrade trade, decimal quantityOfLastFilledTrade)
            : base(timestamp, token, order, OrderExecutionType.Trade, rejectedReason, newClientOrderId)
        {
            Throw.IfNull(trade, nameof(trade));

            Trade = trade;
            QuantityOfLastFilledTrade = quantityOfLastFilledTrade;
        }