public static void BroadcastPrice(AssetQuote price) { var asset = GlobalSettings.FinanceInstruments[price.Id]; if (asset == null) return; var hub = GlobalHost.ConnectionManager.GetLkHub(); var bid = price.Bid; var ask = price.Ask; hub.Clients.All.Price(new {id = price.Id, bid, ask}); }
public static void SetPrice(AssetQuote price) { ReaderWriterLockSlim.EnterWriteLock(); try { if (!Profile.ContainsKey(price.Id)) Profile.Add(price.Id, price); else Profile[price.Id] = price; } finally { ReaderWriterLockSlim.ExitWriteLock(); } }
private static AssetQuote CreateFeedData(string src) { var lines = src.Split(' '); if (lines.Length < 4) return null; var result = new AssetQuote { Id = lines[0], DateTime = ParseDateTime(lines[1]), Bid = double.Parse(lines[2], CultureInfo.InvariantCulture), Ask = double.Parse(lines[3], CultureInfo.InvariantCulture) }; return result; }
private void QuoteCallBack(AssetQuote feed) { lock (_feed) { if (!_feed.ContainsKey(feed.Id)) _feed.Add(feed.Id, feed); _feed[feed.Id] = feed; } lock (_profile) { if (_profile.ContainsKey(feed.Id)) _profile[feed.Id] = feed; else _profile.Add(feed.Id, feed); } }