修复启动报错:expire_old_plans 在 init_db 前未定义
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -43,6 +43,21 @@ KLINE_CUTOFFS = ["平仓时间", "开仓时间", "当前时间"]
|
||||
def today_str() -> str:
|
||||
return datetime.now(TZ).date().isoformat()
|
||||
|
||||
|
||||
def expire_old_plans():
|
||||
"""当日结束后计划自动失效,保留历史。"""
|
||||
today = today_str()
|
||||
conn = get_db()
|
||||
conn.execute(
|
||||
"UPDATE order_plans SET status='expired' WHERE plan_date < ? AND status IN ('planned', 'active')",
|
||||
(today,),
|
||||
)
|
||||
conn.execute(
|
||||
"UPDATE order_plans SET plan_date=date(created_at) WHERE plan_date IS NULL OR plan_date=''"
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
# —————————————— 设置读写 ——————————————
|
||||
|
||||
def get_db():
|
||||
@@ -211,23 +226,6 @@ def fetch_price(ths_code: str, market_code: str = "", sina_code: str = "") -> Op
|
||||
|
||||
# —————————————— 监控逻辑 ——————————————
|
||||
|
||||
# —————————————— 开单计划(按日) ——————————————
|
||||
|
||||
def expire_old_plans():
|
||||
"""当日结束后计划自动失效,保留历史。"""
|
||||
today = today_str()
|
||||
conn = get_db()
|
||||
conn.execute(
|
||||
"UPDATE order_plans SET status='expired' WHERE plan_date < ? AND status IN ('planned', 'active')",
|
||||
(today,),
|
||||
)
|
||||
conn.execute(
|
||||
"UPDATE order_plans SET plan_date=date(created_at) WHERE plan_date IS NULL OR plan_date=''"
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
||||
def check_order_plans():
|
||||
expire_old_plans()
|
||||
today = today_str()
|
||||
|
||||
Reference in New Issue
Block a user