/// <summary>
        /// Filter out a tick from this vehicle, with this new data:
        /// </summary>
        /// <param name="data">New data packet:</param>
        /// <param name="vehicle">Vehicle of this filter.</param>
        public bool Filter(Security asset, BaseData data)
        {
            // TRUE -->  Accept Tick
            // FALSE --> Reject Tick
            var tick = data as Tick;

            // This is a tick bar
            if (tick != null)
            {
                if (tick.Exchange == "P") //MarketCodesFilter.AllowedExchanges.Contains()
                {
                    return true;
                }
            }

            //Only allow those exchanges through.
            return false;
        }
Exemplo n.º 2
0
        /******************************************************** 
        * CLASS METHODS
        *********************************************************/
        /// <summary>
        /// Equity filter the data: true - accept, false - fail.
        /// </summary>
        /// <param name="data">Data class</param>
        /// <param name="vehicle">Security asset</param>
        public override bool Filter(Security vehicle, BaseData data)
        {

            // Filter disabled. Suggested filter below:
            return true;

            //Assuming this isnt the first packet:
            if (data == null) return true;

            //Use running/online techniques to calculate the standard deviation:
            double stddev = OnlineStandardDeviation(Convert.ToDouble(data.Value));

            if (_queue.Count < 2)
            {
                return true;
            }

            double deltaFromMean = (Convert.ToDouble(data.Value) - _mean);
            double stddevFromMean = deltaFromMean / stddev;

            //How many standard deviations from normal are we? less than 3.5 is OK. > 3.5 is probably an error.
            if (Math.Abs(stddevFromMean) > _acceptableDeviations)
            {
                var queueCopy = _queue.ToList();
                var testDev = MathNet.Numerics.Statistics.StreamingStatistics.StandardDeviation(queueCopy);
                Console.WriteLine("STANDARD DEVIATION: Online: " + stddev + "  Reference: " + testDev);

                //FAIL PACKET:
                return false;
            }
            else 
            {
                //ACCEPT PACKET:
                return true;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Reset as many of the Cache's as possible.
 /// </summary>
 public virtual void Reset() {
     //Data Cache
     _lastData = null; //Tick or TradeBar
     //Order Cache:
     OrderCache = new List<Order>();
 }
Exemplo n.º 4
0
        /******************************************************** 
        * CLASS METHODS
        *********************************************************/

        /// <summary>
        /// Add a list of new MarketData samples to the cache
        /// </summary>
        public virtual void AddData(BaseData data)
        {
            //Record as Last Added Packet:
            if (data != null) _lastData = data;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Update the Market Online Calculations:
        /// </summary>
        /// <param name="data">New Data packet:</param>
        /// <param name="frontier">time frontier / where we are in time.</param>
        public void Update(DateTime frontier, BaseData data)
        {
            //Update the Exchange/Timer:
            Exchange.SetDateTimeFrontier(frontier);

            //Add new point to cache:
            if (data != null)
            {
                Cache.AddData(data);
                Holdings.UpdatePrice(data.Value);
            }
        }
 /// <summary>
 /// Reset as many of the Cache's as possible.
 /// </summary>
 public virtual void Reset()
 {
     //Data Cache
     _lastData = null; //Tick or TradeBar
 }
Exemplo n.º 7
0
 /******************************************************** 
 * CLASS METHODS
 *********************************************************/
 /// <summary>
 /// Filter the data: true - accept, false - fail.
 /// </summary>
 /// <param name="data">Data class</param>
 /// <param name="vehicle">Security asset</param>
 public virtual bool Filter(Security vehicle, BaseData data)
 {
     return true;
 }
Exemplo n.º 8
0
 /******************************************************** 
 * CLASS METHODS
 *********************************************************/
 /// <summary>
 /// Equity filter the data: true - accept, false - fail.
 /// </summary>
 /// <param name="data">Data class</param>
 /// <param name="vehicle">Security asset</param>
 public override bool Filter(Security vehicle, BaseData data)
 {
     //FX data is from FXCM and fairly clean already.
     return true;
 }