From 9fc931ce681eb4f07cf5db616586221af7736ee6 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Mon, 29 Jun 2026 03:39:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(strategy-switch):=20DCA=E5=85=81=E8=AE=B8Bi?= =?UTF-8?q?nance=E3=80=81example=E6=96=87=E4=BB=B6target=5Fid=E3=80=81?= =?UTF-8?q?=E6=AD=BB=E4=BB=A3=E7=A0=81=E6=B8=85=E7=90=86=E3=80=81=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E7=9F=A9=E9=98=B5=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DCA_SUPPORTED_PLATFORMS: 添加 binance,允许 crypto_btc_dca 提交 - 修复 4 个 example 文件 target_id 与路径名不一致 - 移除未使用的 fetchAllGithubVariables / githubVariableListUrl 死代码 - runtime_settings.py: 添加 binance 到 SUPPORTED_PLATFORMS 和 DRY_RUN 变量 - internal_dependency_matrix.json: 同步至当前所有 repo 的实际 pin - 全部 55 测试通过 Co-Authored-By: Claude --- .../targets/longbridge/hk_combo.example.json | 2 +- .../us_combo_leveraged.example.json | 2 +- examples/targets/qmt/cn_combo.example.json | 2 +- internal_dependency_matrix.json | 30 ++++++++--------- scripts/runtime_settings.py | 3 ++ web/strategy-switch-console/worker.js | 32 +------------------ 6 files changed, 22 insertions(+), 49 deletions(-) diff --git a/examples/targets/longbridge/hk_combo.example.json b/examples/targets/longbridge/hk_combo.example.json index c689bdb..f291813 100644 --- a/examples/targets/longbridge/hk_combo.example.json +++ b/examples/targets/longbridge/hk_combo.example.json @@ -1,6 +1,6 @@ { "$schema": "../../../schemas/runtime-target.schema.json", - "target_id": "longbridge/hk_combo_sg", + "target_id": "longbridge/hk_combo", "description": "LongBridge SG target for hk_equity_combo (60/40 ETF momentum/dividend quality with dynamic regime adjustment).", "github": { "repository": "QuantStrategyLab/LongBridgePlatform", diff --git a/examples/targets/longbridge/us_combo_leveraged.example.json b/examples/targets/longbridge/us_combo_leveraged.example.json index 05985dc..4e5f06e 100644 --- a/examples/targets/longbridge/us_combo_leveraged.example.json +++ b/examples/targets/longbridge/us_combo_leveraged.example.json @@ -1,6 +1,6 @@ { "$schema": "../../../schemas/runtime-target.schema.json", - "target_id": "longbridge/us_combo_leveraged_sg", + "target_id": "longbridge/us_combo_leveraged", "description": "LongBridge SG target for us_equity_combo_leveraged (40/20/40 TQQQ/SOXL/BOXX with SPY MA200 dynamic adjustment).", "github": { "repository": "QuantStrategyLab/LongBridgePlatform", diff --git a/examples/targets/qmt/cn_combo.example.json b/examples/targets/qmt/cn_combo.example.json index 92da85b..d462e41 100644 --- a/examples/targets/qmt/cn_combo.example.json +++ b/examples/targets/qmt/cn_combo.example.json @@ -1,6 +1,6 @@ { "$schema": "../../../schemas/runtime-target.schema.json", - "target_id": "qmt/cn_combo_dry_run", + "target_id": "qmt/cn_combo", "description": "QMT dry-run target for cn_equity_combo (30/50/20 ETF/stock/dividend with dynamic regime adjustment).", "github": { "repository": "QuantStrategyLab/QmtPlatform", diff --git a/internal_dependency_matrix.json b/internal_dependency_matrix.json index 31f3671..56fdcba 100644 --- a/internal_dependency_matrix.json +++ b/internal_dependency_matrix.json @@ -6,7 +6,7 @@ "path": "requirements.txt", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "bc5351d3567b2bb60416dc969062c37eedbbf65e" + "ref": "e86554b" }, { "consumer_repo": "BinancePlatform", @@ -20,7 +20,7 @@ "path": "requirements-lock.txt", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "bc5351d3567b2bb60416dc969062c37eedbbf65e" + "ref": "e86554b" }, { "consumer_repo": "BinancePlatform", @@ -34,7 +34,7 @@ "path": "requirements.txt", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "dfdbef6b58ab46f357d67800510bb9e8c4a01182" + "ref": "e86554b" }, { "consumer_repo": "CharlesSchwabPlatform", @@ -55,7 +55,7 @@ "path": "pyproject.toml", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "dfdbef6b58ab46f357d67800510bb9e8c4a01182" + "ref": "e86554b" }, { "consumer_repo": "FirstradePlatform", @@ -69,7 +69,7 @@ "path": "requirements.txt", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "dfdbef6b58ab46f357d67800510bb9e8c4a01182" + "ref": "e86554b" }, { "consumer_repo": "FirstradePlatform", @@ -83,14 +83,14 @@ "path": "pyproject.toml", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "dfdbef6b58ab46f357d67800510bb9e8c4a01182" + "ref": "e86554b" }, { "consumer_repo": "InteractiveBrokersPlatform", "path": "requirements.txt", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "dfdbef6b58ab46f357d67800510bb9e8c4a01182" + "ref": "e86554b" }, { "consumer_repo": "InteractiveBrokersPlatform", @@ -111,7 +111,7 @@ "path": "requirements.txt", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "dfdbef6b58ab46f357d67800510bb9e8c4a01182" + "ref": "e86554b" }, { "consumer_repo": "LongBridgePlatform", @@ -132,7 +132,7 @@ "path": "pyproject.toml", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "7b6e3ce33e6563db4794fa7b865db9ec428dc478" + "ref": "e86554b" }, { "consumer_repo": "UsEquitySnapshotPipelines", @@ -146,35 +146,35 @@ "path": "pyproject.toml", "package": "us-equity-strategies", "source_repo": "UsEquityStrategies", - "ref": "c7793bab6d63a434338bfcfd997a7ae9195dcddb" + "ref": "a9546362a27abdfc9cd5184b30ca8d26fd774187" }, { "consumer_repo": "UsEquityStrategies", "path": "pyproject.toml", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "dfdbef6b58ab46f357d67800510bb9e8c4a01182" + "ref": "e86554b" }, { "consumer_repo": "QmtPlatform", "path": "pyproject.toml", "package": "quant-platform-kit", "source_repo": "QuantPlatformKit", - "ref": "d18fe32b57a0a8bb746bebf6f11465dd68107eae" + "ref": "e86554b" }, { "consumer_repo": "QmtPlatform", "path": "pyproject.toml", "package": "cn-equity-strategies", "source_repo": "CnEquityStrategies", - "ref": "de6c76033e9d8a83fd6a8a31a51ce98690bb4262" + "ref": "357dba7e8896a7f488a484d4a3eea33894708ab9" }, { "consumer_repo": "CnEquitySnapshotPipelines", "path": "pyproject.toml", "package": "cn-equity-strategies", "source_repo": "CnEquityStrategies", - "ref": "0440651539dad4bb79c21bb5b965e97daec837de" + "ref": "357dba7e8896a7f488a484d4a3eea33894708ab9" } ] -} +} \ No newline at end of file diff --git a/scripts/runtime_settings.py b/scripts/runtime_settings.py index d05b506..4e34bef 100644 --- a/scripts/runtime_settings.py +++ b/scripts/runtime_settings.py @@ -25,6 +25,7 @@ "ibkr": {"plugin_mounts_prefix": "IBKR_", "repository": "QuantStrategyLab/InteractiveBrokersPlatform"}, "firstrade": {"plugin_mounts_prefix": "FIRSTRADE_", "repository": "QuantStrategyLab/FirstradePlatform"}, "qmt": {"plugin_mounts_prefix": "QMT_", "repository": "QuantStrategyLab/QmtPlatform"}, + "binance": {"plugin_mounts_prefix": "BINANCE_", "repository": "QuantStrategyLab/BinancePlatform"}, } PLATFORM_REPOSITORY_ENV = { "schwab": "RUNTIME_SETTINGS_SCHWAB_REPO", @@ -32,6 +33,7 @@ "ibkr": "RUNTIME_SETTINGS_IBKR_REPO", "firstrade": "RUNTIME_SETTINGS_FIRSTRADE_REPO", "qmt": "RUNTIME_SETTINGS_QMT_REPO", + "binance": "RUNTIME_SETTINGS_BINANCE_REPO", } RUNTIME_REQUIRED_FIELDS = ( "platform_id", @@ -102,6 +104,7 @@ "longbridge": "LONGBRIDGE_DRY_RUN_ONLY", "ibkr": "IBKR_DRY_RUN_ONLY", "firstrade": "FIRSTRADE_DRY_RUN_ONLY", + "binance": "BINANCE_DRY_RUN", } diff --git a/web/strategy-switch-console/worker.js b/web/strategy-switch-console/worker.js index de456b7..fc91868 100644 --- a/web/strategy-switch-console/worker.js +++ b/web/strategy-switch-console/worker.js @@ -105,7 +105,7 @@ const DCA_PROFILE_CONFIG = { ibit_smart_dca: { default_mode: "fixed", default_base_investment_usd: "1000" }, crypto_btc_dca: { default_mode: "fixed", default_base_investment_usd: "100" }, }; -const DCA_SUPPORTED_PLATFORMS = new Set(["firstrade"]); +const DCA_SUPPORTED_PLATFORMS = new Set(["firstrade", "binance"]); const SECURITY_HEADERS = { "Content-Security-Policy": [ "default-src 'self'", @@ -1795,36 +1795,6 @@ async function fetchGithubVariable(token, repository, scope, githubEnvironment, } } -async function fetchAllGithubVariables(token, repository, scope, githubEnvironment) { - const apiUrl = githubVariableListUrl(repository, scope, githubEnvironment); - if (!apiUrl) return {}; - try { - const response = await fetchWithTimeout(apiUrl, { - headers: githubHeaders(token), - }); - if (!response.ok) return {}; - const payload = await response.json(); - const vars = Array.isArray(payload) ? payload : (payload?.variables || []); - const result = {}; - for (const v of vars) { - result[v.name] = v.value; - } - return result; - } catch { - return {}; - } -} - -function githubVariableListUrl(repository, scope, githubEnvironment) { - const [owner, repo] = String(repository || "").split("/"); - if (!owner || !repo) return ""; - const base = `https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`; - if (scope === "environment") { - if (!githubEnvironment) return ""; - return `${base}/environments/${encodeURIComponent(githubEnvironment)}/variables`; - } - return `${base}/actions/variables`; -} function githubVariableUrl(repository, scope, githubEnvironment, name) { const [owner, repo] = String(repository || "").split("/");