보조지표 기준값 변경시 전략편집기 연동
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
type IchimokuCloudColors,
|
||||
resolveIchimokuCloudColors,
|
||||
} from '../utils/ichimokuConfig';
|
||||
import type { IndicatorConfig } from '../types';
|
||||
import {
|
||||
loadIndicatorSettings,
|
||||
saveIndicatorSettings,
|
||||
@@ -173,6 +174,49 @@ export function useIndicatorSettings(sessionKey = 0) {
|
||||
[]
|
||||
);
|
||||
|
||||
/**
|
||||
* 설정 화면 — 보조지표 기본값 일괄 저장 (파라미터 PUT + 시각 PATCH).
|
||||
* 저장 완료 후 캐시 갱신 및 구독자(settingsRevision) 알림.
|
||||
*/
|
||||
const saveAllIndicatorDefaults = useCallback(
|
||||
async (configs: Record<string, IndicatorConfig>) => {
|
||||
const entries = Object.values(configs);
|
||||
if (entries.length === 0) return;
|
||||
|
||||
const allParams: AllSettings = { ...(_cache ?? {}) };
|
||||
for (const cfg of entries) {
|
||||
allParams[cfg.type] = cfg.params as ParamMap;
|
||||
}
|
||||
|
||||
await saveAllIndicatorSettings(allParams);
|
||||
_cache = { ...allParams };
|
||||
|
||||
const visualEntries = entries.map(cfg => {
|
||||
const visual: IndicatorVisual = {
|
||||
plots: cfg.plots,
|
||||
hlines: cfg.hlines,
|
||||
};
|
||||
if (cfg.cloudColors) visual.cloudColors = cfg.cloudColors;
|
||||
return { type: cfg.type, visual };
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
visualEntries.map(({ type, visual }) =>
|
||||
saveIndicatorVisualSettings(type, visual as { plots?: unknown[]; hlines?: unknown[]; cloudColors?: IchimokuCloudColors }),
|
||||
),
|
||||
);
|
||||
|
||||
const nextVisual: VisualCache = { ...(_visualCache ?? {}) };
|
||||
for (const { type, visual } of visualEntries) {
|
||||
nextVisual[type] = visual;
|
||||
}
|
||||
_visualCache = nextVisual;
|
||||
|
||||
notifyIndicatorSettingsChanged();
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
// ── 시각 설정 (색상·선굵기·수평선) ──────────────────────────────────────
|
||||
|
||||
/**
|
||||
@@ -250,5 +294,13 @@ export function useIndicatorSettings(sessionKey = 0) {
|
||||
[]
|
||||
);
|
||||
|
||||
return { getParams, saveParams, saveAll, getVisualConfig, saveVisual, settingsRevision };
|
||||
return {
|
||||
getParams,
|
||||
saveParams,
|
||||
saveAll,
|
||||
saveAllIndicatorDefaults,
|
||||
getVisualConfig,
|
||||
saveVisual,
|
||||
settingsRevision,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user