public Level2(Quote quote, SymbolInfo info) { this.CreatingTime = quote.CreatingTime; this.Symbol = quote.Symbol; this.Bids = Level2EntriesFromQuoteEntries(quote.Bids, info.RoundLot); this.Asks = Level2EntriesFromQuoteEntries(quote.Asks, info.RoundLot); }
static QuoteLevel2Data[] BuildQuoteMultiLevelData(Quote[] quotesData, int depth) { var itemsToAdd = new List<QuoteLevel2Data>(capacity: quotesData.Length*depth); var prevTime = new DateTime(1970, 1, 1); var indexOrder = 0; foreach (var quote in quotesData) { if (prevTime == quote.CreatingTime) { indexOrder++; } else { indexOrder = 0; } var timeSpan = quote.CreatingTime.Subtract(prevTime).TotalMilliseconds; var maxLength = Math.Max(quote.Asks.Length, quote.Bids.Length); for (var index = 0; index < depth; index++) { var quoteEntryAsk = index < maxLength && index<quote.Asks.Length ? quote.Asks[index] : NullQuote; var quoteEntryBid = index < maxLength && index < quote.Bids.Length ? quote.Bids[index] : NullQuote; if (quoteEntryAsk.Price.Equals(NullQuote.Price) && quoteEntryBid.Price.Equals(NullQuote.Price)) continue; var newQuoteL2Data = new QuoteLevel2Data() { AskVolume = quoteEntryAsk.Volume, AsksPrice = quoteEntryAsk.Price, BidVolume = quoteEntryBid.Volume, BidPrice = quoteEntryBid.Price, CreateTime = quote.CreatingTime, IndexOrder = timeSpan + indexOrder / 100.0, Level = index+1 }; itemsToAdd.Add(newQuoteL2Data); } } QuoteLevel2Data[] quoteLevel2Data = itemsToAdd.ToArray(); return quoteLevel2Data; }
public void EncodeFast(int precision, double volumeStep, Quote[] quotes) { this.proxy.EncodeFast((uint)precision, volumeStep, quotes); }
public void EncodeFast(Quote[] quotes) { this.proxy.EncodeFast(quotes); }
public void EncodeSlow(Quote[] quotes) { this.proxy.EncodeSlow(quotes); }
internal static double[] QuoteArraySpread(Quote[] quotes) { return quotes.SelectToArray(b => b.Spread); }
internal static DateTime[] QuoteArrayCreateTime(Quote[] quotes) { var timesAsEpoch = quotes.SelectToArray(b => b.CreatingTime); return timesAsEpoch; }
internal static double[] QuoteArrayAsk(Quote[] quotes) { return quotes.SelectToArray(b => b.HasAsk ? b.Ask : -1); }
static Quote Parse(string text) { var stream = new TextStream(); stream.Initialize(text); var lrpQuote = stream.ReadQuote("quote"); var bids = new QuoteEntry[lrpQuote.Bids.Length]; var asks = new QuoteEntry[lrpQuote.Asks.Length]; for (int index = 0; index < lrpQuote.Bids.Length; ++index) { bids[index] = new QuoteEntry(lrpQuote.Bids[index].Price, lrpQuote.Bids[index].Volume); } for (int index = 0; index < lrpQuote.Asks.Length; ++index) { asks[index] = new QuoteEntry(lrpQuote.Asks[index].Price, lrpQuote.Asks[index].Volume); } var result = new Quote(lrpQuote.Symbol, lrpQuote.CreatingTime, bids, asks); return result; }
/// <summary> /// Compares to quotes for equality. /// </summary> /// <param name="first">the first quote to compare.</param> /// <param name="second">the second quote to compare.</param> /// <returns>true, if two quotes are the same or null, else false</returns> public static bool Equals(Quote first, Quote second) { if (object.ReferenceEquals(first, second)) return true; if (object.ReferenceEquals(first, null)) return false; if (object.ReferenceEquals(null, second)) return false; if (first.Symbol != second.Symbol) return false; if (first.CreatingTime != second.CreatingTime) return false; if (!Equals(first.Bids, second.Bids)) return false; if (!Equals(first.Asks, second.Asks)) return false; return true; }
public void EncodeFast(Quote[] quotes) { throw new NotSupportedException(); }
public void EncodeFast(uint precision, double volumeStep, Quote[] quotes) { throw new NotSupportedException(); }
void DoRefreshBids(Quote quote, SymbolInfo info) { var count = quote.Bids.Length; for (var index = 0; index < count; ++index) { var entry = quote.Bids[index]; var price = entry.Price; var volume = (entry.Volume / info.RoundLot); this.m_grid.Rows.Add(volume.ToString(), price.ToString(), string.Empty); } }
void DoRefreshAsks(Quote quote, SymbolInfo info) { var count = quote.Asks.Length; for (var index = count - 1; index > -1; -- index) { var entry = quote.Asks[index]; var price = entry.Price; var volume = (entry.Volume / info.RoundLot); this.m_grid.Rows.Add(string.Empty, price.ToString(), volume.ToString()); } }
void DoRefresh(Quote quote, SymbolInfo info) { this.m_grid.Rows.Clear(); this.DoRefreshAsks(quote, info); this.DoRefreshBids(quote, info); }
internal static double[] QuoteArrayBid(Quote[] quotes) { return quotes.SelectToArray(b => b.HasBid ? b.Bid : -1); }
public bool TryGetQuote(string symbol, FixSessionId sessionId, out Quote quote) { return this.parser.TryGetQuote(this.handle, symbol, sessionId, out quote); }
public static void Main(string[] args) { string line = null; using (var stream = new StreamReader(@"E:\Output\codec0.txt")) { line = stream.ReadLine(); } var quote = Parse(line); using (var codec = new LrpCodec()) { var quotes = new Quote[] { quote }; codec.EncodeSlow(quotes); } }