📄 test_per_hlc.c
字号:
testParam->close, testParam->test->optInTimePeriod1, outBegIdx, outNbElement, outputBuffer ); *lookback = TA_CCI_Lookback( testParam->test->optInTimePeriod1 ); break; case TA_WILLR_TEST: retCode = TA_WILLR( startIdx, endIdx, testParam->high, testParam->low, testParam->close, testParam->test->optInTimePeriod1, outBegIdx, outNbElement, outputBuffer ); *lookback = TA_WILLR_Lookback( testParam->test->optInTimePeriod1 ); break; case TA_ULTOSC_TEST: retCode = TA_ULTOSC( startIdx, endIdx, testParam->high, testParam->low, testParam->close, testParam->test->optInTimePeriod1, testParam->test->optInTimePeriod2, testParam->test->optInTimePeriod3, outBegIdx, outNbElement, outputBuffer ); *lookback = TA_ULTOSC_Lookback( testParam->test->optInTimePeriod1, testParam->test->optInTimePeriod2, testParam->test->optInTimePeriod3 ); break; default: retCode = TA_INTERNAL_ERROR(132); } return retCode;}static TA_RetCode do_call( const TA_Test *test, const double high[], const double low[], const double close[], int *outBegIdx, int *outNbElement, double output[] ){ TA_RetCode retCode; switch( test->theFunction ) { case TA_NATR_TEST: retCode = TA_NATR( test->startIdx, test->endIdx, high, low, close, test->optInTimePeriod1, outBegIdx, outNbElement, output ); break; case TA_CCI_TEST: retCode = TA_CCI( test->startIdx, test->endIdx, high, low, close, test->optInTimePeriod1, outBegIdx, outNbElement, output ); break; case TA_WILLR_TEST: retCode = TA_WILLR( test->startIdx, test->endIdx, high, low, close, test->optInTimePeriod1, outBegIdx, outNbElement, output ); break; case TA_ULTOSC_TEST: retCode = TA_ULTOSC( test->startIdx, test->endIdx, high, low, close, test->optInTimePeriod1, test->optInTimePeriod2, test->optInTimePeriod3, outBegIdx, outNbElement, output ); break; default: retCode = TA_INTERNAL_ERROR(133); } 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(); /* Build the input. */ setInputBuffer( 0, history->high, history->nbBars ); setInputBuffer( 1, history->low, history->nbBars ); setInputBuffer( 2, history->close, history->nbBars ); /* Make a simple first call. */ retCode = do_call( test, gBuffer[0].in, gBuffer[1].in, gBuffer[2].in, &outBegIdx, &outNbElement, gBuffer[0].out0 ); /* Check that the input were preserved. */ errNb = checkDataSame( gBuffer[0].in, history->high,history->nbBars ); if( errNb != TA_TEST_PASS ) return errNb; errNb = checkDataSame( gBuffer[1].in, history->low, history->nbBars ); if( errNb != TA_TEST_PASS ) return errNb; errNb = checkDataSame( gBuffer[2].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. */ retCode = do_call( test, gBuffer[0].in, gBuffer[1].in, gBuffer[2].in, &outBegIdx, &outNbElement, gBuffer[0].in ); /* Check that the input were preserved. */ errNb = checkDataSame( gBuffer[1].in, history->low, history->nbBars ); if( errNb != TA_TEST_PASS ) return errNb; errNb = checkDataSame( gBuffer[2].in, history->close,history->nbBars ); if( errNb != TA_TEST_PASS ) return errNb; /* 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[0].in ); if( errNb != TA_TEST_PASS ) return errNb; CHECK_EXPECTED_VALUE( gBuffer[0].in, 0 ); setInputBuffer( 0, history->high, history->nbBars ); /* Make another call where the input and the output are the * same buffer. */ retCode = do_call( test, gBuffer[0].in, gBuffer[1].in, gBuffer[2].in, &outBegIdx, &outNbElement, gBuffer[1].in ); /* Check that the input were preserved. */ errNb = checkDataSame( gBuffer[0].in, history->high,history->nbBars ); if( errNb != TA_TEST_PASS ) return errNb; errNb = checkDataSame( gBuffer[2].in, history->close,history->nbBars ); if( errNb != TA_TEST_PASS ) return errNb; /* 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 ); setInputBuffer( 1, history->low, history->nbBars ); /* Make another call where the input and the output are the * same buffer. */ retCode = do_call( test, gBuffer[0].in, gBuffer[1].in, gBuffer[2].in, &outBegIdx, &outNbElement, gBuffer[2].in ); /* Check that the input were preserved. */ errNb = checkDataSame( gBuffer[0].in, history->high,history->nbBars ); if( errNb != TA_TEST_PASS ) return errNb; errNb = checkDataSame( gBuffer[1].in, history->low, history->nbBars ); if( errNb != TA_TEST_PASS ) return errNb; /* 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[2].in ); if( errNb != TA_TEST_PASS ) return errNb; CHECK_EXPECTED_VALUE( gBuffer[2].in, 0 ); setInputBuffer( 2, history->close, history->nbBars ); /* Do a systematic test of most of the * possible startIdx/endIdx range. */ testParam.test = test; testParam.high = history->high; testParam.low = history->low; testParam.close = history->close; if( test->doRangeTestFlag ) { switch( test->theFunction ) { case TA_NATR_TEST: errNb = doRangeTest( rangeTestFunction, TA_FUNC_UNST_NATR, (void *)&testParam, 1, 0 ); break; default: errNb = doRangeTest( rangeTestFunction, TA_FUNC_UNST_NONE, (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 + -