tqsdk实盘

This commit is contained in:
2025-07-10 15:07:31 +08:00
parent 4c243a4b47
commit 5de1a43b02
26 changed files with 12462 additions and 17535 deletions

View File

@@ -159,11 +159,11 @@ class SimpleLimitBuyStrategyLong(Strategy):
# 只有在没有持仓 (current_pos_volume == 0) 且没有待处理订单 (not pending_orders_after_cancel)
# 且K线历史足够长时才考虑开仓
bar_history = self.get_bar_history()
if current_pos_volume == 0 and len(bar_history) > 10:
if current_pos_volume == 0 and len(bar_history) > 16:
# 获取前1根K线 (倒数第二根) 和前7根K线 (队列中最老的一根)
bar_1_ago = bar_history[-2]
bar_7_ago = bar_history[-8]
bar_1_ago = bar_history[-8]
bar_7_ago = bar_history[-15]
# 计算历史 K 线的 Range
range_1_ago = bar_1_ago.high - bar_1_ago.low
@@ -387,11 +387,11 @@ class SimpleLimitBuyStrategyShort(Strategy):
# 只有在没有持仓 (current_pos_volume == 0) 且没有待处理订单 (not pending_orders_after_cancel)
# 且K线历史足够长时才考虑开仓
bar_history = self.get_bar_history()
if current_pos_volume == 0 and len(bar_history) > 10:
if current_pos_volume == 0 and len(bar_history) > 16:
# 获取前1根K线 (倒数第二根) 和前7根K线 (队列中最老的一根)
bar_1_ago = bar_history[-2]
bar_7_ago = bar_history[-8]
bar_1_ago = bar_history[-8]
bar_7_ago = bar_history[-15]
# 计算历史 K 线的 Range
range_1_ago = bar_1_ago.high - bar_1_ago.low
@@ -660,11 +660,11 @@ class SimpleLimitBuyStrategy(Strategy):
return # 平仓后本K线不再进行开仓判断
bar_history = self.get_bar_history()
if current_pos_volume == 0 and len(bar_history) > 10:
if current_pos_volume == 0 and len(bar_history) > 16:
# 获取前1根K线 (倒数第二根) 和前7根K线 (队列中最老的一根)
bar_1_ago = bar_history[-2]
bar_7_ago = bar_history[-8]
bar_1_ago = bar_history[-8]
bar_7_ago = bar_history[-15]
print(bar_1_ago, bar_7_ago)