顶栏加固:交易账户/期权字段缺省与币金额格式化吞掉Undefined,降低再发500风险
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -121,7 +121,8 @@ def _fmt_coin_amount(v: float | None, *, min_amt: float = 1e-6) -> str | None:
|
|||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
n = float(v)
|
n = float(v)
|
||||||
except (TypeError, ValueError):
|
except Exception:
|
||||||
|
# Jinja Undefined 等也吞掉,避免顶栏 float(Undefined) → HTTP 500
|
||||||
return None
|
return None
|
||||||
if n < min_amt:
|
if n < min_amt:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
{% set _trading_margin_mode = 'coin' if _coin_margin else 'usdc' %}
|
{% set _trading_margin_mode = 'coin' if _coin_margin else 'usdc' %}
|
||||||
<span class="inst-phone-chip"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
<span class="inst-phone-chip"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
||||||
<em>交易</em>
|
<em>交易</em>
|
||||||
<b data-funds-field="current-capital">{{ trading_account_label(current_capital, options_trading_eth, options_trading_btc, margin_mode=_trading_margin_mode) }}</b>
|
<b data-funds-field="current-capital">{{ trading_account_label(current_capital, options_trading_eth|default(none), options_trading_btc|default(none), margin_mode=_trading_margin_mode) }}</b>
|
||||||
</span>
|
</span>
|
||||||
<span class="inst-phone-chip"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
<span class="inst-phone-chip"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
||||||
<em>资金</em>
|
<em>资金</em>
|
||||||
|
|||||||
@@ -34,16 +34,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="stat-strip-item"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
<div class="stat-strip-item"{% if not _show_perp %} style="display:none"{% endif %} data-perp-funds="1">
|
||||||
<div class="label">交易账户</div>
|
<div class="label">交易账户</div>
|
||||||
<div class="value" id="current-capital" data-funds-field="current-capital">{{ trading_account_label(current_capital, options_trading_eth, options_trading_btc, margin_mode=_trading_margin_mode) }}</div>
|
<div class="value" id="current-capital" data-funds-field="current-capital">{{ trading_account_label(current_capital, options_trading_eth|default(none), options_trading_btc|default(none), margin_mode=_trading_margin_mode) }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% if options_enabled and not _coin_margin %}
|
{% if options_enabled and not _coin_margin %}
|
||||||
<div class="stat-strip-item" data-options-funds="1">
|
<div class="stat-strip-item" data-options-funds="1">
|
||||||
<div class="label">期权资金账户</div>
|
<div class="label">期权资金账户</div>
|
||||||
<div class="value" id="options-funding-usdc" data-funds-field="options-funding-usdc">{{ options_funding_label(options_funding_usdc, options_funding_usdt, options_funding_eth, options_margin_mode, options_underly|default('ETH')) }}</div>
|
<div class="value" id="options-funding-usdc" data-funds-field="options-funding-usdc">{{ options_funding_label(options_funding_usdc|default(none), options_funding_usdt|default(none), options_funding_eth|default(none), options_margin_mode|default(none), options_underly|default('ETH')) }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat-strip-item" data-options-funds="1">
|
<div class="stat-strip-item" data-options-funds="1">
|
||||||
<div class="label">期权交易账户</div>
|
<div class="label">期权交易账户</div>
|
||||||
<div class="value" id="options-trading-usdc" data-funds-field="options-trading-usdc">{{ options_funding_label(options_trading_usdc, options_trading_usdt, options_trading_eth, options_margin_mode, options_underly|default('ETH')) }}</div>
|
<div class="value" id="options-trading-usdc" data-funds-field="options-trading-usdc">{{ options_funding_label(options_trading_usdc|default(none), options_trading_usdt|default(none), options_trading_eth|default(none), options_margin_mode|default(none), options_underly|default('ETH')) }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="stat-strip-item stat-strip-item--pnl">
|
<div class="stat-strip-item stat-strip-item--pnl">
|
||||||
|
|||||||
Reference in New Issue
Block a user