public void ResetsProperly() { var fisher = new FisherTransform(10); //fisher.Update(DateTime.Today, 1m); //fisher.Update(DateTime.Today.AddSeconds(1), 2m); Assert.IsFalse(fisher.IsReady); fisher.Reset(); TestHelper.AssertIndicatorIsInDefaultState(fisher); //TestHelper.AssertIndicatorIsInDefaultState(fisher.AverageGain); //TestHelper.AssertIndicatorIsInDefaultState(fisher.AverageLoss); }
/// <summary> /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. /// </summary> /// <seealso cref="QCAlgorithm.SetStartDate(System.DateTime)"/> /// <seealso cref="QCAlgorithm.SetEndDate(System.DateTime)"/> /// <seealso cref="QCAlgorithm.SetCash(decimal)"/> public override void Initialize() { // mylog.Debug(",CurrentBar,Time,Price,smooth,low,i1,cycle0,cycle1,cycle2,fish,medianDelta,DC,instaperiod, v2,DCPeriod,realpart,imagpart,dcphase"); mylog.Debug(ondataheader); //mylog.Debug(",Time,CurrentBar,Direction,TradeProfit,,Price,Profit,HoldingCost,FillQty,Fees,TransAmt"); //mylog.Debug(transheader); //Initialize SetStartDate(2015, 05, 12); SetEndDate(2015, 05, 12); SetCash(25000); //Add as many securities as you like. All the data will be passed into the event handler: AddSecurity(SecurityType.Equity, _symbol, Resolution.Minute); _indicators = new AlgoIndicators { //BB = BB(_symbol, 20, 1, MovingAverageType.Simple, Resolution.Daily), RSI = RSI(_symbol, 14, MovingAverageType.Simple, Resolution.Daily), //ATR = ATR(_symbol, 14, MovingAverageType.Simple, Resolution.Daily), //EMA = EMA(_symbol, 14, Resolution.Daily), //SMA = SMA(_symbol, 14, Resolution.Daily), MACD = MACD(_symbol, 12, 26, 9, MovingAverageType.Simple, Resolution.Minute) //AROON = AROON(_symbol, 20, Resolution.Daily), //MOM = MOM(_symbol, 20, Resolution.Daily), //MOMP = MOMP(_symbol, 20, Resolution.Daily), //STD = STD(_symbol, 20, Resolution.Daily), //MIN = MIN(_symbol, 14, Resolution.Daily), // by default if the symbol is a tradebar type then it will be the min of the low property //MAX = MAX(_symbol, 14, Resolution.Daily), // by default if the symbol is a tradebar type then it will be the max of the high property //open = new WindowIndicator<IndicatorDataPoint>(4) //Ft = FT(_symbol, samplesize, Resolution.Minute), //Rvi = RVI(_symbol, samplesize, Resolution.Minute) }; //open = new RollingWindow<IndicatorDataPoint>(samplesize); //close = new RollingWindow<IndicatorDataPoint>(samplesize); //high = new RollingWindow<IndicatorDataPoint>(samplesize); //low = new RollingWindow<IndicatorDataPoint>(samplesize); //i1 = new RollingWindow<IndicatorDataPoint>(samplesize); //instperiod = new RollingWindow<IndicatorDataPoint>(samplesize); //v2 = new RollingWindow<IndicatorDataPoint>(samplesize); //v1 = new RollingWindow<IndicatorDataPoint>(samplesize); //Rvi = new RollingWindow<IndicatorDataPoint>(samplesize); unrealized = new RollingWindow<IndicatorDataPoint>(samplesize); iFishes = new RollingWindow<IndicatorDataPoint>(samplesize); RsiHistory = new RollingWindow<IndicatorDataPoint>(samplesize); //Signal = new RollingWindow<IndicatorDataPoint>(samplesize); //maxRvi = new Maximum("RVI_Max", samplesize); //minRvi = new Minimum("RVi_Min", samplesize); //maxSignal = new Maximum("Sig_Max", samplesize); //minSignal = new Minimum("Sig_Min", samplesize); fish = new FisherTransform(samplesize); ifish = new InverseFisherTransform(samplesize); //Crossing = new RollingWindow<IndicatorDataPoint>(samplesize); //FisherHistory = new RollingWindow<IndicatorDataPoint>(samplesize); Rvi = new RelativeVigorIndex(_symbol, samplesize); for (int x = 0; x < samplesize; x++) { //open.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //close.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //high.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //low.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //i1.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //instperiod.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //v1.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //v2.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //Rvi.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); unrealized.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); iFishes.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //Signal.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //Crossing.Add(new IndicatorDataPoint(DateTime.MinValue, .0001m)); } }
public void ComparesAgainstExternalData() { var fisher = new FisherTransform("fisher", 10); TestHelper.TestIndicator(fisher, "spy_with_fisher.txt", "Fisher Transform 10", (ind, expected) => Assert.AreEqual(expected, (double)((FisherTransform)ind).Current.Value, 1e-3)); }
/// <summary> /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. /// </summary> /// <seealso cref="QCAlgorithm.SetStartDate(System.DateTime)"/> /// <seealso cref="QCAlgorithm.SetEndDate(System.DateTime)"/> /// <seealso cref="QCAlgorithm.SetCash(decimal)"/> public override void Initialize() { //mylog.Debug(transheader); mylog.Debug(ondataheader); //Initialize dates SetStartDate(2013, 10, 07); SetEndDate(2013, 10, 07); SetCash(25000); //Add as many securities as you like. All the data will be passed into the event handler: AddSecurity(SecurityType.Equity, _symbol, Resolution.Minute); maxHigh = new Maximum("MaxHigh", _period); minLow = new Minimum("MinLow", _period); value1 = new RollingWindow<IndicatorDataPoint>(_period); fish = new RollingWindow<IndicatorDataPoint>(_period); //wma = new LinearWeightedMovingAverage(5); // induces 2 bar lag //wwma = new RollingWindow<IndicatorDataPoint>(_period); //fishHigh = new Maximum("FishHigh", 400); //fishLow = new Minimum("FishLow", 400); fx = new FisherTransform(_symbol,_period); //fx = FT(_symbol, _period, Resolution.Minute); // Add a bars to initialize the RollingWindow value1.Add(new IndicatorDataPoint(DateTime.MinValue, .0001m)); value1.Add(new IndicatorDataPoint(DateTime.MinValue, .0001m)); fish.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); fish.Add(new IndicatorDataPoint(DateTime.MinValue, 0m)); //wwma.Add(new IndicatorDataPoint(DateTime.MinValue, .0001m)); //wwma.Add(new IndicatorDataPoint(DateTime.MinValue, .0001m)); }