Skip to content

Commit 231ba2e

Browse files
Pigbibiclaude
andcommitted
fix(strategy-switch): remove duplicate RESERVED_CASH_VARIABLES block before fallback
Move the ACCOUNT_OPTIONS_DEFAULT fallback before the RESERVED_CASH_VARIABLES block so platforms with only partial cash data also get their default profile. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8932849 commit 231ba2e

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

web/strategy-switch-console/worker.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,26 @@ async function resolveCurrentStrategyForAccount({ platform, option, optionsCount
831831
}
832832
}
833833

834+
// Fallback: use default_strategy_profile from account options when
835+
// no GitHub variables can be read (e.g. token lacks repo access),
836+
// or only partial cash/reserve data is available (RESERVED_CASH_VARIABLES).
837+
const defaultProfile = cleanCurrentStrategy(option?.default_strategy_profile);
838+
if (defaultProfile) {
839+
return {
840+
strategy_profile: defaultProfile,
841+
...reservedCashPayload,
842+
...incomeLayerPayload,
843+
...optionOverlayPayload,
844+
...runtimeTargetEnabledPayload,
845+
...dcaPayloadForProfile(defaultProfile, dcaPayload),
846+
...ibitZscoreExitPayloadForProfile(defaultProfile, ibitZscorePayload),
847+
...cashOnlyPayload,
848+
source: "ACCOUNT_OPTIONS_DEFAULT",
849+
variable_scope: variableScope,
850+
github_environment: githubEnvironment || "",
851+
};
852+
}
853+
834854
if (
835855
Object.keys(reservedCashPayload).length ||
836856
Object.keys(incomeLayerPayload).length ||
@@ -858,25 +878,6 @@ async function resolveCurrentStrategyForAccount({ platform, option, optionsCount
858878
};
859879
}
860880

861-
// Fallback: use default_strategy_profile from account options when
862-
// no GitHub variables can be read (e.g. token lacks repo access).
863-
const defaultProfile = cleanCurrentStrategy(option?.default_strategy_profile);
864-
if (defaultProfile) {
865-
return {
866-
strategy_profile: defaultProfile,
867-
...reservedCashPayload,
868-
...incomeLayerPayload,
869-
...optionOverlayPayload,
870-
...runtimeTargetEnabledPayload,
871-
...dcaPayloadForProfile(defaultProfile, dcaPayload),
872-
...ibitZscoreExitPayloadForProfile(defaultProfile, ibitZscorePayload),
873-
...cashOnlyPayload,
874-
source: "ACCOUNT_OPTIONS_DEFAULT",
875-
variable_scope: variableScope,
876-
github_environment: githubEnvironment || "",
877-
};
878-
}
879-
880881
return null;
881882
}
882883

0 commit comments

Comments
 (0)