Skip to content

Commit

Permalink
backtest output into a dir
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhuangxinyu1 committed Mar 21, 2020
1 parent bb3087d commit 794a3f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config/backtest/backtest.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ time_controller :
close_time = [ "14:00:59-14:55:00", "23:00:00-23:29:00" ];
force_close_time = [ "14:55:10-14:59:59", "23:29:10-23:59:59" ];
};
backtest_out_file = "backtest_record";
backtest_outputdir = "backtest_out";
strategy = (
{
unique_name = "au";
Expand Down Expand Up @@ -112,7 +112,7 @@ strategy = (
// start_date = "today";
// start_date = "yesterday";
test_mode = "test";
start_date = "2020-03-17"
start_date = "today"
period = 1;
matcher_mode = "python";
message_line = 100000;
Expand Down
15 changes: 8 additions & 7 deletions src/backtest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ std::map<std::string, std::string> GetBacktestFile() {

Dater dt;
std::string start_date = param_cfg.lookup("start_date");
std::string test_mode = param_cfg.lookup("test_mode");
if (start_date == "today") {
start_date = dt.GetDate();
}
Expand All @@ -57,17 +56,19 @@ std::unordered_map<std::string, std::vector<BaseStrategy*> > GetStratMap(std::st
std::string contract_config_path = default_path + "/hft/config/contract/contract.config";
HistoryWorker hw(Dater::FindOneValid(date, -20));

std::string ui_address = "backtest_ui_" + date;
std::string order_address = "order_sub_" + date;
std::string ui_file = "mid_" + date + ".dat";
std::string order_file = "order_" + date + ".dat";
// std::unique_ptr<Sender<MarketSnapshot> > ui_sender(new Sender<MarketSnapshot>(ui_address, "bind", "ipc", ui_file));
// std::unique_ptr<Sender<Order> > order_sender(new Sender<Order>("order_sub", "connect", "ipc", "order.dat"));
// std::unique_ptr<ShmSender<Order> > order_sender(new ShmSender<Order>(order_address, 100000, order_file));
auto ui_sender = new Sender<MarketSnapshot>(ui_address, "bind", "ipc", ui_file);
auto order_sender = new ShmSender<Order>(order_address, 100000, order_file);

try {
std::string backtest_outputdir = param_cfg.lookup("backtest_outputdir");
EnsureDir(backtest_outputdir);
std::string ui_address = "backtest_ui_" + date;
std::string order_address = "order_sub_" + date;
std::string ui_file = backtest_outputdir + "/mid_" + date + ".dat";
std::string order_file = backtest_outputdir + "/order_" + date + ".dat";
auto ui_sender = new Sender<MarketSnapshot>(ui_address, "bind", "ipc", ui_file);
auto order_sender = new ShmSender<Order>(order_address, 100000, order_file);
std::string test_mode = param_cfg.lookup("test_mode");
const libconfig::Setting & strategies = param_cfg.lookup("strategy");
for (int i = 0; i < strategies.getLength(); i++) {
Expand Down

0 comments on commit 794a3f6

Please sign in to comment.