예제 #1
0
        /// <summary>
        /// Add a list of new MarketData samples to the cache
        /// </summary>
        public virtual void AddData(MarketData data)
        {
            //Only add to the database when its not in use.
            lock (DataCache) {
                //Record as Last Added Packet:
                _lastData = data;
                //Add it to the depth cache:
                DataCache.Enqueue(data);

                //Dumping old data because lots of tick data results in memory overflows.
                if (DataCache.Count > 1000) {
                    DataCache.Dequeue();
                }
            }
        }
예제 #2
0
파일: Security.cs 프로젝트: vdt/QCAlgorithm
        /// <summary>
        /// Update the Market Online Calculations:
        /// </summary>
        /// <param name="data">New Data packet:</param>
        /// <param name="frontier"></param>
        public void Update(DateTime frontier, MarketData data)
        {
            //Update the Exchange/Timer:
            Exchange.SetDateTimeFrontier(frontier);

            //Update the Holdings Copy of Price Variable:
            Holdings.UpdatePrice(Close);

            //Add new point to cache:
            if (data != null)
            {
                Cache.AddData(data);
            }

            //Update Online Calculations:
        }
예제 #3
0
        /// <summary>
        /// Reset as many of the Cache's as possible.
        /// </summary>
        public virtual void Reset()
        {
            //Data Cache
            DataCache = new Queue<MarketData>();
            _lastData = new MarketData();

            //Order Cache:
            OrderCache = new List<Order>();
        }