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

📄 test_rsi.c

📁 股票主要技术指标源码
💻 C
📖 第 1 页 / 共 2 页
字号:
                        outBegIdx,                        outNbElement,                        outputBuffer );      *lookback = TA_RSI_Lookback( testParam->test->optInTimePeriod);      break;   case TA_CMO_TEST:      retCode = TA_CMO( startIdx,                        endIdx,                        testParam->close,                        testParam->test->optInTimePeriod,                        outBegIdx,                        outNbElement,                        outputBuffer );      *lookback = TA_CMO_Lookback( testParam->test->optInTimePeriod);      break;   default:      retCode = TA_INTERNAL_ERROR(177);   }   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;   const TA_FuncHandle *funcHandle;   const TA_FuncInfo *funcInfo;   TA_ParamHolder *params;      retCode = TA_SUCCESS;   /* 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 );      /* Set the unstable period requested for that test. */   switch( test->theFunction )   {   case TA_RSI_TEST:      retCode = TA_SetUnstablePeriod( TA_FUNC_UNST_RSI, test->unstablePeriod );      break;   case TA_CMO_TEST:      retCode = TA_SetUnstablePeriod( TA_FUNC_UNST_CMO, test->unstablePeriod );      break;   }   if( retCode != TA_SUCCESS )      return TA_TEST_TFRR_SETUNSTABLE_PERIOD_FAIL;   /* Make a simple first call. */   switch( test->theFunction )   {   case TA_RSI_TEST:      retCode = TA_RSI( test->startIdx,                        test->endIdx,                        gBuffer[0].in,                        test->optInTimePeriod,                        &outBegIdx,                        &outNbElement,                        gBuffer[0].out0 );      break;   case TA_CMO_TEST:      retCode = TA_CMO( test->startIdx,                        test->endIdx,                        gBuffer[0].in,                        test->optInTimePeriod,                        &outBegIdx,                        &outNbElement,                        gBuffer[0].out0 );      break;   default:      retCode = TA_INTERNAL_ERROR(178);   }   errNb = checkDataSame( gBuffer[0].in, history->close,history->nbBars );   if( errNb != TA_TEST_PASS )      return errNb;   CHECK_EXPECTED_VALUE( gBuffer[0].out0, 0 );   outBegIdx = outNbElement = 0;   /* Make another call where the input and the output are the    * same buffer.    */   switch( test->theFunction )   {   case TA_RSI_TEST:      retCode = TA_RSI( test->startIdx,                        test->endIdx,                        gBuffer[1].in,                        test->optInTimePeriod,                        &outBegIdx,                        &outNbElement,                        gBuffer[1].in );      break;   case TA_CMO_TEST:      retCode = TA_CMO( test->startIdx,                        test->endIdx,                        gBuffer[1].in,                        test->optInTimePeriod,                        &outBegIdx,                        &outNbElement,                        gBuffer[1].in );      break;   default:      retCode = TA_INTERNAL_ERROR(179);   }   /* 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;   CHECK_EXPECTED_VALUE( gBuffer[1].in, 0 );   if( errNb != TA_TEST_PASS )      return errNb;   /* Make a call using the abstract interface. */   switch( test->theFunction )   {   case TA_RSI_TEST:      retCode = TA_GetFuncHandle( "RSI", &funcHandle );      break;   case TA_CMO_TEST:      retCode = TA_GetFuncHandle( "CMO", &funcHandle );      break;   default:      retCode = TA_INTERNAL_ERROR(180);   }   if( retCode != TA_SUCCESS )   {      printf( "Fail: TA_GetFuncHandle with retCode = %d\n", retCode );      return TA_ABS_TST_FAIL_GETFUNCHANDLE;   }   retCode = TA_GetFuncInfo( funcHandle, &funcInfo );   if( retCode != TA_SUCCESS )   {      printf( "Fail: TA_GetFuncInfo with retCode = %d\n", retCode );      return TA_ABS_TST_FAIL_GETFUNCINFO;   }                                retCode = TA_ParamHolderAlloc( funcHandle, &params );   if( retCode != TA_SUCCESS )   {      printf( "Fail: TA_ParamHolderAlloc with retCode = %d\n", retCode );      return TA_ABS_TST_FAIL_PARAMHOLDERALLOC;   }   retCode = TA_SetInputParamRealPtr( params, 0, gBuffer[0].in );   if( retCode != TA_SUCCESS )   {      printf( "Fail: TA_SetInputParamRealPtr with retCode = %d\n", retCode );      return TA_ABS_TST_FAIL_PARAMREALPTR;   }   retCode = TA_SetOptInputParamInteger( params, 0, test->optInTimePeriod );   if( retCode != TA_SUCCESS )   {      printf( "Fail: TA_SetOptInputParamInteger with retCode = %d\n", retCode );      return TA_ABS_TST_FAIL_OPTINPUTPARAMINTEGER;   }   retCode = TA_SetOutputParamRealPtr( params, 0, gBuffer[1].out0 );   if( retCode != TA_SUCCESS )   {      printf( "Fail: TA_SetOutputParamRealPtr with retCode = %d\n", retCode );      return TA_ABS_TST_FAIL_SETOUTPUTPARAMREALPTR;   }   retCode = TA_CallFunc( params,                          test->startIdx,                          test->endIdx,                          &outBegIdx,                          &outNbElement );   if( retCode != TA_SUCCESS )   {      printf( "Fail: TA_CallFunc with retCode = %d\n", retCode );      return TA_ABS_TST_FAIL_CALLFUNC;   }                              retCode = TA_ParamHolderFree( params );   if( retCode != TA_SUCCESS )   {      printf( "Fail: TA_GetFuncHandle with retCode = %d\n", retCode );      return TA_ABS_TST_FAIL_PARAMHOLDERFREE;   }   /* 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].out0 );   if( errNb != TA_TEST_PASS )      return errNb;   CHECK_EXPECTED_VALUE( gBuffer[1].out0, 0 );   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 )   {      switch( test->theFunction )      {      case TA_RSI_TEST:         errNb = doRangeTest( rangeTestFunction,                               TA_FUNC_UNST_RSI,                              (void *)&testParam, 1, 0 );         break;      case TA_CMO_TEST:         errNb = doRangeTest( rangeTestFunction,                               TA_FUNC_UNST_CMO,                              (void *)&testParam, 1, 0 );         break;     }      if( errNb != TA_TEST_PASS )         return errNb;   }   return TA_TEST_PASS;}

⌨️ 快捷键说明

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