⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_po.c

📁 股票主要技术指标源码
💻 C
📖 第 1 页 / 共 2 页
字号:
      if( (int)tableTest[i].expectedNbElement > (int)history->nbBars )      {         printf( "TA_APO/TA_PPO Failed Bad Parameter for Test #%d (%d,%d)\n",                 i, tableTest[i].expectedNbElement, history->nbBars );         return TA_TESTUTIL_TFRR_BAD_PARAM;      }      retValue = do_test( history, &tableTest[i] );      if( retValue != 0 )      {         printf( "TA_APO/TA_PPO Failed Test #%d (Code=%d)\n", i, retValue );         return retValue;      }   }   /* All test succeed. */   return TA_TEST_PASS; }/**** Local functions definitions.     ****/static TA_RetCode rangeTestFunction( TA_Integer    startIdx,                                     TA_Integer    endIdx,                                     TA_Real      *outputBuffer,                                     TA_Integer   *outputBufferInt,                                     TA_Integer   *outBegIdx,                                     TA_Integer   *outNbElement,                                     TA_Integer   *lookback,                                     void         *opaqueData,                                     unsigned  int outputNb,                                     unsigned int *isOutputInteger )      {   TA_RetCode retCode;   TA_RangeTestParam *testParam;   (void)outputNb;   (void)outputBufferInt;     *isOutputInteger = 0;   testParam = (TA_RangeTestParam *)opaqueData;      if( testParam->test->doPercentage )   {      retCode = TA_PPO( startIdx,                        endIdx,                        testParam->close,                        testParam->test->optInFastPeriod,                        testParam->test->optInSlowPeriod,                        (TA_MAType)testParam->test->optInMethod_2,                        outBegIdx,                        outNbElement,                        outputBuffer );     *lookback = TA_PPO_Lookback( testParam->test->optInFastPeriod,                      testParam->test->optInSlowPeriod,                      (TA_MAType)testParam->test->optInMethod_2 );                         }   else   {      retCode = TA_APO( startIdx,                        endIdx,                        testParam->close,                        testParam->test->optInFastPeriod,                        testParam->test->optInSlowPeriod,                        (TA_MAType)testParam->test->optInMethod_2,                        outBegIdx,                        outNbElement,                        outputBuffer );     *lookback = TA_APO_Lookback( testParam->test->optInFastPeriod,                      testParam->test->optInSlowPeriod,                      (TA_MAType)testParam->test->optInMethod_2 );   }  return retCode;}static ErrorNumber do_test( const TA_History *history,                            const TA_Test *test ){   TA_RetCode retCode;   ErrorNumber errNb;   TA_Integer outBegIdx;   TA_Integer outNbElement;   TA_RangeTestParam testParam;   /* Set to NAN all the elements of the gBuffers.  */   clearAllBuffers();   TA_SetCompatibility( (TA_Compatibility)test->compatibility );   /* Build the input. */   setInputBuffer( 0, history->close, history->nbBars );   setInputBuffer( 1, history->close, history->nbBars );      TA_SetUnstablePeriod( TA_FUNC_UNST_EMA, 0 );   /* Make a simple first call. */   if( test->doPercentage )   {      retCode = TA_PPO( test->startIdx,                        test->endIdx,                        gBuffer[0].in,                        test->optInFastPeriod,                        test->optInSlowPeriod,                        (TA_MAType)test->optInMethod_2,                        &outBegIdx,                        &outNbElement,                        gBuffer[0].out0 );   }   else   {      retCode = TA_APO( test->startIdx,                        test->endIdx,                        gBuffer[0].in,                        test->optInFastPeriod,                        test->optInSlowPeriod,                        (TA_MAType)test->optInMethod_2,                        &outBegIdx,                        &outNbElement,                        gBuffer[0].out0 );   }   errNb = checkDataSame( gBuffer[0].in, history->close, history->nbBars );   if( errNb != TA_TEST_PASS )      return errNb;   errNb = checkExpectedValue( gBuffer[0].out0,                                retCode, test->expectedRetCode,                               outBegIdx, test->expectedBegIdx,                               outNbElement, test->expectedNbElement,                               test->oneOfTheExpectedOutReal,                               test->oneOfTheExpectedOutRealIndex );      if( errNb != TA_TEST_PASS )      return errNb;   outBegIdx = outNbElement = 0;   /* Make another call where the input and the output are the    * same buffer.    */   if( test->doPercentage )   {      retCode = TA_PPO( test->startIdx,                        test->endIdx,                        gBuffer[1].in,                        test->optInFastPeriod,                        test->optInSlowPeriod,                        (TA_MAType)test->optInMethod_2,                        &outBegIdx,                        &outNbElement,                        gBuffer[1].in );   }   else   {      retCode = TA_APO( test->startIdx,                        test->endIdx,                        gBuffer[1].in,                        test->optInFastPeriod,                        test->optInSlowPeriod,                        (TA_MAType)test->optInMethod_2,                        &outBegIdx,                        &outNbElement,                        gBuffer[1].in );   }   /* The previous call should have the same output    * as this call.    *    * checkSameContent verify that all value different than NAN in    * the first parameter is identical in the second parameter.    */   errNb = checkSameContent( gBuffer[0].out0, gBuffer[1].in );   if( errNb != TA_TEST_PASS )      return errNb;   errNb = checkExpectedValue( gBuffer[1].in,                                retCode, test->expectedRetCode,                               outBegIdx, test->expectedBegIdx,                               outNbElement, test->expectedNbElement,                               test->oneOfTheExpectedOutReal,                               test->oneOfTheExpectedOutRealIndex );      if( errNb != TA_TEST_PASS )      return errNb;   /* Do a systematic test of most of the    * possible startIdx/endIdx range.    */   testParam.test  = test;   testParam.close = history->close;   if( test->doRangeTestFlag )   {      if( test->optInMethod_2 == TA_MAType_EMA )      {         errNb = doRangeTest( rangeTestFunction,                               TA_FUNC_UNST_EMA,                              (void *)&testParam, 1, 0 );         if( errNb != TA_TEST_PASS )            return errNb;      }      else      {         errNb = doRangeTest( rangeTestFunction,                               TA_FUNC_UNST_NONE,                              (void *)&testParam, 1, 0 );         if( errNb != TA_TEST_PASS )            return errNb;      }   }   return TA_TEST_PASS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -