模拟盘无 API Key 时复盘K线改为优先走 OKX 公开行情接口。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-09-15 12:16:06 +08:00
parent d6bb99b5bb
commit d16821c7b7
3 changed files with 172 additions and 16 deletions
+13 -1
View File
@@ -12,7 +12,19 @@ from lib.sim.wallets_lib import InsufficientFunds, SimWallets
def _now() -> str:
return datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
"""业务时区墙钟(默认 Asia/Shanghai);勿用 utcnow,否则复盘K线标记会偏 8 小时."""
try:
from lib.options.options_time_lib import options_app_now_str
return options_app_now_str()
except Exception:
from zoneinfo import ZoneInfo
tz = ZoneInfo(
(os.getenv("APP_TIMEZONE") or os.getenv("TZ") or "Asia/Shanghai").strip()
or "Asia/Shanghai"
)
return datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
def _ticker_bid_ask(exchange: Any, symbol: str) -> tuple[float, float]: