Exemple #1
0
            public void UpdateData(Security sec, decimal price)
            {
                var ps = sec.PriceStep ?? 1;

                var msg = new Level1ChangeMessage
                {
                    SecurityId = sec.ToSecurityId(),
                    ServerTime = DateTimeOffset.Now,
                };

                if (RandomGen.GetBool())
                {
                    msg.Changes.TryAdd(Level1Fields.BestBidPrice, price - RandomGen.GetInt(1, 10) * ps);
                }

                if (RandomGen.GetBool())
                {
                    msg.Changes.TryAdd(Level1Fields.BestAskPrice, price + RandomGen.GetInt(1, 10) * ps);
                }

                foreach (var l1Subscriptions in _l1Subscriptions)
                {
                    _level1Received?.Invoke(l1Subscriptions, msg);
                }
            }
Exemple #2
0
            public void UpdateData(Security sec, decimal price)
            {
                var ps = sec.PriceStep ?? 1;

                var list = new List <KeyValuePair <Level1Fields, object> >();

                if (RandomGen.GetBool())
                {
                    list.Add(new KeyValuePair <Level1Fields, object>(Level1Fields.BestBidPrice, price - RandomGen.GetInt(1, 10) * ps));
                }

                if (RandomGen.GetBool())
                {
                    list.Add(new KeyValuePair <Level1Fields, object>(Level1Fields.BestAskPrice, price + RandomGen.GetInt(1, 10) * ps));
                }

                var now = DateTimeOffset.Now;

                ValuesChanged?.Invoke(sec, list, now, now);
            }