Exemple #1
0
        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});
        }
Exemple #2
0
 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();
     }
 }
Exemple #3
0
        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;
        }
Exemple #4
0
        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);
            }
        }