修复期权到期结算漏推企业微信:页面同步与模拟盘结算一并通知。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-06 16:08:49 +08:00
parent d743185f05
commit 95e713e9e6
4 changed files with 101 additions and 1 deletions
+32
View File
@@ -58,6 +58,38 @@ def ensure_options_notify_columns(conn: sqlite3.Connection) -> None:
pass
_BOUND_NOTIFY_CFG: dict[str, Any] | None = None
def bind_options_notify_cfg(cfg: dict[str, Any] | None) -> None:
global _BOUND_NOTIFY_CFG
_BOUND_NOTIFY_CFG = cfg
def active_options_notify_cfg(cfg: dict[str, Any] | None = None) -> dict[str, Any]:
if cfg is not None and callable(cfg.get("send_wechat")):
return cfg
if _BOUND_NOTIFY_CFG is not None and callable(_BOUND_NOTIFY_CFG.get("send_wechat")):
return _BOUND_NOTIFY_CFG
import os
from lib.common.wechat_notify_lib import send_wechat_webhook
webhook = (os.getenv("WECHAT_WEBHOOK") or "").strip()
try:
timeout = int(float(os.getenv("WECHAT_TIMEOUT_SECONDS") or "10"))
except (TypeError, ValueError):
timeout = 10
label = (
os.getenv("OKX_OPTIONS_ACCOUNT_LABEL") or os.getenv("OKX_ACCOUNT_LABEL") or "OKX期权"
).strip()
def send(content: str) -> None:
send_wechat_webhook(webhook, content, timeout=timeout)
return {"send_wechat": send, "account_label": label}
def notify_options_send(cfg: dict[str, Any], content: str) -> bool:
send: Optional[Callable[[str], Any]] = cfg.get("send_wechat")
if not callable(send):