Skip to content

Commit

Permalink
upload contract info
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhuangxinyu1 committed Jun 5, 2020
1 parent 888ef40 commit 6cbc2bc
Show file tree
Hide file tree
Showing 21 changed files with 129 additions and 257 deletions.
6 changes: 3 additions & 3 deletions config/backtest/backtest.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fixed_path="/home/nick/future";
backtest_outputdir = "backtest_high";
backtest_outputdir = "backtest_plot";
strategy = (
{
unique_name = "IC";
Expand Down Expand Up @@ -128,8 +128,8 @@ strategy = (
// start_date = "today";
// start_date = "yesterday";
test_mode = "nexttest";
start_date = "2019-01-01";
period = 1000;
start_date = "2019-11-01";
period = 10;

order_file = "order_backtest.dat";
exchange_file = "exchange_backtest.dat";
Expand Down
259 changes: 29 additions & 230 deletions config/backtest/bk_backtest.config
Original file line number Diff line number Diff line change
@@ -1,231 +1,30 @@
time_controller = {
sleep_time = ["10:14:20-10:30:00", "11:29:20-13:30:00", "03:58:20-08:55:00"];
close_time = ["14:00:59-14:59:00", "23:00:00-23:59:59"];
force_close_time = ["16:59:59-17:30:00"];
};

legend = "nf:rg3:am50:mhc:*";
backtest_out_file = "backtest_record";

fixed_path="/home/nick/future";
backtest_outputdir = "backtest_plot";
strategy = (
/*
{ unique_name = "AP";
pairs = ("AP910", "AP905");
max_position = 5;
range_width = 1.5;
tick_size = 1.0;
contract_size = 10;
min_train_samples= 600;
cancel_threshhold = 1000000000;
min_range = 4.0;
min_profit = 1.0;
add_margin = 5.0;
spread_threshold = 3.0;
stop_loss_margin = 1.0;
max_loss_times = 2;
max_holding_sec = 144000000;
},
{ unique_name = "CF";
pairs = ("CF909", "CF905");
max_position = 5;
range_width = 1.0;
tick_size = 5.0;
contract_size = 10;
min_train_samples= 600;
cancel_threshhold = 1000000000;
min_range = 4.0;
min_profit = 1.0;
add_margin = 1.0;
spread_threshold = 3.0;
stop_loss_margin = 1.0;
max_loss_times = 2;
max_holding_sec = 3600;
},
{ unique_name = "FG";
pairs = ("FG909", "FG905");
max_position = 5;
range_width = 1.0;
tick_size = 1.0;
contract_size = 10;
min_train_samples= 600;
cancel_threshhold = 1000000000;
min_range = 4.0;
min_profit = 1.0;
add_margin = 1.0;
spread_threshold = 3.0;
max_holding_sec = 3600;
stop_loss_margin = 1.0;
max_loss_times = 2;
},
{ unique_name = "MA";
pairs = ("MA909", "MA905");
max_position = 5;
range_width = 1.0;
tick_size = 1.0;
contract_size = 10;
min_train_samples= 600;
cancel_threshhold = 1000000000;
min_range = 4.0;
min_profit = 1.0;
add_margin = 1.0;
spread_threshold = 3.0;
max_holding_sec = 3600;
stop_loss_margin = 1.0;
max_loss_times = 2;
},
{ unique_name = "OI";
pairs = ("OI909", "OI905");
max_position = 5;
range_width = 1.0;
tick_size = 1.0;
contract_size = 10;
min_train_samples= 600;
cancel_threshhold = 1000000000;
min_range = 4.0;
min_profit = 1.0;
add_margin = 1.0;
spread_threshold = 3.0;
max_holding_sec = 3600;
stop_loss_margin = 1.0;
max_loss_times = 2;
},
{ unique_name = "fu";
pairs = ("fu1909", "fu1905");
max_position = 5;
range_width = 1.0;
tick_size = 1.0;
contract_size = 10;
min_train_samples= 600;
cancel_threshhold = 1000000000;
min_range = 4.0;
min_profit = 1.0;
add_margin = 1.0;
spread_threshold = 3.0;
max_holding_sec = 36000000000;
stop_loss_margin = 1.0;
max_loss_times = 2;
},

{ unique_name = "cu";
pairs = ("cu1905", "cu1904");
max_position = 5;
tick_size = 10.0;
range_width = 2.0;
contract_size = 5;
min_train_samples= 600;
cancel_threshhold = 1000000000;
min_range = 4.0;
min_profit = 1.0;
add_margin = 1.0;
spread_threshold = 3.0;
max_holding_sec = 3600000;
stop_loss_margin = 1.0;
max_loss_times = 2;
},

{ unique_name = "ni";
pairs = ("ni1905", "ni1906");
max_position = 5;
tick_size = 10.0;
range_width = 2.0;
contract_size = 1;
min_train_samples= 600;
cancel_threshhold = 1000000000;
min_range = 4.0;
min_profit = 1.0;
add_margin = 1.0;
spread_threshold = 3.0;
max_holding_sec = 3600000;
stop_loss_margin = 1.0;
max_loss_times = 2;
},
*/

{ unique_name = "IC";
pairs = ("IC1906", "IC1903");
max_position = 1;
range_width = 2.0;
tick_size = 0.2;
contract_size = 10;
min_train_samples= 600;
cancel_threshhold = 1000000000;
min_range = 4.0;
min_profit = 1.0;
add_margin = 3.0;
spread_threshold = 3.0;
max_holding_sec = 360000000;
stop_loss_margin = 1.0;
max_loss_times = 2;
}

);

data_file = [
/*
"/running/quant/data/Ali/2018-11-28/AP9",
"/running/quant/data/Ali/2018-12-03/AP9",
"/running/quant/data/Ali/2018-12-05/AP9",
"/running/quant/data/Ali/2018-12-06/AP9",
"/running/quant/data/Ali/2018-12-10/AP9",
"/running/quant/data/Ali/2018-12-11/AP9",
"/running/quant/data/Ali/2018-12-12/AP9",
"/running/quant/data/Ali/2018-12-13/AP9",
"/running/quant/data/Ali/2018-12-14/AP9",
"/running/quant/data/Ali/2018-12-17/AP9",
"/running/quant/data/Ali/2018-12-18/AP9",
"/running/quant/data/Ali/2018-12-19/AP9",
"/running/quant/data/Ali/2018-12-20/AP9",
"/running/quant/data/Ali/2018-12-21/AP9",
"/running/quant/data/Ali/2018-12-24/AP9",
"/running/quant/data/Ali/2018-12-25/AP9",
"/running/quant/data/Ali/2018-12-26/AP9",
"/running/quant/data/Ali/2018-12-27/AP9",
"/running/quant/data/Ali/2018-12-28/AP9",
"/running/quant/data/Ali/2018-12-31/AP9",
"/running/quant/data/Ali/2019-01-01/AP9",
"/running/quant/data/Ali/2019-01-02/AP9",
"/running/quant/data/Ali/2019-01-03/AP9",
"/running/quant/data/Ali/2019-01-04/AP9",
"/running/quant/data/Ali/2019-01-07/AP9",
"/running/quant/data/Ali/2019-01-08/AP9",
"/running/quant/data/Ali/2019-01-09/AP9",
"/running/quant/data/Ali/2019-01-10/AP9",
"/running/quant/data/Ali/2019-01-11/AP9",
"/running/quant/data/Ali/2019-01-14/AP9",
"/running/quant/data/Ali/2019-01-15/AP9",
"/running/quant/data/Ali/2019-01-16/AP9",
"/running/quant/data/Ali/2019-01-17/AP9",
"/running/quant/data/Ali/2019-01-18/AP9",
"/running/quant/data/Ali/2019-01-21/AP9",
"/running/quant/data/Ali/2019-01-22/AP9",
"/running/quant/data/Ali/2019-01-23/AP9",
"/running/quant/data/Ali/2019-01-24/AP9",
"/running/quant/data/Ali/2019-01-25/AP9",
*/
"/running/quant/data/Ali/2019-01-28/IC19",
"/running/quant/data/Ali/2019-01-29/IC19",
"/running/quant/data/Ali/2019-01-30/IC19",
"/running/quant/data/Ali/2019-01-31/IC19",
"/running/quant/data/Ali/2019-02-01/IC19",
"/running/quant/data/Ali/2019-02-02/IC19",
"/running/quant/data/Ali/2019-02-11/IC19",
"/running/quant/data/Ali/2019-02-12/IC19",
"/running/quant/data/Ali/2019-02-13/IC19",
"/running/quant/data/Ali/2019-02-14/IC19",
"/running/quant/data/Ali/2019-02-15/IC19",
"/running/quant/data/Ali/2019-02-18/IC19",
"/running/quant/data/Ali/2019-02-19/IC19",
"/running/quant/data/Ali/2019-02-20/IC19",
"/running/quant/data/Ali/2019-02-21/IC19",
"/running/quant/data/Ali/2019-02-22/IC19",
"/running/quant/data/Ali/2019-02-25/IC19",
"/running/quant/data/Ali/2019-02-26/IC19",
"/running/quant/data/Ali/2019-02-27/IC19",
"/running/quant/data/Ali/2019-02-28/IC19",
"/running/quant/data/Ali/2019-03-01/IC19"
// "/running/quant/data/Ali/2019-01-15/IC19"
// "/running/IC19"
];

matcher_mode = "c++";
message_line = 100000;
{
unique_name = "ni";
ticker = "ni";
max_position = 1;
max_round = 1000;
range_width = 1.0;
train_samples = 1200;
min_range = 1.0;
split_num = 6;
min_profit = 1.0;
add_margin = 3.0;
spread_threshold = 3.0;
max_holding_sec = 3600000;
stop_loss_margin = 300.0;
max_loss_times = 2;
}
);

// start_date = "today";
// start_date = "yesterday";
test_mode = "nexttest";
start_date = "2019-11-01";
period = 10;

order_file = "order_backtest.dat";
exchange_file = "exchange_backtest.dat";
strat_file = "mid_backtest.dat";
4 changes: 2 additions & 2 deletions config/contract/bk_contract.config
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ map = (
is_fixed_open_fee_rate = true;
is_fixed_close_today_fee_rate = true;
is_fixed_close_fee_rate = true;
open_fee = 6.0;
close_today_fee= 6.0;
open_fee = 3.5;
close_today_fee= 0.0;
close_fee= 6.0;
},
{
Expand Down
4 changes: 2 additions & 2 deletions config/contract/contract.config
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ sn = {
is_fixed_open_fee_rate = true;
is_fixed_close_today_fee_rate = true;
is_fixed_close_fee_rate = true;
open_fee= 3.0;
open_fee= 2.0;
close_today_fee= 0.0;
close_fee= 3.0;
close_fee= 2.0;
};

sp = {
Expand Down
7 changes: 4 additions & 3 deletions config/prod/time.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
time_controller :
{
sleep_time = ["09:30:00-09:45:59", "11:30:04-13:10:00", "00:00:00-03:30:00", "16:00:00-23:59:59"];
close_time = [ "14:20:00-14:50:00", "11:15:00-11:29:00" ];
force_close_time = [ "14:50:01-15:59:59", "11:29:01-11:29:59" ];
sleep_time = ["09:30:00-09:45:59", "20:55:00-23:59:59", "00:00:00-02:29:59"];
close_time = [ "14:30:00-14:50:00"];
force_close_time = [ "14:55:01-15:29:59"];
invalid_time = ["02:30:00-08:30:00", "11:30:00-13:00:00", "15:30:00-20:50:00"];
};
2 changes: 1 addition & 1 deletion external/common/include/core/base_strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BaseStrategy {

void RequestQryPos();
// automatic control function
void CheckStatus(const MarketSnapshot& shot);
void CheckStatus(const MarketSnapshot& shot, TimeStatus::Enum time_status);
void UpdatePos(Order* o, const ExchangeInfo& info);
void UpdateAvgCost(const std::string & ticker, double trade_price, int size);
bool TimeUp() const;
Expand Down
7 changes: 6 additions & 1 deletion external/common/include/struct/time_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ struct TimeStatus {
Pause,
Close,
Training,
ForceClose
ForceClose,
InValid
};

static inline const char* ToString(Enum status) {
Expand All @@ -32,6 +33,10 @@ struct TimeStatus {
return "ForceClose";
break;

case InValid:
return "InValid";
break;

default:
return "Unknown";
break;
Expand Down
2 changes: 2 additions & 0 deletions external/common/include/util/time_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class TimeController {
std::vector<int>close_stop;
std::vector<int>force_close_start;
std::vector<int>force_close_stop;
std::vector<int>invalid_start;
std::vector<int>invalid_stop;
std::string mode;
long int timer_sec;
long int timer_usec;
Expand Down
Binary file modified external/common/lib/libnick.so
Binary file not shown.
6 changes: 6 additions & 0 deletions external/ctp/include/ThostFtdcMdApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class CThostFtdcMdSpi
///登出请求响应
virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};

///请求查询组播合约响应
virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};

///错误应答
virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};

Expand Down Expand Up @@ -155,6 +158,9 @@ class MD_API_EXPORT CThostFtdcMdApi

///登出请求
virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0;

///请求查询组播合约
virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0;
protected:
~CThostFtdcMdApi(){};
};
Expand Down
Loading

0 comments on commit 6cbc2bc

Please sign in to comment.