This commit is contained in:
msincenselee 2021-05-16 10:46:25 +08:00
parent 5ddbf6541a
commit 4e006e59fd
2 changed files with 17 additions and 5 deletions

View File

@ -16,8 +16,10 @@ os.environ["VNPY_TESTING"] = "1"
from vnpy.data.tdx.tdx_future_data import * from vnpy.data.tdx.tdx_future_data import *
from vnpy.trader.util_wechat import send_wx_msg from vnpy.trader.util_wechat import send_wx_msg
from vnpy.trader.utility import load_json, save_json from vnpy.trader.utility import load_json, save_json, append_data
log_csv_name = 'dominat_change_history.csv'
field_names = ['account_name', 'strategy_name', 'old_vt_symbol', 'new_vt_symbol', 'datetime']
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) < 2: if len(sys.argv) < 2:
@ -103,6 +105,16 @@ if __name__ == "__main__":
setting.update({'vt_symbol': new_vt_symbol}) setting.update({'vt_symbol': new_vt_symbol})
send_wx_msg(f'{account_name}{strategy_name} 主力合约更换:{vt_symbol} => {new_vt_symbol} ') send_wx_msg(f'{account_name}{strategy_name} 主力合约更换:{vt_symbol} => {new_vt_symbol} ')
changed = True changed = True
# 写入日志csv供后续检查
append_data(file_name=log_csv_name,
dict_data={
'account_name': account_name,
'strategy_name': strategy_name,
'old_vt_symbol': vt_symbol,
'new_vt_symbol': new_vt_symbol,
'datetime': datetime.now().strftime('%Y-%m-%d %H:%M:%S')
},
field_names=field_names)
if changed: if changed:
save_json(setting_file_path, settings) save_json(setting_file_path, settings)

View File

@ -18,8 +18,8 @@ from vnpy.trader.utility import get_csv_last_dt, append_data
# 获取币安合约交易的所有期货合约 # 获取币安合约交易的所有期货合约
future_data = BinanceFutureData() future_data = BinanceFutureData()
contracts = BinanceFutureData.load_contracts()
if len(contracts) == 0: # 获取全量合约信息
future_data.save_contracts() future_data.save_contracts()
contracts = BinanceFutureData.load_contracts() contracts = BinanceFutureData.load_contracts()