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:
@ -86,7 +88,7 @@ if __name__ == "__main__":
next_mi_symbol = new_mi_symbol next_mi_symbol = new_mi_symbol
new_vt_symbol = '.'.join([new_mi_symbol, new_exchange]) new_vt_symbol = '.'.join([new_mi_symbol, new_exchange])
new_full_symbol =get_full_symbol(new_mi_symbol).upper() new_full_symbol = get_full_symbol(new_mi_symbol).upper()
if full_symbol >= new_full_symbol: if full_symbol >= new_full_symbol:
print(f'{account_name}策略配置:长合约{full_symbol} 主力长合约{new_full_symbol},不更新') print(f'{account_name}策略配置:长合约{full_symbol} 主力长合约{new_full_symbol},不更新')
continue continue
@ -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,10 +18,10 @@ from vnpy.trader.utility import get_csv_last_dt, append_data
# 获取币安合约交易的所有期货合约 # 获取币安合约交易的所有期货合约
future_data = BinanceFutureData() future_data = BinanceFutureData()
# 获取全量合约信息
future_data.save_contracts()
contracts = BinanceFutureData.load_contracts() contracts = BinanceFutureData.load_contracts()
if len(contracts) == 0:
future_data.save_contracts()
contracts = BinanceFutureData.load_contracts()
# 开始下载日期 # 开始下载日期
start_date = '20190101' start_date = '20190101'