전략평가 MA 참조에러 수정

This commit is contained in:
Macbook
2026-06-13 01:25:56 +09:00
parent 24128e6a0a
commit 207374a08e
10 changed files with 451 additions and 77 deletions
+45 -13
View File
@@ -10,6 +10,11 @@ import {
candleRangeWindowBars,
formatCandleRangeClause,
} from '../utils/strategyTypes';
import {
appendLegacyMaFieldOption,
buildEmaFieldOptions,
buildMaFieldOptions,
} from './maDslField';
import {
COMPOSITE_INDICATOR_ITEMS,
compositeDisplayName,
@@ -136,7 +141,7 @@ export const saveStratsLocal = (_s: StrategyDto[]) => { /* no-op */ };
interface HLThresh { over?: number; mid?: number; under?: number; }
/** 하드코딩 기본값 — activeIndicators가 없을 때 폴백 */
const DEF_DEFAULTS = {
export const DEF_DEFAULTS = {
rsiPeriod: 9,
macdFast: 12, macdSlow: 26, macdSignal: 9,
cciPeriod: 13,
@@ -347,6 +352,23 @@ export function buildStrategyEditorDefFromSettings(
}
/** @deprecated buildStrategyEditorDefFromSettings 사용 — 하드코딩 폴백 */
export function buildDefFromGetParams(
getParams: (type: string, defaults?: Record<string, number | string | boolean>) => Record<string, number | string | boolean>,
): DefType {
const types = [
'RSI', 'MACD', 'CCI', 'Stochastic', 'ADX', 'TRIX', 'DMI', 'BollingerBands',
'IchimokuCloud', 'WilliamsPercentRange', 'VolumeOscillator', 'VR', 'Disparity',
'Psychological', 'NewPsychological', 'InvestPsychological', 'OBV', 'SMA', 'EMA',
] as const;
const configs: IndicatorConfig[] = types.map(type => ({
id: `eval-def-${type}`,
type,
params: getParams(type, getIndicatorDef(type)?.defaultParams as Record<string, number | string | boolean>),
plots: getIndicatorDef(type)?.plots ?? [],
}));
return buildDef(configs);
}
export function buildStrategyEditorDef(): DefType {
return buildDef([]);
}
@@ -497,16 +519,26 @@ export const getFieldOpts = (
{ value:'VOLUME_VALUE', label:'거래량' },
{ value:'VOLUME_MA', label:'거래량 이동평균' },
]);
case 'MA': return [
NONE,
...DEF.maLines.map((p, i) => ({ value:`MA${p}`, label:`MA${i+1}(${p}일)` })),
{ value:'CLOSE_PRICE', label:'종가' },
];
case 'EMA': return [
NONE,
...DEF.maLines.slice(0,4).map((p, i) => ({ value:`EMA${p}`, label:`EMA${i+1}(${p}일)` })),
{ value:'CLOSE_PRICE', label:'종가' },
];
case 'MA': {
let opts = [
NONE,
...buildMaFieldOptions(DEF.maLines),
{ value: 'CLOSE_PRICE', label: '종가' },
];
if (cond?.leftField) opts = appendLegacyMaFieldOption(opts, cond.leftField);
if (cond?.rightField) opts = appendLegacyMaFieldOption(opts, cond.rightField);
return opts;
}
case 'EMA': {
let opts = [
NONE,
...buildEmaFieldOptions(DEF.maLines, 4),
{ value: 'CLOSE_PRICE', label: '종가' },
];
if (cond?.leftField) opts = appendLegacyMaFieldOption(opts, cond.leftField);
if (cond?.rightField) opts = appendLegacyMaFieldOption(opts, cond.rightField);
return opts;
}
case 'DISPARITY': {
const { mid } = th({ mid: 100 });
return condOpts([
@@ -667,8 +699,8 @@ const getDefaultConditionFields = (ind: string, signalType: 'buy'|'sell', DEF: D
DMI: { l:'PDI', r:'MDI' },
OBV: { l:'OBV_LINE', r:'OBV_SIGNAL' },
VOLUME: { l:'VOLUME_VALUE', r:'VOLUME_MA' },
MA: { l:`MA${DEF.maLines[0]}`, r:`MA${DEF.maLines[1]}` },
EMA: { l:`EMA${DEF.maLines[0]}`, r:`EMA${DEF.maLines[1]}` },
MA: { l: 'MA1', r: 'MA2' },
EMA: { l: 'EMA1', r: 'EMA2' },
DISPARITY: { l:`DISPARITY${DEF.dispUltra}`, r: THRESHOLD_HL_MID },
PSYCHOLOGICAL: { l:'PSY_VALUE', r: THRESHOLD_HL_OVER },
NEW_PSYCHOLOGICAL: { l:'NEW_PSY_VALUE', r: THRESHOLD_HL_OVER },