fix: skip first 3 cycles after cold start to prevent duplicate paper trades
This commit is contained in:
parent
d0e626a437
commit
95b45d0f07
@ -665,6 +665,7 @@ def main():
|
|||||||
|
|
||||||
last_1m_save = {}
|
last_1m_save = {}
|
||||||
cycle = 0
|
cycle = 0
|
||||||
|
warmup_cycles = 3 # 启动后跳过前3轮(45秒),避免冷启动信号开仓
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -687,8 +688,8 @@ def main():
|
|||||||
|
|
||||||
if result.get("signal"):
|
if result.get("signal"):
|
||||||
logger.info(f"[{sym}] 🚨 信号: {result['signal']} score={result['score']} price={result['price']:.1f}")
|
logger.info(f"[{sym}] 🚨 信号: {result['signal']} score={result['score']} price={result['price']:.1f}")
|
||||||
# 模拟盘开仓(需开关开启)
|
# 模拟盘开仓(需开关开启 + 跳过冷启动)
|
||||||
if PAPER_TRADING_ENABLED:
|
if PAPER_TRADING_ENABLED and warmup_cycles <= 0:
|
||||||
existing_dir = paper_get_active_direction(sym)
|
existing_dir = paper_get_active_direction(sym)
|
||||||
new_dir = result["signal"]
|
new_dir = result["signal"]
|
||||||
|
|
||||||
@ -710,6 +711,10 @@ def main():
|
|||||||
# 模拟盘持仓检查由paper_monitor.py通过WebSocket实时处理,这里不再检查
|
# 模拟盘持仓检查由paper_monitor.py通过WebSocket实时处理,这里不再检查
|
||||||
|
|
||||||
cycle += 1
|
cycle += 1
|
||||||
|
if warmup_cycles > 0:
|
||||||
|
warmup_cycles -= 1
|
||||||
|
if warmup_cycles == 0:
|
||||||
|
logger.info("冷启动保护期结束,模拟盘开仓已启用")
|
||||||
if cycle % 60 == 0:
|
if cycle % 60 == 0:
|
||||||
for sym, state in states.items():
|
for sym, state in states.items():
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user