Harden env save against empty numerics; default coin margin and hedge off.

Reject blank float/int/select on save and parse env with safe helpers so options config edits cannot crash into 502; default OKX_TRADE_MODE=options and OKX_OPTIONS_MARGIN_MODE=coin.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-21 18:04:19 +08:00
parent d1e6d841c9
commit 6215d0975d
6 changed files with 129 additions and 62 deletions
+2 -2
View File
@@ -34,9 +34,9 @@ def _env_bool(key: str, default: bool = False) -> bool:
def _env_float(key: str, default: float) -> float:
try:
return float(os.getenv(key, str(default)))
return float(os.getenv(key) or default)
except (TypeError, ValueError):
return default
return float(default)
def attach_options_templates(app: Flask, repo_root: str) -> None: