Ejemplo n.º 1
0
        public PartialDepthMessage GetParsedPartialDepthMessage(dynamic messageData)
        {
            var result = new PartialDepthMessage
            {
                LastUpdateId = messageData.data.lastUpdateId,
                Stream       = messageData.stream,
            };

            var bids = new List <OrderBookOffer>();
            var asks = new List <OrderBookOffer>();

            foreach (JToken item in ((JArray)messageData.data.bids).ToArray())
            {
                bids.Add(new OrderBookOffer()
                {
                    Price = decimal.Parse(item[0].ToString()), Quantity = decimal.Parse(item[1].ToString())
                });
            }

            foreach (JToken item in ((JArray)messageData.data.asks).ToArray())
            {
                asks.Add(new OrderBookOffer()
                {
                    Price = decimal.Parse(item[0].ToString()), Quantity = decimal.Parse(item[1].ToString())
                });
            }

            result.Bids = bids;
            result.Asks = asks;

            return(result);
        }
Ejemplo n.º 2
0
        private void DepthCallBack(string symble, PartialDepthMessage message)
        {
            if (this.Zqdm.Equals(symble, StringComparison.CurrentCultureIgnoreCase))
            {
                int priceRound, qtyRound, notionRound;
                MarketAdapter.BinanceAdapter.Instance.GetRoundNum(symble, out priceRound, out qtyRound, out notionRound);
                this.BeginInvoke(new Action(() => {
                    int i = 0;
                    foreach (var bidItem in message.Bids)
                    {
                        if (i < listView买盘.Items.Count)
                        {
                            ListViewItem bidViewItem     = listView买盘.Items[i++];
                            bidViewItem.SubItems[0].Text = Math.Round(bidItem.Price, priceRound).ToString();
                            bidViewItem.SubItems[1].Text = Math.Round(bidItem.Quantity, qtyRound).ToString();
                            bidViewItem.SubItems[2].Text = Math.Round(bidItem.Quantity * bidItem.Price, notionRound).ToString();
                        }
                    }

                    i = 0;
                    foreach (var item in message.Asks)
                    {
                        if (i < listView卖盘.Items.Count)
                        {
                            ListViewItem askViewItem     = listView卖盘.Items[i++];
                            askViewItem.SubItems[0].Text = Math.Round(item.Price, priceRound) + "";
                            askViewItem.SubItems[1].Text = Math.Round(item.Quantity, qtyRound) + "";
                            askViewItem.SubItems[2].Text = Math.Round(item.Quantity * item.Price, notionRound) + "";
                        }
                    }
                    var qtyMin     = MarketAdapter.BinanceAdapter.Instance.GetMinQty(Zqdm);
                    label可买股数.Text = Math.Round(decimal.Parse(label可用资金.Text) / message.Asks.First().Price, MarketAdapter.BinanceUtils.GetDigit(qtyMin)) + "";
                }));
            }
        }
Ejemplo n.º 3
0
 private void PartialDepthHandler(PartialDepthMessage message)
 {
     try
     {
         DepthQueue.Enqueue(message);
     }
     catch (Exception ex)
     {
         Program.logger.LogRunning("PartialDepthHandler Exception: {0}", ex.Message);
     }
 }
Ejemplo n.º 4
0
        public static void PartialDepthHandler(PartialDepthMessage messageData)
        {
            var depthData = messageData;

            Console.WriteLine(depthData.LastUpdateId.ToString());
            Console.WriteLine(depthData.Stream);
            foreach (Binance.API.Csharp.Client.Models.Market.OrderBookOffer t in depthData.Asks)
            {
                Console.Write(t.Price.ToString(), t.Quantity.ToString(), " ");
            }
            Console.WriteLine();
        }
Ejemplo n.º 5
0
 public static void PartialDepthHandler(PartialDepthMessage messageData)
 {
     //var depthData = messageData;
     //Console.WriteLine(depthData.LastUpdateId.ToString());
     //Console.WriteLine(depthData.Stream);
 }