Use hub exchange instances for calculator contract precision.

Load enabled instances from settings, fetch market info via /api/hub/market, and apply exchange-specific amount and price precision in trend and roll calculators.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-23 18:13:02 +08:00
parent d938bc6c59
commit 5e507d0b66
14 changed files with 1140 additions and 204 deletions
+17
View File
@@ -214,6 +214,7 @@ def install_on_app(
ohlcv_fn=None,
account_fn=None,
volume_rank_fn=None,
market_fn=None,
reconcile_hub_flat_fn=None,
risk_status_fn=None,
user_close_fn=None,
@@ -229,6 +230,7 @@ def install_on_app(
"views": views,
"ohlcv_fn": ohlcv_fn,
"volume_rank_fn": volume_rank_fn,
"market_fn": market_fn,
"reconcile_hub_flat_fn": reconcile_hub_flat_fn,
"risk_status_fn": risk_status_fn,
"user_close_fn": user_close_fn,
@@ -602,6 +604,21 @@ def register_hub_routes(app):
except Exception as e:
return jsonify({"ok": False, "msg": str(e)}), 500
@app.route("/api/hub/market")
@_hub_auth_required
def api_hub_market():
fn = _ctx().get("market_fn")
if not callable(fn):
return jsonify({"ok": False, "msg": "该实例未配置合约信息接口"}), 501
base = (request.args.get("base") or request.args.get("symbol") or "").strip()
try:
result = fn(base=base)
if isinstance(result, dict):
return jsonify(result)
return jsonify({"ok": False, "msg": "合约信息返回格式无效"}), 500
except Exception as e:
return jsonify({"ok": False, "msg": str(e)}), 500
@app.route("/api/hub/ohlcv")
@_hub_auth_required
def api_hub_ohlcv():