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
+9 -9
View File
@@ -1,9 +1,9 @@
"""Gate.io ccxt 构造ccxt 4.x 起类名由 gateio 改为 gate)。"""
from __future__ import annotations
import ccxt
def gate_ccxt_class():
"""返回 ccxt Gate 交易所类兼容旧版 gateio 名称)。"""
return getattr(ccxt, "gate", None) or ccxt.gateio
"""Gate.io ccxt 构造(ccxt 4.x 起类名由 gateio 改为 gate)."""
from __future__ import annotations
import ccxt
def gate_ccxt_class():
"""返回 ccxt Gate 交易所类(兼容旧版 gateio 名称)."""
return getattr(ccxt, "gate", None) or ccxt.gateio
+3 -3
View File
@@ -1,4 +1,4 @@
"""Gate 平仓历史匹配fetch_positions_history),供 reconcile / 中控全平同步共用"""
"""Gate 平仓历史匹配(fetch_positions_history),供 reconcile / 中控全平同步共用."""
from __future__ import annotations
@@ -21,8 +21,8 @@ def pick_gate_position_close(
max_close_delta_ms: int = 25 * 60 * 1000,
) -> dict | None:
"""
从 Gate 平仓历史列表中选取与 symbol/direction/开仓时间最匹配的一条
返回 normalize 后的 dict含 close_mspnlsync_key 等),无匹配则 None
从 Gate 平仓历史列表中选取与 symbol/direction/开仓时间最匹配的一条.
返回 normalize 后的 dict(含 close_ms,pnl,sync_key 等),无匹配则 None.
"""
if not hist:
return None
+5 -5
View File
@@ -1,12 +1,12 @@
"""Gate.io 资金划转crypto_monitor_gate 共用)。"""
"""Gate.io 资金划转(crypto_monitor_gate 共用)."""
from __future__ import annotations
from typing import Any, Callable, Optional
INVALID_KEY_HINT = (
"常见原因① GATE_API_SECRET 错误或 .env 里多了空格/换行② IP 白名单未包含当前服务器出口 IP"
"③ Gate「交易账户」类 API Key 若不支持钱包接口则无法走账户内划转 POST /wallet/transfers需在官网确认该 Key 类型是否开放划转);"
"④ Key 已重置或权限变更你已勾选现货/统一账户仍报错时优先核对 Secret 与白名单"
".常见原因:① GATE_API_SECRET 错误或 .env 里多了空格/换行;② IP 白名单未包含当前服务器出口 IP;"
"③ Gate「交易账户」类 API Key 若不支持钱包接口则无法走账户内划转 POST /wallet/transfers(需在官网确认该 Key 类型是否开放划转);"
"④ Key 已重置或权限变更.你已勾选现货/统一账户仍报错时,优先核对 Secret 与白名单."
)
@@ -41,7 +41,7 @@ def execute_transfer_usdt(
def count_auto_transfer_blockers(conn, *, count_order_monitors: Callable[[Any], int]) -> int:
"""自动划转持仓守卫order_monitors active + 趋势回调已开仓计划"""
"""自动划转持仓守卫:order_monitors active + 趋势回调已开仓计划."""
n = int(count_order_monitors(conn) or 0)
if n > 0:
return n
+13 -13
View File
@@ -1,4 +1,4 @@
"""OKX USDⓈ 期权 API 封装主账户 exchange_options 专用)。"""
"""OKX USDⓈ 期权 API 封装(主账户 exchange_options 专用)."""
from __future__ import annotations
import json
@@ -19,7 +19,7 @@ from lib.options.options_pricing_lib import (
_OKX_OPTION_ERR_ZH: dict[str, str] = {
"51018": "期权账户不能持有净空头头寸",
"51019": "期权买入须使用逐仓模式全仓模式下不能持有多头净头寸",
"51019": "期权买入须使用逐仓模式(全仓模式下不能持有多头净头寸)",
}
_OPTIONS_BALANCE_CACHE: dict[str, Any] = {"updated_at": 0.0, "data": None}
@@ -59,7 +59,7 @@ def _okx_trade_error_message(exc: BaseException | None = None, resp: Any = None)
def td_mode_for_option_buy(configured: str | None = None) -> str:
"""OKX 买入期权多头必须使用逐仓"""
"""OKX 买入期权(多头)必须使用逐仓."""
mode = (configured or "isolated").strip().lower()
return "isolated" if mode == "cross" else mode or "isolated"
@@ -94,7 +94,7 @@ def _safe_float(v: Any) -> float | None:
def round_option_px(px: float, tick_sz: Any, side: str) -> float:
"""按 OKX tickSz 对齐买入向上取整卖出向下取整"""
"""按 OKX tickSz 对齐:买入向上取整,卖出向下取整."""
tick = _safe_float(tick_sz)
if tick is None or tick <= 0 or px <= 0:
return px
@@ -132,7 +132,7 @@ def _resolve_chain_quote(
strike: float,
index_px: float,
) -> dict[str, Any]:
"""链列表报价卖一缺失时用标记价/内在价值估算深度实值常见无卖一)。"""
"""链列表报价:卖一缺失时用标记价/内在价值估算(深度实值常见无卖一)."""
tick_sz = meta.get("tickSz")
ask = _safe_float(ticker.get("askPx"))
bid = _safe_float(ticker.get("bidPx"))
@@ -209,7 +209,7 @@ def _pos_side_from_position(pos: dict[str, Any] | None) -> str | None:
def inst_family_from_inst_id(inst_id: str) -> str | None:
"""从 instId 解析 instFamily如 ETH-USD_UM-260707-1790-C → ETH-USD_UM"""
"""从 instId 解析 instFamily,如 ETH-USD_UM-260707-1790-C → ETH-USD_UM."""
parts = (inst_id or "").strip().split("-")
if len(parts) < 4:
return None
@@ -217,7 +217,7 @@ def inst_family_from_inst_id(inst_id: str) -> str | None:
def option_fields_from_inst_id(inst_id: str) -> tuple[str | None, float | None]:
"""从 instId 解析 optType 与 strike如 ETH-USD_UM-260709-1700-P"""
"""从 instId 解析 optType 与 strike,如 ETH-USD_UM-260709-1700-P."""
parts = (inst_id or "").strip().split("-")
if len(parts) < 2:
return None, None
@@ -228,7 +228,7 @@ def option_fields_from_inst_id(inst_id: str) -> tuple[str | None, float | None]:
def expiry_ms_from_inst_id(inst_id: str) -> int | None:
"""从 instId 日期段解析到期时刻OKX 期权默认 08:00 UTC)。"""
"""从 instId 日期段解析到期时刻(OKX 期权默认 08:00 UTC)."""
parts = (inst_id or "").strip().split("-")
if len(parts) < 3:
return None
@@ -246,7 +246,7 @@ def expiry_ms_from_inst_id(inst_id: str) -> int | None:
def normalize_option_exp_ms(exp_time: Any, inst_id: str = "") -> int | None:
"""统一期权到期毫秒时间戳优先 API expTime否则从 instId 推算)。"""
"""统一期权到期毫秒时间戳(优先 API expTime,否则从 instId 推算)."""
raw = _safe_float(exp_time)
if raw is not None and raw > 0:
ms = int(raw)
@@ -345,7 +345,7 @@ def options_header_balances(
*,
force: bool = False,
) -> tuple[float | None, float | None, float | None]:
"""顶栏三格交易 USDC资金 USDC资金 USDT单次拉取 + 缓存)。"""
"""顶栏三格:交易 USDC,资金 USDC,资金 USDT(单次拉取 + 缓存)."""
bal = fetch_options_balances(ex, force=force)
def _round(v: Any) -> float | None:
@@ -645,7 +645,7 @@ def fetch_option_positions(ex: ccxt.okx) -> list[dict[str, Any]]:
def fetch_options_unrealized_pnl_usdc(ex: ccxt.okx) -> float | None:
"""期权持仓未实现盈亏合计USDC统计口径与 USDT 1:1)。"""
"""期权持仓未实现盈亏合计(USDC,统计口径与 USDT 1:1)."""
total = 0.0
found = False
for pos in fetch_option_positions(ex):
@@ -752,7 +752,7 @@ def spot_market_swap_usdt_usdc(
direction: str,
amount: float,
) -> dict[str, Any]:
"""现货市价兑换 USDC-USDTdirection: usdt_to_usdc | usdc_to_usdt"""
"""现货市价兑换 USDC-USDT.direction: usdt_to_usdc | usdc_to_usdt."""
if amount <= 0:
return {"ok": False, "msg": "数量须大于 0"}
d = (direction or "").lower()
@@ -798,7 +798,7 @@ def transfer_main_sub_account(
from_account: str = "funding",
to_account: str = "funding",
) -> dict[str, Any]:
"""主账户与子账户之间划转须主账户 API)。"""
"""主账户与子账户之间划转(须主账户 API)."""
if amount <= 0:
return {"ok": False, "msg": "划转金额须大于 0"}
sub = (sub_acct or "").strip()
+6 -6
View File
@@ -1,6 +1,6 @@
"""
OKX 挂单聚合普通委托 + 算法单conditional / oco / trigger)。
交易所 App「止盈止损」页多为 orders-algo-pending仅 fetch_open_orders 默认拿不到
OKX 挂单聚合:普通委托 + 算法单(conditional / oco / trigger).
交易所 App「止盈止损」页多为 orders-algo-pending,仅 fetch_open_orders 默认拿不到.
"""
from __future__ import annotations
@@ -22,7 +22,7 @@ def _okx_algo_cancel_id(order_id: str) -> str:
def _okx_order_needs_stop_cancel_param(order: dict) -> bool:
"""OKX 条件/算法单撤单须 params.stop=True否则 cancel_order 走普通单接口会静默失败"""
"""OKX 条件/算法单撤单须 params.stop=True,否则 cancel_order 走普通单接口会静默失败."""
if not isinstance(order, dict):
return False
info = order.get("info") or {}
@@ -40,7 +40,7 @@ def _okx_order_needs_stop_cancel_param(order: dict) -> bool:
def fetch_okx_all_open_orders(ex, exchange_symbol: str) -> list[dict]:
"""合并 OKX 普通挂单与算法挂单去重)。"""
"""合并 OKX 普通挂单与算法挂单(去重)."""
if not exchange_symbol:
return []
ex.load_markets()
@@ -80,8 +80,8 @@ def fetch_okx_all_open_orders(ex, exchange_symbol: str) -> list[dict]:
def cancel_okx_all_open_orders(ex, exchange_symbol: str) -> int:
"""
撤销某合约全部挂单普通 + 条件/算法)。
OKX 止盈止损在 orders-algo-pending必须用 stop=True 才能撤掉
撤销某合约全部挂单(普通 + 条件/算法).
OKX 止盈止损在 orders-algo-pending,必须用 stop=True 才能撤掉.
"""
if not exchange_symbol:
return 0