diff --git a/tests/renko/ui_renko_reverse_klines.py b/tests/renko/ui_renko_reverse_klines.py index ae68ff2e..e193489f 100644 --- a/tests/renko/ui_renko_reverse_klines.py +++ b/tests/renko/ui_renko_reverse_klines.py @@ -36,7 +36,9 @@ if __name__ == '__main__': ], "sub_indicators": [ "atr" - ] + ], + "dist_file": "log/renko_reverse_v1_J99_dist.csv", + "dist_include_list": ["M15 new signal"] }, "Renko_K3": { @@ -53,8 +55,10 @@ if __name__ == '__main__': "sub_indicators": [ "sk", "sd", - ] - + ], + "trade_list_file": "log/renko_reverse_test_0229_1638_J99_trade_list.csv", + "dist_file": "log/renko_reverse_v1_J99_dist.csv", + "dist_include_list": ["new signal"] } } display_multi_grid(kline_settings) diff --git a/vnpy/app/cta_strategy_pro/cta_grid_trade.py b/vnpy/app/cta_strategy_pro/cta_grid_trade.py index d857c523..a2e065fc 100644 --- a/vnpy/app/cta_strategy_pro/cta_grid_trade.py +++ b/vnpy/app/cta_strategy_pro/cta_grid_trade.py @@ -261,7 +261,7 @@ class CtaGridTrade(CtaComponent): opened_volume = grid.volume else: pending_close_list = pending_close_list + u'[{}{}->{},sp:{},v:{}/{}];' \ - .format(t, grid.open_price, grid.close_price, grid.volume, grid.stop_price, + .format(t, grid.open_price, grid.close_price, grid.stop_price, grid.volume, grid.traded_volume) opened_volume = grid.volume - grid.traded_volume diff --git a/vnpy/app/cta_strategy_pro/template.py b/vnpy/app/cta_strategy_pro/template.py index ab644d56..e461d178 100644 --- a/vnpy/app/cta_strategy_pro/template.py +++ b/vnpy/app/cta_strategy_pro/template.py @@ -890,7 +890,7 @@ class CtaProTemplate(CtaTemplate): return none_mi_price = max(none_mi_tick.last_price, none_mi_tick.bid_price_1) - grid = copy.copy(none_mi_grid) + grid = copy(none_mi_grid) # 委托卖出非主力合约 vt_orderids = self.sell(price=none_mi_price, volume=none_mi_grid.volume, vt_symbol=none_mi_symbol, @@ -953,7 +953,7 @@ class CtaProTemplate(CtaTemplate): return none_mi_price = max(none_mi_tick.last_price, none_mi_tick.bid_price_1) - grid = copy.copy(none_mi_grid) + grid = copy(none_mi_grid) # 委托平空非主力合约 vt_orderids = self.cover(price=none_mi_price, volume=none_mi_grid.volume, vt_symbol=self.vt_symbol, grid=none_mi_grid) @@ -1244,7 +1244,7 @@ class CtaProFutureTemplate(CtaProTemplate): old_order = self.active_orders[order.vt_orderid] self.write_log(u'{} 委托信息:{}'.format(order.vt_orderid, old_order)) old_order['traded'] = order.traded - order_vt_symbol = copy.copy(old_order['vt_symbol']) + order_vt_symbol = copy(old_order['vt_symbol']) order_volume = old_order['volume'] - old_order['traded'] if order_volume <= 0: msg = u'{} {}{}需重新开仓数量为{},不再开仓' \ @@ -1393,7 +1393,7 @@ class CtaProFutureTemplate(CtaProTemplate): self.write_log(u'{} 订单信息:{}'.format(order.vt_orderid, old_order)) old_order['traded'] = order.traded # order_time = old_order['order_time'] - order_symbol = copy.copy(old_order['symbol']) + order_symbol = copy(old_order['symbol']) order_volume = old_order['volume'] - old_order['traded'] if order_volume <= 0: msg = u'{} {}{}重新平仓数量为{},不再平仓' \ @@ -1709,7 +1709,7 @@ class CtaProFutureTemplate(CtaProTemplate): self.save_dist(dist_record) # 创建一个对锁网格 - lock_grid = copy.copy(grid) + lock_grid = copy(grid) # 网格类型, => 锁仓格 lock_grid.type = LOCK_GRID lock_grid.id = str(uuid.uuid1()) @@ -1798,7 +1798,7 @@ class CtaProFutureTemplate(CtaProTemplate): dist_record['operation'] = 'add long lock[short]' self.save_dist(dist_record) # 创建一个对锁网格 - lock_grid = copy.copy(grid) + lock_grid = copy(grid) # 网格类型, => 锁仓格 lock_grid.type = LOCK_GRID lock_grid.id = str(uuid.uuid1()) @@ -1912,7 +1912,7 @@ class CtaProFutureTemplate(CtaProTemplate): elif g.volume > open_volume: self.write_log(u'第一个网格持仓数量大于需求:g.volume:{},open_volume:{}' .format(g.volume, open_volume)) - remain_grid = copy.copy(g) + remain_grid = copy(g) g.volume = open_volume remain_grid.volume -= open_volume remain_grid.id = uuid.uuid1() @@ -1958,7 +1958,7 @@ class CtaProFutureTemplate(CtaProTemplate): elif g.volume > open_volume: self.write_log(u'第一个空单网格持仓数量大于需求:g.volume:{},open_volume:{}' .format(g.volume, open_volume)) - remain_grid = copy.copy(g) + remain_grid = copy(g) g.volume = open_volume remain_grid.volume -= open_volume remain_grid.id = uuid.uuid1() diff --git a/vnpy/trader/ui/kline/kline.py b/vnpy/trader/ui/kline/kline.py index 054fccaa..26e1d54b 100644 --- a/vnpy/trader/ui/kline/kline.py +++ b/vnpy/trader/ui/kline/kline.py @@ -1492,22 +1492,25 @@ class GridKline(QtWidgets.QWidget): # 加载交易信号 trade_list_file = kline_setting.get('trade_list_file', None) if trade_list_file and os.path.exists(trade_list_file): + print(f'loading {trade_list_file}') df_trade = pd.read_csv(trade_list_file) self.kline_dict[kline_name].add_signals(df_trade) # 加载tns tns_file = kline_setting.get('tns_file', None) if tns_file and os.path.exists(tns_file): + print(f'loading {tns_file}') df_tns = pd.read_csv(tns_file) self.kline_dict[kline_name].add_trans_df(df_tns) # 加载policy 逻辑记录 dist_file = kline_setting.get('dist_file', None) if dist_file and os.path.exists(dist_file): + print(f'loading {dist_file}') df_markup = pd.read_csv(dist_file) df_markup = df_markup[['datetime', 'price', 'operation']] df_markup.rename(columns={'operation': 'markup'}, inplace=True) - self.kline_dict['m30'].add_markups(df_markup=df_markup, + self.kline_dict[kline_name].add_markups(df_markup=df_markup, include_list=kline_setting.get('dist_include_list', []), exclude_list=['buy', 'short', 'sell', 'cover'])