Skip to content

Commit 49ae64f

Browse files
Pigbibiclaude
andcommitted
fix(strategy-switch): add crypto_btc_dca to DCA configs + pass through combo_enabled
Threefold fix: 1. Hardcoded DCA_PROFILE_CONFIG (worker.js) and dcaProfileDefaults (index.html): - Added crypto_btc_dca with default_mode=fixed, base_investment=100 2. API response: normalizeStrategyProfilesPayload now reads item.dca_enabled AND item.combo_enabled from incoming payload, not just hardcoded config 3. Frontend applyStrategyProfiles: reads item.dca_enabled from API alongside dcaProfileDefaults fallback Also synced KV strategy_profiles to latest build from strategy_profiles_asset.js (via Cloudflare API). Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 502ccce commit 49ae64f

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

web/strategy-switch-console/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,7 @@ <h2 data-i18n="summary">切换摘要</h2>
16591659
const dcaProfileDefaults = {
16601660
nasdaq_sp500_smart_dca: { defaultMode: "fixed", defaultBaseInvestmentUsd: "1000" },
16611661
ibit_smart_dca: { defaultMode: "fixed", defaultBaseInvestmentUsd: "1000" },
1662+
crypto_btc_dca: { defaultMode: "fixed", defaultBaseInvestmentUsd: "100" },
16621663
};
16631664
const platformMinReservedCashVariables = {
16641665
longbridge: "LONGBRIDGE_MIN_RESERVED_CASH_USD",
@@ -2282,7 +2283,7 @@ <h2 data-i18n="summary">切换摘要</h2>
22822283
runtime_enabled: true,
22832284
};
22842285
const dcaDefaults = dcaProfileDefaults[profile] || null;
2285-
if (dcaDefaults) {
2286+
if (dcaDefaults || item?.dca_enabled === true) {
22862287
nextCatalog[profile].dca_enabled = true;
22872288
nextCatalog[profile].dca_default_mode = normalizeDcaMode(
22882289
item?.dca_default_mode || item?.default_dca_mode || dcaDefaults?.defaultMode || "fixed",

web/strategy-switch-console/page_asset.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/strategy-switch-console/worker.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const OPTION_OVERLAY_MODES = ["current", "enabled", "disabled"];
103103
const DCA_PROFILE_CONFIG = {
104104
nasdaq_sp500_smart_dca: { default_mode: "fixed", default_base_investment_usd: "1000" },
105105
ibit_smart_dca: { default_mode: "fixed", default_base_investment_usd: "1000" },
106+
crypto_btc_dca: { default_mode: "fixed", default_base_investment_usd: "100" },
106107
};
107108
const DCA_SUPPORTED_PLATFORMS = new Set(["firstrade"]);
108109
const SECURITY_HEADERS = {
@@ -1408,8 +1409,10 @@ function normalizeStrategyProfilesPayload(payload, fieldName = "strategy profile
14081409
cleanLabel,
14091410
);
14101411
entry.domain = cleanStrategyDomain(item.domain || "us_equity", `${fieldName}[${index}].domain`);
1411-
const dcaDefaults = DCA_PROFILE_CONFIG[profile] || null;
1412-
if (dcaDefaults) {
1412+
// DCA detection: accept from item payload OR hardcoded DCA_PROFILE_CONFIG
1413+
const dcaEnabled = item.dca_enabled === true || Boolean(DCA_PROFILE_CONFIG[profile]);
1414+
if (dcaEnabled) {
1415+
const dcaDefaults = DCA_PROFILE_CONFIG[profile] || null;
14131416
entry.dca_enabled = true;
14141417
entry.dca_default_mode = cleanDcaMode(item.dca_default_mode || item.default_dca_mode || dcaDefaults?.default_mode || "fixed");
14151418
entry.dca_default_base_investment_usd = cleanPositiveNumber(
@@ -1420,6 +1423,11 @@ function normalizeStrategyProfilesPayload(payload, fieldName = "strategy profile
14201423
`${fieldName}[${index}].dca_default_base_investment_usd`,
14211424
);
14221425
}
1426+
// Pass through combo_enabled and combo_mode from item payload
1427+
if (item.combo_enabled === true) {
1428+
entry.combo_enabled = true;
1429+
entry.combo_mode = String(item.combo_mode || "dynamic").trim() || "dynamic";
1430+
}
14231431
const incomeLayerConfig = incomeLayerConfigFromProfileItem(item, `${fieldName}[${index}]`);
14241432
if (incomeLayerConfig) Object.assign(entry, incomeLayerConfig);
14251433
const optionOverlayConfig = optionOverlayConfigFromProfileItem(item, `${fieldName}[${index}]`);

0 commit comments

Comments
 (0)