Esempio n. 1
0
        /// <summary>
        /// Gets a stock point object for the current line.
        /// </summary>
        /// <returns>A stock point object for the current line.</returns>
        public DatePoint GetStockPoint()
        {
            if (this.datePoint == null)
            {
                this.datePoint = new DatePoint(
                    this.indicators[this.IndicatorLocations["timestamp"]]);
            }

            return(this.datePoint);
        }
Esempio n. 2
0
        /// <summary>
        /// Calculates all the buys and sells against the dataset.
        /// </summary>
        /// <param name="indicatorLibraryAdapter">Moves through each row of the indicatorLibraryAdapter to find the buy and sell points.</param>
        public void RunBacktest(TestData indicatorLibraryAdapter, Dictionary <DateTime, Dictionary <string, double> > ILA)
        {
            TradeCondition newbuyCondition = tradeSystem.BuyCondition;

            indicatorLibraryAdapter.Restart();
            DatePoint point = indicatorLibraryAdapter.GetStockPoint();

            do
            {
                if (newbuyCondition.Eval(ILA, point))
                {
                    occurance.Add(indicatorLibraryAdapter.GetStockPoint().PointDateTime);
                }
                point = indicatorLibraryAdapter.GetStockPoint();
            } while (indicatorLibraryAdapter.MoveNext());
        }
Esempio n. 3
0
        /// <summary>
        /// Moves to the next line of the input.
        /// </summary>
        /// <returns>false if it's at the end of the file.</returns>
        public bool MoveNext()
        {
            if (this.streamReader == null)
            {
                return(false);
            }

            if (this.streamReader.EndOfStream)
            {
                this.streamReader.Close();
                this.streamReader = null;
                return(false);
            }

            this.datePoint  = null;
            this.indicators = this.streamReader.ReadLine().Split(',');
            return(true);
        }
Esempio n. 4
0
        public DateTime?getDateTime(string indicatorName)
        {
            if (indicatorName.ElementAt(0) == '#')
            {
                return(DateTime.Parse(indicatorName.Remove(0, 1)));
            }
            else
            {
                int       i         = this.IndicatorLocations[indicatorName];
                string    indicator = this.indicators[i];
                DatePoint newpoint  = new DatePoint();
                if (indicator.Trim() == string.Empty)
                {
                    return(null);
                }

                return(newpoint.ParseDateTime(indicator));
            }
        }