Exemple #1
0
 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);
 }
Exemple #2
0
		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;
		}
Exemple #3
0
 public void EncodeFast(int precision, double volumeStep, Quote[] quotes)
 {
     this.proxy.EncodeFast((uint)precision, volumeStep, quotes);
 }
Exemple #4
0
 public void EncodeFast(Quote[] quotes)
 {
     this.proxy.EncodeFast(quotes);
 }
Exemple #5
0
 public void EncodeSlow(Quote[] quotes)
 {
     this.proxy.EncodeSlow(quotes);
 }
Exemple #6
0
 internal static double[] QuoteArraySpread(Quote[] quotes)
 {
     return quotes.SelectToArray(b => b.Spread);
 }
Exemple #7
0
 internal static DateTime[] QuoteArrayCreateTime(Quote[] quotes)
 {
     var timesAsEpoch = quotes.SelectToArray(b => b.CreatingTime);
     return timesAsEpoch;
 }
Exemple #8
0
 internal static double[] QuoteArrayAsk(Quote[] quotes)
 {
     return quotes.SelectToArray(b => b.HasAsk ? b.Ask : -1);
 }
Exemple #9
0
        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;

        }
Exemple #10
0
        /// <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;
        }
Exemple #11
0
 public void EncodeFast(Quote[] quotes)
 {
     throw new NotSupportedException();
 }
Exemple #12
0
 public void EncodeFast(uint precision, double volumeStep, Quote[] quotes)
 {
     throw new NotSupportedException();
 }
Exemple #13
0
 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);
     }
 }
Exemple #14
0
 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());
     }
 }
Exemple #15
0
 void DoRefresh(Quote quote, SymbolInfo info)
 {
     this.m_grid.Rows.Clear();
     this.DoRefreshAsks(quote, info);
     this.DoRefreshBids(quote, info);
 }
Exemple #16
0
 internal static double[] QuoteArrayBid(Quote[] quotes)
 {
     return quotes.SelectToArray(b => b.HasBid ? b.Bid : -1);
 }
Exemple #17
0
 public bool TryGetQuote(string symbol, FixSessionId sessionId, out Quote quote)
 {
     return this.parser.TryGetQuote(this.handle, symbol, sessionId, out quote);
 }
Exemple #18
0
        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);
            }
        }