コード例 #1
0
        public void ComparesWithExternalDataDelayedKijunSenkouA()
        {
            var ichimoku = new IchimokuKinkoHyo("Ichimoku", 9, 26, 26, 52, 26, 26);

            TestHelper.TestIndicator(
                ichimoku,
                "spy_with_ichimoku.csv",
                "DelayedKijunSenkouA",
                (ind, expected) => Assert.AreEqual(expected, (double)((IchimokuKinkoHyo)ind).DelayedKijunSenkouA.Current.Value)
                );
        }
コード例 #2
0
        public void ComparesAgainstExternalDataOnStochasticsK()
        {
            var stochastics = new Stochastic("sto", 12, 3, 5);

            const double epsilon = 1e-3;

            TestHelper.TestIndicator(stochastics, "spy_with_stoch12k3.txt", "Stochastics 12 %K 3",
                                     (ind, expected) => Assert.AreEqual(expected, (double)((Stochastic)ind).StochK.Current.Value, epsilon)

                                     );
        }
コード例 #3
0
        public void ComparesAgainstExternalData()
        {
            var onBalanceVolumeIndicator = new OnBalanceVolume("OBV");

            TestHelper.TestIndicator(onBalanceVolumeIndicator, "spy_with_obv.txt", "OBV",
                                     (ind, expected) => Assert.AreEqual(
                                         expected.ToString("0.##E-00"),
                                         (onBalanceVolumeIndicator.Current.Value).ToString("0.##E-00")
                                         )
                                     );
        }
コード例 #4
0
        public void ComparesAgainstExternalData()
        {
            var adx = new AverageDirectionalIndex("adx", 14);

            const double epsilon = 1;

            TestHelper.TestIndicator(adx, "spy_with_adx.txt", "ADX 14",
                                     (ind, expected) => Assert.AreEqual(expected, (double)((AverageDirectionalIndex)ind).Current.Value, epsilon)

                                     );
        }
コード例 #5
0
        public void ComparesWithExternalDataTenkanMaximum()
        {
            var ichimoku = new IchimokuKinkoHyo("Ichimoku", 9, 26, 26, 52, 26, 26);

            TestHelper.TestIndicator(
                ichimoku,
                "spy_with_ichimoku.csv",
                "TenkanMaximum",
                (ind, expected) => Assert.AreEqual(expected, (double)((IchimokuKinkoHyo)ind).TenkanMaximum.Current.Value)
                );
        }
コード例 #6
0
 public void PrimaryOutputIsFastStochProperty()
 {
     TestHelper.TestIndicator(
         CreateIndicator(),
         TestFileName,
         "Stochastics 12 %K 3",
         (ind, expected) => Assert.AreEqual(
             (double)((Stochastic)ind).FastStoch.Current.Value,
             ind.Current.Value
             )
         );
 }
コード例 #7
0
 public void ComparesTimeStampBetweenKeltnerChannelAndMiddleBand()
 {
     TestHelper.TestIndicator(
         CreateIndicator(),
         TestFileName,
         "Middle Band",
         (ind, expected) => Assert.AreEqual(
             ((KeltnerChannels)ind).Current.EndTime,
             ((KeltnerChannels)ind).MiddleBand.Current.EndTime
             )
         );
 }
コード例 #8
0
        public void ComparesWithExternalDataKijun()
        {
            var ichimoku = new IchimokuKinkoHyo("Ichimoku", 9, 26, 26, 52, 26, 26);

            ichimoku.Current.Time.ToString();
            TestHelper.TestIndicator(
                ichimoku,
                "spy_with_ichimoku.csv",
                "Kijun",
                (ind, expected) => Assert.AreEqual(expected, (double)((IchimokuKinkoHyo)ind).Kijun.Current.Value)
                );
        }
コード例 #9
0
        public void ComparesWithExternalDataUpperBand()
        {
            var abands = CreateIndicator();

            TestHelper.TestIndicator(
                abands,
                "spy_acceleration_bands_20_4.txt",
                "UpperBand",
                (ind, expected) => Assert.AreEqual(expected, (double)((AccelerationBands)ind).UpperBand.Current.Value,
                                                   delta: 1e-4, message: "Upper band test fail.")
                );
        }
コード例 #10
0
 public void ComparesAgainstExternalDataOnStochasticsK()
 {
     TestHelper.TestIndicator(
         CreateIndicator(),
         TestFileName,
         "Stochastics 12 %K 3",
         (ind, expected) => Assert.AreEqual(
             expected,
             (double)((Stochastic)ind).StochK.Current.Value,
             1e-3
             )
         );
 }
コード例 #11
0
 public void ComparesWithExternalDataLowerBand()
 {
     TestHelper.TestIndicator(
         CreateIndicator(),
         TestFileName,
         "Keltner Channels 20 Bottom",
         (ind, expected) => Assert.AreEqual(
             expected,
             (double)((KeltnerChannels)ind).LowerBand.Current.Value,
             1e-3
             )
         );
 }
コード例 #12
0
        public override void ComparesAgainstExternalData()
        {
            const double epsilon = .0001;
            var          adx     = CreateIndicator();

            TestHelper.TestIndicator(adx, TestFileName, "+DI14",
                                     (ind, expected) => Assert.AreEqual(expected, (double)((AverageDirectionalIndex)ind).PositiveDirectionalIndex.Current.Value, epsilon)
                                     );
            adx.Reset();

            TestHelper.TestIndicator(adx, TestFileName, "-DI14",
                                     (ind, expected) => Assert.AreEqual(expected, (double)((AverageDirectionalIndex)ind).NegativeDirectionalIndex.Current.Value, epsilon)
                                     );
        }
        public void ComparesWithExternalDataMacdSignal()
        {
            var macd = CreateIndicator();

            TestHelper.TestIndicator(
                macd,
                TestFileName,
                "Signal",
                (ind, expected) => Assert.AreEqual(
                    expected,
                    (double)((MovingAverageConvergenceDivergence)ind).Signal.Current.Value,
                    delta: 1e-4
                    )
                );
        }
コード例 #14
0
 /// <summary>
 /// Executes a test of the specified indicator
 /// </summary>
 protected virtual void RunTestIndicator(IndicatorBase <T> indicator)
 {
     if (indicator is IndicatorBase <IndicatorDataPoint> )
     {
         TestHelper.TestIndicator(indicator as IndicatorBase <IndicatorDataPoint>, TestFileName, TestColumnName, Assertion as Action <IndicatorBase <IndicatorDataPoint>, double>);
     }
     else if (indicator is IndicatorBase <TradeBar> )
     {
         TestHelper.TestIndicator(indicator as IndicatorBase <TradeBar>, TestFileName, TestColumnName, Assertion as Action <IndicatorBase <TradeBar>, double>);
     }
     else
     {
         throw new NotSupportedException("RunTestIndicator: Unsupported indicator data type: " + typeof(T));
     }
 }
コード例 #15
0
        public void ComparesWithExternalDataSignal()
        {
            var tsi = CreateIndicator();

            TestHelper.TestIndicator(
                tsi,
                TestFileName,
                "Signal_7",
                (ind, expected) => Assert.AreEqual(
                    expected,
                    (double)((TrueStrengthIndex)ind).Signal.Current.Value,
                    delta: 1e-4
                    )
                );
        }
コード例 #16
0
ファイル: HeikinAshiTests.cs プロジェクト: aihua/quant-lean
        public override void ComparesAgainstExternalDataAfterReset()
        {
            var indicator = new HeikinAshi();

            for (var i = 1; i <= 2; i++)
            {
                TestHelper.TestIndicator(indicator, TestFileName, "HA_Open", (ind, expected) => Assert.AreEqual(expected, (double)((HeikinAshi)ind).Open.Current.Value, 1e-3));
                indicator.Reset();
                TestHelper.TestIndicator(indicator, TestFileName, "HA_High", (ind, expected) => Assert.AreEqual(expected, (double)((HeikinAshi)ind).High.Current.Value, 1e-3));
                indicator.Reset();
                TestHelper.TestIndicator(indicator, TestFileName, "HA_Low", (ind, expected) => Assert.AreEqual(expected, (double)((HeikinAshi)ind).Low.Current.Value, 1e-3));
                indicator.Reset();
                TestHelper.TestIndicator(indicator, TestFileName, "HA_Close", (ind, expected) => Assert.AreEqual(expected, (double)((HeikinAshi)ind).Close.Current.Value, 1e-3));
                indicator.Reset();
            }
        }
コード例 #17
0
        public void ComparesAgainstExternalData()
        {
            var onBalanceVolumeIndicator = new OnBalanceVolume("OBV")
            {
                Current =
                {
                    Time  = new DateTime(2013,                             4, 30),
                    Value = decimal.Parse("1.156486E+08", NumberStyles.Float, CultureInfo.InvariantCulture)
                }
            };

            TestHelper.TestIndicator(onBalanceVolumeIndicator, "spy_with_obv.txt", "OBV",
                                     (ind, expected) => Assert.AreEqual(
                                         expected.ToString("0.##E-00"),
                                         (onBalanceVolumeIndicator.Current.Value).ToString("0.##E-00")
                                         )

                                     );
        }
コード例 #18
0
        public void ComparesWithExternalDataLowerBand()
        {
            var bb = new BollingerBands(20, 2.0m, MovingAverageType.Simple);

            TestHelper.TestIndicator(bb, "spy_bollinger_bands.txt", "Bollinger Bands® 20 2 Bottom", (BollingerBands ind) => (double)ind.LowerBand.Current.Value);
        }
コード例 #19
0
        public void CompareAgainstExternalData()
        {
            var sma = new SimpleMovingAverage(14);

            TestHelper.TestIndicator(sma, "SMA14", 1e-2); // test file only has
        }
コード例 #20
0
        public void ComparesAgainstExternalDataSma()
        {
            var rsiSimple = new RelativeStrengthIndex("rsi", 14, MovingAverageType.Simple);

            TestHelper.TestIndicator(rsiSimple, "RSI 14");
        }
コード例 #21
0
        public void ComparesWithExternalData()
        {
            var psar = new ParabolicStopAndReverse();

            TestHelper.TestIndicator(psar, "spy_parabolic_SAR.txt", "Parabolic SAR 0.02 0.20");
        }
コード例 #22
0
        public void ComparesAgainstExternalData()
        {
            var cci = new CommodityChannelIndex(14);

            TestHelper.TestIndicator(cci, "spy_with_cci.txt", "Commodity Channel Index (CCI) 14", 1e-2);
        }
コード例 #23
0
        public override void ComparesAgainstExternalData()
        {
            var atrSimple = new AverageTrueRange(14, MovingAverageType.Simple);

            TestHelper.TestIndicator(atrSimple, "spy_atr.txt", "Average True Range 14");
        }
コード例 #24
0
ファイル: SwissArmyKnifeTests.cs プロジェクト: xg86/Lean
 private void RunTestIndicator(IndicatorBase <IndicatorDataPoint> indicator, string field, decimal variance)
 {
     TestHelper.TestIndicator(indicator, TestFileName, field, (actual, expected) => { AssertResult(expected, actual.Current.Value, variance); });
 }
コード例 #25
0
 private static void RunTestIndicator(TradeBarIndicator indicator)
 {
     TestHelper.TestIndicator(indicator, "spy_natr.txt", "NATR_5", (ind, expected) => Assert.AreEqual(expected, (double)ind.Current.Value, 1e-3));
 }
コード例 #26
0
        public void ComparesAgainstExternalData()
        {
            var mfi = new MoneyFlowIndex(20);

            TestHelper.TestIndicator(mfi, "spy_mfi.txt", "Money Flow Index 20");
        }
コード例 #27
0
 private static void TestIndicator(ChandeMomentumOscillator cmo)
 {
     TestHelper.TestIndicator(cmo, "spy_cmo.txt", "CMO_5", (ind, expected) => Assert.AreEqual(expected, (double)ind.Current.Value, 1e-3));
 }
コード例 #28
0
 private static void RunTestIndicator(TradeBarIndicator indicator)
 {
     TestHelper.TestIndicator(indicator, "frama.txt", "Filt", (actual, expected) => { AssertResult(expected, actual.Current.Value); });
 }
コード例 #29
0
        public void ComparesAgainstExternalData()
        {
            var ema = new ExponentialMovingAverage(14);

            TestHelper.TestIndicator(ema, "spy_with_indicators.txt", "EMA14", TestHelper.AssertDeltaDecreases(2.5e-2));
        }
 private static void RunTestIndicator(DoubleExponentialMovingAverage dema)
 {
     TestHelper.TestIndicator(dema, "spy_dema.txt", "DEMA_5", (ind, expected) => Assert.AreEqual(expected, (double)ind.Current.Value, 1e-2));
 }