Skip to content

Commit

Permalink
upload test version
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhuangxinyu1 committed Feb 21, 2020
1 parent 1b7978c commit 105e6cf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion external/common/include/util/dater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ std::string Dater::GetOneDataFileNameByDate(const std::string & date) {
printf("bad date %s\n", date.c_str());
return "";
}
return "/running/"+date_str+"/future" + date_str + ".dat.gz";
return "/running/"+date_str+"/future" + date_str + ".dat";
}

std::string Dater::GetValidFile(const std::string & start_date, int num_days) {
Expand Down
Binary file modified external/common/lib/libnick.so
Binary file not shown.
25 changes: 18 additions & 7 deletions src/backtest/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <libconfig.h++>
#include <unordered_map>
#include <utility>
#include <string>
#include <vector>

Expand All @@ -12,7 +13,7 @@
#include "util/history_worker.h"
#include "/root/hft/src/simplearb/strategy.h"

std::unordered_map<std::string, std::vector<BaseStrategy*> > GenTSM() {
std::pair< std::unordered_map<std::string, std::vector<BaseStrategy*> >, std::vector<std::string> > GenTSM() {
std::string default_path = GetDefaultPath();

libconfig::Config param_cfg;
Expand All @@ -29,6 +30,17 @@ std::unordered_map<std::string, std::vector<BaseStrategy*> > GenTSM() {
std::unordered_map<std::string, std::vector<BaseStrategy*> > ticker_strat_map;
std::string contract_config_path = default_path + "/hft/config/contract/contract.config";

Dater dt;
std::string start_date = param_cfg.lookup("start_date");
if (start_date == "today") {
start_date = dt.GetDate();
}
if (start_date == "yesterday") {
start_date = dt.GetDate("", -1);
}
int period = param_cfg.lookup("period");
std::vector<std::string> file_v = dt.GetDataFilesNameByDate(start_date, period, true);

try {
const libconfig::Setting & strategies = param_cfg.lookup("strategy");
for (int i = 0; i < strategies.getLength(); i++) {
Expand All @@ -50,16 +62,15 @@ std::unordered_map<std::string, std::vector<BaseStrategy*> > GenTSM() {
printf("EXCEPTION: %s\n", ex.what());
exit(1);
}
return ticker_strat_map;
return std::make_pair(ticker_strat_map, file_v);
}

int main() {
auto ticker_strat_map = GenTSM();
auto t = GenTSM();
auto ticker_strat_map = t.first;
auto file_list = t.second;
PrintVector(file_list);
ThreadPool pool(4);
std::vector<std::string> file_list = {"/running/2020-02-07/future2020-02-07.dat.gz",
"/running/2020-02-07/future2020-02-07.dat.gz",
"/running/2020-02-07/future2020-02-07.dat.gz",
"/running/2020-02-07/future2020-02-07.dat.gz"};
for (auto f: file_list) {
pool.enqueue([](const std::unordered_map<std::string, std::vector<BaseStrategy*> >& m, std::string f) {Backtester bt(m); bt.LoadData(f);}, ticker_strat_map, f);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ctporder/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ int main() {
}
CThostFtdcTraderApi* user_api = CThostFtdcTraderApi::CreateFtdcTraderApi();

/*
std::string broker = "9999";
std::string username = "116909";
std::string password = "yifeng";
/*
*/
std::string broker = "9999";
std::string username = "115686";
std::string password = "fz567789";
*/
::unordered_map<int, int> order_id_map;

TokenManager tm;
Expand Down

0 comments on commit 105e6cf

Please sign in to comment.