diff --git a/frontend/src/components/strategyEditor/StrategyEditorEvaluationPanel.tsx b/frontend/src/components/strategyEditor/StrategyEditorEvaluationPanel.tsx index 4650b57..dfed2ab 100644 --- a/frontend/src/components/strategyEditor/StrategyEditorEvaluationPanel.tsx +++ b/frontend/src/components/strategyEditor/StrategyEditorEvaluationPanel.tsx @@ -42,6 +42,11 @@ const StrategyEditorEvaluationPanel: React.FC = ({ const [selectedBarIndex, setSelectedBarIndex] = useState(0); const [paramsRevision, setParamsRevision] = useState(0); + const editorState = useMemo( + () => ({ buy: buyEditorState, sell: sellEditorState }), + [buyEditorState, sellEditorState], + ); + const draftStrategy = useMemo( () => buildDraftStrategyForEvaluation({ name: stratName, @@ -53,12 +58,12 @@ const StrategyEditorEvaluationPanel: React.FC = ({ ); const strategyPrimaryTimeframe = useMemo( - () => (draftStrategy ? resolveStrategyPrimaryTimeframe(draftStrategy) : undefined), - [draftStrategy], + () => resolveStrategyPrimaryTimeframe(draftStrategy ?? undefined, editorState), + [draftStrategy, editorState], ); const chartTimeframe = useMemo((): Timeframe => { - return resolveBacktestExecTimeframe(timeframeChoice, strategyPrimaryTimeframe ?? '3m'); + return resolveBacktestExecTimeframe(timeframeChoice, strategyPrimaryTimeframe); }, [timeframeChoice, strategyPrimaryTimeframe]); const tfOptions = useMemo( @@ -67,10 +72,14 @@ const StrategyEditorEvaluationPanel: React.FC = ({ ); const draftRevisionKey = useMemo( - () => `${draftStrategy?.buyCondition ?? ''}|${draftStrategy?.sellCondition ?? ''}`, - [draftStrategy?.buyCondition, draftStrategy?.sellCondition], + () => `${draftStrategy?.buyCondition ?? ''}|${draftStrategy?.sellCondition ?? ''}|${strategyPrimaryTimeframe}`, + [draftStrategy?.buyCondition, draftStrategy?.sellCondition, strategyPrimaryTimeframe], ); + useEffect(() => { + setTimeframeChoice(BACKTEST_STRATEGY_TIMEFRAME); + }, [strategyPrimaryTimeframe]); + useEffect(() => { setParamsRevision(v => v + 1); }, [draftRevisionKey, settingsRevision]);