/// <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); }
/// <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()); }
/// <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); }
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)); } }