Normalize fullwidth punctuation to ASCII across codebase.

Add scripts/normalize_ambiguous_unicode.py; fix corrupted patch_instance_theme_templates.py. Preserves curly quotes in string literals; removes Git homoglyph warnings on .env.example.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-08 23:42:26 +08:00
parent aaa72c7961
commit b733e551a0
392 changed files with 71522 additions and 71369 deletions
+17 -17
View File
@@ -1,4 +1,4 @@
"""OKX USDⓈ 期权张数与权利金计算"""
"""OKX USDⓈ 期权:张数与权利金计算."""
from __future__ import annotations
import math
@@ -24,12 +24,12 @@ def min_sz_from_meta(meta: dict[str, Any] | None) -> int:
def premium_per_sheet(quote_per_unit: float, ct_mult: float = 0.01) -> float:
"""报价为每 1 ETH/BTC每张权利金 = 报价 × ctMult"""
"""报价为每 1 ETH/BTC;每张权利金 = 报价 × ctMult."""
return float(quote_per_unit) * float(ct_mult)
def format_quote_liquidity(px: float | None, sz: float | None, *, px_decimals: int = 4) -> str | None:
"""盘口展示价格/张数如 17.2/150"""
"""盘口展示:价格/张数,如 17.2/150."""
if px is None:
return None
try:
@@ -72,8 +72,8 @@ def calc_order_size(
budget_cap: float | None = None,
) -> dict[str, Any]:
"""
返回 sheets, eth_amount, total_premium
mode: budget_full / eth_amount / sheets
返回 sheets, eth_amount, total_premium.
mode: budget_full / eth_amount / sheets.
"""
if quote_per_unit <= 0:
return {"ok": False, "msg": "卖一价无效", "sheets": 0, "eth_amount": 0.0, "total_premium": 0.0}
@@ -89,13 +89,13 @@ def calc_order_size(
return {"ok": False, "msg": "无法计算单张权利金", "sheets": 0, "eth_amount": 0.0, "total_premium": 0.0}
sheets = int(math.floor(eff / per_sheet))
else:
return {"ok": False, "msg": "请指定预算币数量或张数", "sheets": 0, "eth_amount": 0.0, "total_premium": 0.0}
return {"ok": False, "msg": "请指定预算,币数量或张数", "sheets": 0, "eth_amount": 0.0, "total_premium": 0.0}
if sheets < min_sz:
per = premium_per_sheet(quote_per_unit, ct_mult)
return {
"ok": False,
"msg": f"预算不足无法买入 {min_sz}单张约 {per:.4f} USDC",
"msg": f"预算不足,无法买入 {min_sz}(单张约 {per:.4f} USDC)",
"sheets": sheets,
"eth_amount": eth_amount_from_sheets(sheets, ct_mult),
"total_premium": total_premium(quote_per_unit, eth_amount_from_sheets(sheets, ct_mult)),
@@ -134,7 +134,7 @@ def is_shallow_itm(
def option_moneyness(*, opt_type: str, strike: float, index_px: float) -> str:
"""返回 itm / otm / atm"""
"""返回 itm / otm / atm."""
o = (opt_type or "").upper()
if strike is None or index_px is None or index_px <= 0:
return "unknown"
@@ -159,7 +159,7 @@ def expiry_breakeven_from_ask(
ask_px: float | None,
mark_px: float | None = None,
) -> float | None:
"""买入前预估到期平衡权利金按卖一无卖一时回退标记价"""
"""买入前预估到期平衡:权利金按卖一;无卖一时回退标记价."""
prem = ask_px if ask_px is not None and ask_px > 0 else mark_px
return expiry_breakeven_px(opt_type=opt_type, strike=strike, avg_px=prem)
@@ -171,7 +171,7 @@ def expiry_breakeven_px(
avg_px: float | None,
be_px_api: float | None = None,
) -> float | None:
"""到期平衡点持有至到期时标的指数盈亏为 0 的价格优先 OKX bePx"""
"""到期平衡点:持有至到期时标的指数盈亏为 0 的价格.优先 OKX bePx."""
if be_px_api is not None and be_px_api > 0:
return round(float(be_px_api), 2)
if strike is None or avg_px is None:
@@ -195,8 +195,8 @@ def close_breakeven_idx(
ct_mult: float = 0.01,
) -> float | None:
"""
平掉回本标的指数达到该价位时按标记价平仓近似盈亏为 0
优先用 deltaPA 线性外推否则用时间价值近似适合短期轻度实值)。
平掉回本:标的指数达到该价位时,按标记价平仓近似盈亏为 0.
优先用 deltaPA 线性外推,否则用时间价值近似(适合短期轻度实值).
"""
if idx_px is None or mark_px is None or avg_px is None:
return None
@@ -213,7 +213,7 @@ def close_breakeven_idx(
def idx_distance_to_be(idx_px: float | None, be_px: float | None) -> float | None:
"""指数距平衡点正=指数需上涨才到平衡点)。"""
"""指数距平衡点(正=指数需上涨才到平衡点)."""
if idx_px is None or be_px is None:
return None
return round(float(be_px) - float(idx_px), 2)
@@ -225,14 +225,14 @@ def format_options_breakeven_line(
close_be_px: float | None,
idx_px: float | None = None,
) -> str:
"""持仓摘要行到期平衡 / 平掉回本"""
"""持仓摘要行:到期平衡 / 平掉回本."""
parts: list[str] = []
if expiry_be_px is not None:
parts.append(f"到期平衡{expiry_be_px:.0f}")
if close_be_px is not None:
parts.append(f"平掉回本{close_be_px:.0f}")
if idx_px is not None and parts:
return " ".join(parts) + f"指数{idx_px:.0f}"
return " ".join(parts) + f"(指数{idx_px:.0f})"
return " ".join(parts)
@@ -244,7 +244,7 @@ def estimate_expiry_profit_at_index(
entry_px: float | None,
eth_amount: float | None,
) -> float | None:
"""到期测算目标指数价下按内在价值减权利金每 1 币报价 × 币量)。"""
"""到期测算:目标指数价下按内在价值减权利金(每 1 币报价 × 币量)."""
if strike is None or target_idx is None or entry_px is None or eth_amount is None:
return None
if eth_amount <= 0:
@@ -265,7 +265,7 @@ def equivalent_contract_leverage(
eth_amount: float | None,
total_premium: float | None,
) -> float | None:
"""名义价值 / 权利金近似相当于永续合约杠杆倍数测算用)。"""
"""名义价值 / 权利金,近似相当于永续合约杠杆倍数(测算用)."""
if index_px is None or eth_amount is None or total_premium is None:
return None
if eth_amount <= 0 or total_premium <= 0: