수정
This commit is contained in:
@@ -65,4 +65,22 @@ assertOk('directInput 55 => K_55', direct55.rightField === 'K_55' && direct55.ta
|
||||
const filled = ensureDirectThresholdSnapshot({ indicatorType: 'RSI', rightField: 'K_55', thresholdOverride: false });
|
||||
assertOk('K_55 fills targetValue', filled.targetValue === 55 && filled.thresholdOverride === true);
|
||||
|
||||
// 레거시 마이그레이션 — K_55 를 HL_MID(50) 로 접지 않음
|
||||
function migrateK(cond) {
|
||||
if (cond.thresholdOverride === true) return cond;
|
||||
const field = cond.rightField;
|
||||
if (!field?.startsWith('K_')) return cond;
|
||||
const val = parseFloat(field.slice(2));
|
||||
if (!Number.isFinite(val)) return cond;
|
||||
const DEFAULT = { RSI: { over: 70, mid: 50, under: 30 } };
|
||||
const th = DEFAULT.RSI;
|
||||
const eps = 0.0001;
|
||||
if (th.over != null && Math.abs(th.over - val) < eps) return { ...cond, rightField: 'HL_OVER', thresholdOverride: false };
|
||||
if (th.mid != null && Math.abs(th.mid - val) < eps) return { ...cond, rightField: 'HL_MID', thresholdOverride: false };
|
||||
if (th.under != null && Math.abs(th.under - val) < eps) return { ...cond, rightField: 'HL_UNDER', thresholdOverride: false };
|
||||
return { ...cond, rightField: field, targetValue: val, thresholdOverride: true };
|
||||
}
|
||||
const migrated = migrateK({ indicatorType: 'RSI', rightField: 'K_55', thresholdOverride: false });
|
||||
assertOk('migrate K_55 stays K_55', migrated.rightField === 'K_55' && migrated.targetValue === 55);
|
||||
|
||||
process.exit(failed > 0 ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user