📄 technic_test.cpp
字号:
#include <iostream>#include "technic_test.h"#include "hbstock2/stock_data.h"#include "hbstock2/hbstock_init.h"/* must be at the end of include */#include "gnu/i18n_debug.h"using namespace std;using namespace hbstock2;using namespace gnu;static const char* LOGFILE = gnu::FILENAME(__FILE__);CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TechnicTest, "unitTest" );void TechnicTest::setUp(){ }void TechnicTest::tearDown(){}void TechnicTest::testAll(){ int status = 0; AppConfig* p_app_config = AppConfigInst::instance();
string str_dir = p_app_config->get_root_dir() + "/plugin/data";
const char* p_file_prefix = "data_"; DataManger* p_datamanger = 0; p_datamanger = DataMangerInst::instance();
p_datamanger->load_dso_from_dir(str_dir,p_file_prefix); DataLoaderPtr data_loader_ptr ; data_loader_ptr = p_datamanger->get_day_default_dataloader("SZ"); CPPUNIT_ASSERT( data_loader_ptr.get() != 0 ); VectStockData vect_stockdata;
std::string str_stock_code = "002018"; //std::string str_stock_code = "600028";
char* p_chr_date=NULL; int data_length=0; try { data_loader_ptr->load_day_data(vect_stockdata,str_stock_code,p_chr_date,data_length); } catch (std::exception& ex) { I18N_ERROR(_("%s [%s:%l] load data error: error is: %s\n"),ex.what()); status = -1; } CPPUNIT_ASSERT( vect_stockdata.size() != 0 ); //bool is_show = true; std::vector<float> arr_in; std::vector<float> arr_ma; unsigned int ma_len = 10; for (unsigned int i=0;i<vect_stockdata.size();i++) { /* I18N_INFO(_D("%s %s\t%f\t%f\t%f\t%f\t%d\t%f\n"), vect_stockdata[i].date.c_str(), vect_stockdata[i].open_price, vect_stockdata[i].close_price, vect_stockdata[i].high_price, vect_stockdata[i].low_price, vect_stockdata[i].volume, vect_stockdata[i].money); */ arr_in.push_back(vect_stockdata[i].close_price); } ma(arr_ma,arr_in,ma_len); I18N_DEBUG(_("%s [%s:%l] arr_ma size : %d\n"),arr_ma.size()); /* for (unsigned int i=0;i<arr_ma.size();i++) { I18N_INFO(_("%s %f\n"),arr_ma[i]); } */ // get macd data macd macd_inst; std::vector<hbstock2::macd_data > arr_macd; macd_inst.result(arr_macd,arr_in); I18N_INFO(_("%s DIF\tDEA\tMACD\n")); I18N_DEBUG(_("%s [%s:%l] arr_macd size : %d\n"),arr_macd.size()); int i_cout = arr_macd.size() -10 ; if (i_cout < 0) { i_cout = 0; } /* for (unsigned int i=i_cout;i<arr_macd.size();i++) { I18N_INFO(_("%s %f\t%f\t%f\n"),arr_macd[i].dif,arr_macd[i].dea,arr_macd[i].macd); } */ CPPUNIT_ASSERT( status == 0 );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -