From 7696f725dc1132be6e075b6140ca0ae0f2d556f8 Mon Sep 17 00:00:00 2001 From: letianzj Date: Thu, 3 Sep 2020 19:18:17 -0400 Subject: [PATCH] prepare update config --- examples/config_live.yaml | 60 +++++++++++++---------------- examples/prepare_trading_session.py | 14 ++++++- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/examples/config_live.yaml b/examples/config_live.yaml index a7cbd8c..4fda6f5 100644 --- a/examples/config_live.yaml +++ b/examples/config_live.yaml @@ -1,52 +1,46 @@ account: LU1832 -theme: dark # white, dark -host: '127.0.0.1' -port: 7497 client_id: 0 -total_trade_limit: 20 -total_cancel_limit: 10 -total_active_limit: 3 -total_loss_limit: 5000 - -#-------------- active strategies -------------# +host: 127.0.0.1 +port: 7497 strategy: - MovingAverageCrossStrategy: - active: False + DoubleMovingAverageCrossStrategy: + active: false capital: 10000 params: - G: 20 + n_fast_ma: 20 + n_slow_ma: 200 symbols: - - CLV0 FUT NYMEX + - NGV0 FUT NYMEX DualThrustStrategy: - active: False + active: false capital: 10000 params: G: 20 symbols: - - MES FUT GLOBEX - DoubleMovingAverageCrossStrategy: - active: False + - MES FUT GLOBEX + MovingAverageCrossStrategy: + active: false capital: 10000 params: - n_fast_ma: 20 - n_slow_ma: 200 + G: 20 symbols: - - NGV0 FUT NYMEX + - CLV0 FUT NYMEX OrderPerIntervalStrategy: - active: False + active: false capital: 50000 - order_start_time: 09:40:00 # pad 0 in front - order_end_time: 15:50:00 - single_trade_limit: 3 - total_trade_limit: 15 - total_cancel_limit: 5 - total_active_limit: 2 - total_loss_limit: 500 + order_end_time: 57000 + order_start_time: 09:40:00 params: tick_trigger_threshold: 6000 + single_trade_limit: 3 symbols: - #- SPY STK SMART - #- AAPL STK SMART - #- AMZN STK SMART - - ESU0 FUT GLOBEX - #- NGV0 FUT NYMEX \ No newline at end of file + - ESU0 FUT GLOBEX + total_active_limit: 2 + total_cancel_limit: 5 + total_loss_limit: 500 + total_trade_limit: 15 +theme: dark +total_active_limit: 3 +total_cancel_limit: 10 +total_loss_limit: 5000 +total_trade_limit: 20 diff --git a/examples/prepare_trading_session.py b/examples/prepare_trading_session.py index 69cf57e..0ebe0d6 100644 --- a/examples/prepare_trading_session.py +++ b/examples/prepare_trading_session.py @@ -10,14 +10,21 @@ import time from datetime import datetime, timedelta import pandas as pd +import yaml import numpy as np import logging def run(args): target_path = args.path + with open(args.config_file, encoding='utf8') as fd: + config = yaml.safe_load(fd) # DualThrustStrategy + # 1. config + config['strategy']['DualThrustStrategy']['params']['G'] = 20 + + # 2. data sname = 'dual_thrust' index = pd.date_range('1/1/2020', periods=100, freq='T') s1 = pd.Series(range(100), index=index) @@ -27,11 +34,16 @@ def run(args): df = pd.concat([s1, s2], axis=1) df.to_csv(f'{target_path}{sname}.csv', header=True, index=True) + # save config + with open(args.config_file, 'w') as file: + yaml.dump(config, file) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Trading session preparation') parser.add_argument('--date', help='today') - parser.add_argument('--path', help='today', default='./strategy/') + parser.add_argument('-f', '--config_file', dest='config_file', default='./config_live.yaml', help='config yaml file') + parser.add_argument('-p', '--path', dest='path', default='./strategy/', help='data path') args = parser.parse_args() run(args)