public static void Serialize(CancelledOrder cancelledOrder, Span <byte> bytes)
        {
            if (cancelledOrder == null)
            {
                throw new ArgumentNullException(nameof(cancelledOrder));
            }

            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

            Serialize(cancelledOrder.OrderId, cancelledOrder.RemainingQuantity, cancelledOrder.Cost, cancelledOrder.Fee, cancelledOrder.CancelReason, cancelledOrder.Timestamp, bytes);
        }
예제 #2
0
        private async void CancelOrder(object sender, RoutedEventArgs e)
        {
            try {
                CancelledOrder order = await Api.CancelOrder(_realPair, null, GetOrderId());

                responseBox.Text = JsonConvert.SerializeObject(order, Formatting.Indented);
                UpdateUi(new List <CancelledOrder>()
                {
                    order
                });
            } catch (BinanceFailedRequest ex) {
                responseBox.Text = ex.ToString();
            }
        }
예제 #3
0
        /// <summary>
        /// Cancels the specified order.
        /// </summary>
        /// <param name="orderId">The order's ID.</param>
        /// <param name="venue">The venue for the order's stock.</param>
        /// <param name="stock">The symbol for the order's stock.</param>
        /// <returns>Returns information about the cancelled order.</returns>
        public CancelledOrder CancelOrder(int orderId, string venue, string stock)
        {
            var cancelledOrder = deleteResponse <_cancelledOrder>(
                new string[] { venue, stock, orderId.ToString() });

            if (cancelledOrder != null)
            {
                var clientCancelledOrder = new CancelledOrder(cancelledOrder);

                return(clientCancelledOrder);
            }

            else
            {
                throw new ArgumentException("Could not cancel order.");
            }
        }
예제 #4
0
        public static CancelledOrder Deserialize(ReadOnlySpan <byte> bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

            if (bytes.Length != sizeOfMessage)
            {
                throw new Exception("Canceled Order Message must be of Size : " + sizeOfMessage);
            }

            var messageType = (MessageType)(bytes[messageTypeOffset]);

            if (messageType != MessageType.Cancel)
            {
                throw new Exception(Constant.INVALID_MESSAGE);
            }

            var version = BitConverter.ToInt16(bytes.Slice(versionOffset));

            if (version != CancelledOrderSerializer.version)
            {
                throw new Exception(Constant.INVALID_VERSION);
            }

            var cancelledOrder = new CancelledOrder();

            cancelledOrder.OrderId           = BitConverter.ToInt32(bytes.Slice(orderIdOffset));
            cancelledOrder.RemainingQuantity = ReadQuantity(bytes.Slice(remainingQuantityOffset));
            cancelledOrder.CancelReason      = (CancelReason)bytes[cancelReasonOffset];
            cancelledOrder.Timestamp         = BitConverter.ToInt32(bytes.Slice(timestampOffset));
            cancelledOrder.Cost            = ReadQuantity(bytes.Slice(costOffset));
            cancelledOrder.Fee             = ReadQuantity(bytes.Slice(feeOffset));
            cancelledOrder.MessageSequence = BitConverter.ToInt64(bytes.Slice(messageSequenceOffset));

            return(cancelledOrder);
        }
예제 #5
0
        public SathiOrderDetails GetSathiSalesReport(string apikey, int UserId, int DateMode, DateTime?SDATE, DateTime?EDATE)
        {
            SathiOrderDetails _sathiOrderDetails = new SathiOrderDetails();
            SathiOrderDetail  _objData           = new SathiOrderDetail();

            List <FarmerOrderDetails> _objFarmerDataList          = new List <FarmerOrderDetails>();
            List <FarmerOrderDetails> _objFarmerCancellDataList   = new List <FarmerOrderDetails>();
            List <FarmerOrderDetails> _objFarmerDeliveredDataList = new List <FarmerOrderDetails>();
            BZOfferBanner             ObjOfferBanner = new BZOfferBanner();
            BookedOrder    _bookedOrder    = new BookedOrder();
            DeliveredOrder _deliveredOrder = new DeliveredOrder();
            CancelledOrder _cancelledOrder = new CancelledOrder();

            DataSet ds = new SathiOrderDetailsDal().GetSathiSalesReport(apikey, UserId, DateMode, SDATE, EDATE);

            if (ds != null && ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    _objData.SathiName              = ds.Tables[0].Rows[i]["SathiName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["SathiName"]);
                    _objData.ValueIncentive         = ds.Tables[0].Rows[i]["ValueIncentive"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i]["ValueIncentive"]);
                    _objData.OrderIncentive         = ds.Tables[0].Rows[i]["OrderIncentive"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i]["OrderIncentive"]);
                    _objData.TotalIncentive         = ds.Tables[0].Rows[i]["TotalIncentive"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i]["TotalIncentive"]);
                    _bookedOrder.BookedQuantity     = ds.Tables[0].Rows[i]["BookedQuantity"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["BookedQuantity"]);
                    _bookedOrder.BookedValue        = ds.Tables[0].Rows[i]["BookedValue"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["BookedValue"]);
                    _bookedOrder.FarmerOrderDetails = new List <FarmerOrderDetails>();

                    _deliveredOrder.DelieveredQuantity = ds.Tables[0].Rows[i]["DelieveredQuantity"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["DelieveredQuantity"]);
                    _deliveredOrder.DeliveredValue     = ds.Tables[0].Rows[i]["DelieveredValue"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["DelieveredValue"]);
                    _deliveredOrder.FarmerOrderDetails = new List <FarmerOrderDetails>();

                    _cancelledOrder.CancelledQuantity = ds.Tables[0].Rows[i]["CancelledQuantity"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["CancelledQuantity"]);
                    _cancelledOrder.CancelledValue    = ds.Tables[0].Rows[i]["CancelledValue"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[i]["CancelledValue"]);

                    _cancelledOrder.FarmerOrderDetails = new List <FarmerOrderDetails>();
                }
                for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
                {
                    FarmerOrderDetails _objFarmerData = new FarmerOrderDetails();
                    _objFarmerData.FarmerId         = ds.Tables[1].Rows[i]["FarmerId"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[i]["FarmerId"]);
                    _objFarmerData.FarmerName       = ds.Tables[1].Rows[i]["FarmerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[1].Rows[i]["FarmerName"]);
                    _objFarmerData.FatherName       = ds.Tables[1].Rows[i]["FatherName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[1].Rows[i]["FatherName"]);
                    _objFarmerData.Village          = ds.Tables[1].Rows[i]["Village"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[1].Rows[i]["Village"]);
                    _objFarmerData.Block            = ds.Tables[1].Rows[i]["Block"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[1].Rows[i]["Block"]);
                    _objFarmerData.State            = ds.Tables[1].Rows[i]["State"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[1].Rows[i]["State"]);
                    _objFarmerData.orderId          = ds.Tables[1].Rows[i]["orderId"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[i]["orderId"]);
                    _objFarmerData.ProductName      = ds.Tables[1].Rows[i]["ProductName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[1].Rows[i]["ProductName"]);
                    _objFarmerData.Quantity         = ds.Tables[1].Rows[i]["Quantity"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[i]["Quantity"]);
                    _objFarmerData.DelieveredAmount = ds.Tables[1].Rows[i]["DelieveredAmount"] == DBNull.Value ? 0 : Convert.ToDecimal(ds.Tables[1].Rows[i]["DelieveredAmount"]);
                    _objFarmerData.DeliveryDate     = ds.Tables[1].Rows[i]["DeliveryDate"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[1].Rows[i]["DeliveryDate"]).Substring(0, 10);
                    _objFarmerData.DeliveryDate     = (_objFarmerData.DeliveryDate.Trim().Split('/')[1] + "/" + _objFarmerData.DeliveryDate.Trim().Split('/')[0] + "/" + _objFarmerData.DeliveryDate.Trim().Split('/')[2]);
                    _objFarmerData.PaymentStatus    = Convert.ToInt32(ds.Tables[1].Rows[i]["OrderStatus"]) == 0 ? false : Convert.ToInt32(ds.Tables[1].Rows[i]["OrderStatus"]) == 2?false: true;
                    _objFarmerData.District         = ds.Tables[1].Rows[i]["District"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[1].Rows[i]["District"]);
                    _objFarmerDataList.Add(_objFarmerData);
                    if (ds.Tables[1].Rows[i]["OrderStatus"].ToString() == "2")
                    {
                        _objFarmerCancellDataList.Add(_objFarmerData);
                    }
                    if (ds.Tables[1].Rows[i]["OrderStatus"].ToString() == "5")
                    {
                        _objFarmerDeliveredDataList.Add(_objFarmerData);
                    }
                }
                _sathiOrderDetails.SathiOrderDetail                = _objData;
                _sathiOrderDetails.SathiOrderDetail.BookedOrder    = _bookedOrder;
                _sathiOrderDetails.SathiOrderDetail.DeliveredOrder = _deliveredOrder;
                _sathiOrderDetails.SathiOrderDetail.CancelledOrder = _cancelledOrder;
                _sathiOrderDetails.SathiOrderDetail.BookedOrder.FarmerOrderDetails = _objFarmerDataList;

                _sathiOrderDetails.SathiOrderDetail.DeliveredOrder.FarmerOrderDetails = _objFarmerDeliveredDataList;
                _sathiOrderDetails.SathiOrderDetail.CancelledOrder.FarmerOrderDetails = _objFarmerCancellDataList;
            }
            return(_sathiOrderDetails);
        }
예제 #6
0
        public SerializeBenchmark()
        {
            book = new Book();
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3434, Price = 234
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3434, Price = 235
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3435, Price = 236
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3436, Price = 237
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = true, OpenQuantity = 1000, OrderId = 3437, Price = 238
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3438, Price = 239
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3439, Price = 240
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3440, Price = 241
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3441, Price = 242
            });
            book.AddOrderOpenBook(new Order {
                CancelOn = 1000, IsBuy = false, OpenQuantity = 1000, OrderId = 3442, Price = 243
            });
            bid = book.BidSide.Select(x => new KeyValuePair <Price, Quantity>(x.Key, x.Value.Quantity)).ToList();
            ask = book.AskSide.Select(x => new KeyValuePair <Price, Quantity>(x.Key, x.Value.Quantity)).ToList();

            var order = new Order()
            {
                CancelOn = 12345678, IsBuy = true, OrderId = 56789, Price = 404, OpenQuantity = 1000, OrderCondition = OrderCondition.ImmediateOrCancel, StopPrice = 9534, TotalQuantity = 7878234
            };

            orderJsonString = JsonConvert.SerializeObject(order);

            orderBinarySerialized = new byte[OrderSerializer.MessageSize];
            OrderSerializer.Serialize(order, orderBinarySerialized);

            orderMsgPck = MessagePackSerializer.Serialize(new Order2 {
                IsBuy = true, IsTip = false, OpenQuantity = 100, OrderId = 1001, Price = 400, Quantity = 100, Sequnce = 0, StopPrice = 0
            });

            fillJsonString = JsonConvert.SerializeObject(new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            });
            fillBinary = new byte[FillSerializer.MessageSize];
            FillSerializer.Serialize(new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            }, fillBinary);

            cancelJsonString = JsonConvert.SerializeObject(new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            });
            cancelBinary = new byte[CancelledOrderSerializer.MessageSize];
            CancelledOrderSerializer.Serialize(new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            }, cancelBinary);

            cancelRequestJsonString = JsonConvert.SerializeObject(new CancelRequest {
                OrderId = 1023
            });
            cancelRequestBinary = new byte[CancelRequestSerializer.MessageSize];
            CancelRequestSerializer.Serialize(new CancelRequest {
                OrderId = 1023
            }, cancelRequestBinary);

            orderTriggerBinary = new byte[OrderTriggerSerializer.MessageSize];
            OrderTriggerSerializer.Serialize(new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            }, orderTriggerBinary);
            orderTriggerJsonString = JsonConvert.SerializeObject(new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            });

            bookRequestBinary = new byte[BookRequestSerializer.MessageSize];
            BookRequestSerializer.Serialize(new BookRequest {
            }, bookRequestBinary);
            bookRequestJsonString = JsonConvert.SerializeObject(new BookRequest {
            });
            bookRequest2Bytes     = MessagePackSerializer.Serialize(new BookRequest2 {
            });

            bookDepth      = new BookDepth(1234, 100, bid, ask);
            bookJsonString = JsonConvert.SerializeObject(bookDepth);
            bookBinary     = new byte[OrderSerializer.MessageSize];
            BookSerializer.Serialize(bookDepth, bookBinary);

            fill = new Fill {
                MakerOrderId = 10001, MatchQuantity = 2000, MatchRate = 2400, TakerOrderId = 9999, Timestamp = 10303
            };
            order2 = new Order2 {
                IsBuy = true, IsTip = false, OpenQuantity = 100, OrderId = 1001, Price = 400, Quantity = 100, Sequnce = 0, StopPrice = 0
            };
            this.order = new Order {
                IsBuy = true, OpenQuantity = 100, OrderId = 1001, Price = 400, Sequnce = 0, TotalQuantity = 100, OrderCondition = OrderCondition.None, StopPrice = 0
            };
            cancelledOrder = new CancelledOrder {
                OrderId = 1201, CancelReason = CancelReason.UserRequested, RemainingQuantity = 2000, Timestamp = 234
            };
            cancelRequest = new CancelRequest {
                OrderId = 1023
            };
            orderTrigger = new OrderTrigger {
                OrderId = 3453, Timestamp = 35345
            };
            bookRequest = new BookRequest {
                LevelCount = 50
            };
            bookRequest2 = new BookRequest2 {
                LevelCount = 50
            };
        }