Skip to content

Commit

Permalink
prepare update config
Browse files Browse the repository at this point in the history
  • Loading branch information
letianzj committed Sep 3, 2020
1 parent 1199bf1 commit 7696f72
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
60 changes: 27 additions & 33 deletions examples/config_live.yaml
Original file line number Diff line number Diff line change
@@ -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
- 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
14 changes: 13 additions & 1 deletion examples/prepare_trading_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 7696f72

Please sign in to comment.