public void PushQuote(Quote quote) { market[quote.Symbol] = quote.Price; // lock for atomic get and reset lock (syncChanges) // ReaderWriterLock for improve perfomance may be used { changes[quote.Symbol] = quote.Price; } }
public void QuoteSerializingTest() { var expect = "EURUSD=1.23"; var q = new Quote { Symbol = "EURUSD", Price = 1.23m }; var res = q.Serialize(); Assert.AreEqual(expect, res); }
public void OneQuoteTest() { var q = new Quote { Symbol = "EURUSD", Price = 1.0m }; var store = new QuoteStore(); store.PushQuote(q); var market = store.GetCurrentMarket(); Assert.AreEqual(1, market.Count); Assert.AreEqual("EURUSD", market[0].Symbol); Assert.AreEqual(1.0, market[0].Price); }
public void GetChangesTest1() { var q = new Quote { Symbol = "EURUSD", Price = 1.0m }; var store = new QuoteStore(); store.PushQuote(q); q.Price = 2.0m; store.PushQuote(q); var market = store.GetChanges(); Assert.AreEqual(1, market.Count); Assert.AreEqual("EURUSD", market[0].Symbol); Assert.AreEqual(2.0, market[0].Price); }
public void GetChangesTest3() { var q1 = new Quote { Symbol = "EURUSD", Price = 1.0m }; var q2 = new Quote { Symbol = "EURUSD", Price = 2.0m }; var store = new QuoteStore(); store.PushQuote(q1); store.PushQuote(q2); var market = store.GetChanges(); Assert.AreEqual(1, market.Count); Assert.IsTrue(market.Any(quote => quote.Symbol == "EURUSD" && quote.Price == 2.0m)); }
public void SomeQuotesTest() { var q1 = new Quote { Symbol = "EURUSD", Price = 1.0m }; var q2 = new Quote { Symbol = "USDJPY", Price = 2.0m }; var store = new QuoteStore(); store.PushQuote(q1); store.PushQuote(q2); var market = store.GetCurrentMarket(); Assert.AreEqual(2, market.Count); Assert.IsTrue(market.Any(quote => quote.Symbol == "EURUSD" && quote.Price == 1.0m)); Assert.IsTrue(market.Any(quote => quote.Symbol == "USDJPY" && quote.Price == 2.0m)); }
private void QuoteSourceOnNewQuoteAvailable(Quote quote) { quoteStore.PushQuote(quote); }
private void OnNewQuoteAvailable(Quote quote) { var handler = NewQuoteAvailable; if (handler != null) handler(quote); }
public static string Serialize(this Quote quote) { return(string.Format("{0}={1}", quote.Symbol, quote.Price)); }