Ejemplo n.º 1
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));
            }
        }
Ejemplo n.º 2
0
        public void Properties()
        {
            var time = DateTimeOffset.FromUnixTimeMilliseconds(DateTime.UtcNow.ToTimestamp()).UtcDateTime;

            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, time, isWorking);

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

            var args = new OrderUpdateEventArgs(time, order, orderExecutionType, orderRejectedReason, newClientOrderId);

            Assert.Equal(time, args.Time);
            Assert.Equal(order, args.Order);
            Assert.Equal(orderExecutionType, args.OrderExecutionType);
            Assert.Equal(orderRejectedReason, args.OrderRejectedReason);
            Assert.Equal(newClientOrderId, args.NewClientOrderId);
        }
Ejemplo n.º 3
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="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;
        }
Ejemplo n.º 4
0
        public void Throws()
        {
            var time = DateTimeOffset.FromUnixTimeMilliseconds(DateTime.UtcNow.ToTimestamp()).UtcDateTime;

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

            Assert.Throws <ArgumentNullException>("order", () => new OrderUpdateEventArgs(time, null, orderExecutionType, orderRejectedReason, newClientOrderId));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="time">The event time.</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(DateTime time, Order order, OrderExecutionType orderExecutionType, string orderRejectedReason, string newClientOrderId)
            : base(time)
        {
            Throw.IfNull(order, nameof(order));
            Throw.IfNullOrWhiteSpace(orderRejectedReason, nameof(orderRejectedReason));

            Order = order;
            OrderExecutionType  = orderExecutionType;
            OrderRejectedReason = orderRejectedReason;
            NewClientOrderId    = newClientOrderId;
        }
Ejemplo n.º 6
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, string rejectedReason, string newClientOrderId)
     : base(time, token, order, executionType, rejectedReason, newClientOrderId)
 {
 }
Ejemplo n.º 7
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="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(long timestamp, CancellationToken token, Order order, OrderExecutionType executionType, OrderRejectedReason rejectedReason, string newClientOrderId)
     : base(timestamp, token, order, executionType, rejectedReason, newClientOrderId)
 {
 }