From 4e006e59fd7821e4eb08d7b97e424f6f3a928bfd Mon Sep 17 00:00:00 2001 From: msincenselee Date: Sun, 16 May 2021 10:46:25 +0800 Subject: [PATCH] [update] --- prod/jobs/check_dominat_symbol.py | 16 ++++++++++++++-- prod/jobs/refill_binance_future_bars.py | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/prod/jobs/check_dominat_symbol.py b/prod/jobs/check_dominat_symbol.py index 1aebad10..2b4b9bf2 100644 --- a/prod/jobs/check_dominat_symbol.py +++ b/prod/jobs/check_dominat_symbol.py @@ -16,8 +16,10 @@ os.environ["VNPY_TESTING"] = "1" from vnpy.data.tdx.tdx_future_data import * 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 len(sys.argv) < 2: @@ -86,7 +88,7 @@ if __name__ == "__main__": next_mi_symbol = new_mi_symbol 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: print(f'{account_name}策略配置:长合约{full_symbol}, 主力长合约{new_full_symbol},不更新') continue @@ -103,6 +105,16 @@ if __name__ == "__main__": setting.update({'vt_symbol': new_vt_symbol}) send_wx_msg(f'{account_name}{strategy_name} 主力合约更换:{vt_symbol} => {new_vt_symbol} ') 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: save_json(setting_file_path, settings) diff --git a/prod/jobs/refill_binance_future_bars.py b/prod/jobs/refill_binance_future_bars.py index 2c9d6c78..88598059 100644 --- a/prod/jobs/refill_binance_future_bars.py +++ b/prod/jobs/refill_binance_future_bars.py @@ -18,10 +18,10 @@ from vnpy.trader.utility import get_csv_last_dt, append_data # 获取币安合约交易的所有期货合约 future_data = BinanceFutureData() + +# 获取全量合约信息 +future_data.save_contracts() contracts = BinanceFutureData.load_contracts() -if len(contracts) == 0: - future_data.save_contracts() - contracts = BinanceFutureData.load_contracts() # 开始下载日期 start_date = '20190101'