private string BookQuoteToString(BookQuote q)
        {
            string res = "";

            try
            {
                int    askCount = Math.Min(q.AskPrices.Length, q.AskPrices.Length);
                string askItems = "";
                for (int i = 0; i < askCount; i++)
                {
                    if (askItems.Length > 0)
                    {
                        askItems += ",";
                    }
                    askItems += string.Format("{0}x{1}", q.FormatValue(q.AskPrices[i], NumericFormat.Default), q.AskSizes[i]);
                }

                int    bidCount = Math.Min(q.BidPrices.Length, q.BidPrices.Length);
                string bidItems = "";
                for (int i = 0; i < bidCount; i++)
                {
                    if (bidItems.Length > 0)
                    {
                        bidItems += ",";
                    }
                    bidItems += string.Format("{0}x{1}", q.FormatValue(q.BidPrices[i], NumericFormat.Default), q.BidSizes[i]);
                }

                res = string.Format("Symbol={0}\nTimestamp={1}\nAsks={2}\nBids={3}\nSource={4}\n",
                                    q.Symbol, q.Timestamp.ToString("yyyy-MM-dd HH:mm:ss"), askItems, bidItems, Encoding.ASCII.GetString(q.Source));
            }
            catch (Exception ex)
            {
                res = "Error converting data from book quote to string: " + ex.Message;
            }

            return(res);
        }
Пример #2
0
        public static string BookQuoteToString(BookQuote q)
        {
            var res = "";

            try
            {
                var askCount = Math.Min(q.AskPrices.Length, q.AskPrices.Length);
                var askItems = "";
                for (var i = 0; i < askCount; i++)
                {
                    if (askItems.Length > 0)
                    {
                        askItems += ",";
                    }
                    askItems += $"{q.FormatValue(q.AskPrices[i], NumericFormat.Default)}x{q.AskSizes[i]}";
                }

                var bidCount = Math.Min(q.BidPrices.Length, q.BidPrices.Length);
                var bidItems = "";
                for (var i = 0; i < bidCount; i++)
                {
                    if (bidItems.Length > 0)
                    {
                        bidItems += ",";
                    }
                    bidItems += $"{q.FormatValue(q.BidPrices[i], NumericFormat.Default)}x{q.BidSizes[i]}";
                }

                res =
                    $"Symbol={q.Symbol}\nTimestamp={q.Timestamp:yyyy-MM-dd HH:mm:ss}\nAsks={askItems}\nBids={bidItems}\nSource={Encoding.ASCII.GetString(q.Source)}\n";
            }
            catch (Exception ex)
            {
                res = "Error converting data from book quote to string: " + ex.Message;
            }

            return(res);
        }