추세검색기 기능 추가
This commit is contained in:
@@ -1,240 +1,191 @@
|
||||
/** 추세검색 20개 조건 정의 */
|
||||
export type TrendConditionMode = 'sort' | 'filter' | 'unsupported';
|
||||
/** 추세검색 조건 정의 — 정배열 / 상승세 / 거래량 / 보조지표 */
|
||||
export type TrendConditionMode = 'filter';
|
||||
|
||||
export type TrendCategoryKey =
|
||||
| 'maAlignEnabled'
|
||||
| 'trendEnabled'
|
||||
| 'volumePowerEnabled'
|
||||
| 'indicatorEnabled';
|
||||
|
||||
export interface TrendConditionDef {
|
||||
id: string;
|
||||
category: 'price' | 'volume' | 'flow' | 'fundamental';
|
||||
category: 'ma' | 'trend' | 'volume' | 'indicator';
|
||||
categoryLabel: string;
|
||||
label: string;
|
||||
desc: string;
|
||||
mode: TrendConditionMode;
|
||||
requestKey: keyof import('./backendApi').TrendSearchRequest;
|
||||
categoryKey: keyof Pick<
|
||||
import('./backendApi').TrendSearchRequest,
|
||||
'priceEnabled' | 'volumeEnabled' | 'flowEnabled' | 'fundamentalEnabled'
|
||||
>;
|
||||
categoryKey: TrendCategoryKey;
|
||||
/** 조건 파라미터 UI */
|
||||
params?: 'maConvergencePct' | 'ma20SlopeBars' | 'newHighBreakout' | 'volumeVsPrior' | 'minTurnover' | 'rsiBand' | 'adxMin';
|
||||
}
|
||||
|
||||
export const TREND_CONDITION_DEFS: TrendConditionDef[] = [
|
||||
// Ⅰ. 정배열
|
||||
{
|
||||
id: 'near52wHigh',
|
||||
category: 'price',
|
||||
categoryLabel: 'Ⅰ. 가격·탄력성',
|
||||
label: '52주 신고가 근접률',
|
||||
desc: '1년 최고가 대비 현재가 근접도 (높을수록 상단)',
|
||||
mode: 'sort',
|
||||
requestKey: 'near52wHigh',
|
||||
categoryKey: 'priceEnabled',
|
||||
},
|
||||
{
|
||||
id: 'ret3m',
|
||||
category: 'price',
|
||||
categoryLabel: 'Ⅰ. 가격·탄력성',
|
||||
label: '3개월 수익률',
|
||||
desc: '최근 12주 누적 상승률',
|
||||
mode: 'sort',
|
||||
requestKey: 'ret3m',
|
||||
categoryKey: 'priceEnabled',
|
||||
},
|
||||
{
|
||||
id: 'ret6m',
|
||||
category: 'price',
|
||||
categoryLabel: 'Ⅰ. 가격·탄력성',
|
||||
label: '6개월 수익률',
|
||||
desc: '최근 24주 누적 상승률',
|
||||
mode: 'sort',
|
||||
requestKey: 'ret6m',
|
||||
categoryKey: 'priceEnabled',
|
||||
},
|
||||
{
|
||||
id: 'maDeviation',
|
||||
category: 'price',
|
||||
categoryLabel: 'Ⅰ. 가격·탄력성',
|
||||
label: '이동평균 이격도 (20·60일)',
|
||||
desc: '20·60일선 대비 주가 이격률',
|
||||
mode: 'sort',
|
||||
requestKey: 'maDeviation',
|
||||
categoryKey: 'priceEnabled',
|
||||
},
|
||||
{
|
||||
id: 'maFullAlign',
|
||||
category: 'price',
|
||||
categoryLabel: 'Ⅰ. 가격·탄력성',
|
||||
label: '이동평균 완전 정배열',
|
||||
desc: '주가 > 5 > 20 > 60 > 120 > 200일선',
|
||||
id: 'priceAboveMa',
|
||||
category: 'ma',
|
||||
categoryLabel: 'Ⅰ. 정배열',
|
||||
label: '주가 > 5·20·60 이평',
|
||||
desc: '종가가 5·20·60일 이동평균선 위',
|
||||
mode: 'filter',
|
||||
requestKey: 'maFullAlign',
|
||||
categoryKey: 'priceEnabled',
|
||||
requestKey: 'priceAboveMa',
|
||||
categoryKey: 'maAlignEnabled',
|
||||
},
|
||||
{
|
||||
id: 'stage2',
|
||||
category: 'price',
|
||||
categoryLabel: 'Ⅰ. 가격·탄력성',
|
||||
label: "마크 미너비니 Stage 2",
|
||||
desc: '150·200일선 위 + 200일선 1개월↑',
|
||||
id: 'maAlignment',
|
||||
category: 'ma',
|
||||
categoryLabel: 'Ⅰ. 정배열',
|
||||
label: '5 > 20 > 60 > 120 정배열',
|
||||
desc: '단기 이평이 장기 이평 위에 배열',
|
||||
mode: 'filter',
|
||||
requestKey: 'stage2',
|
||||
categoryKey: 'priceEnabled',
|
||||
requestKey: 'maAlignment',
|
||||
categoryKey: 'maAlignEnabled',
|
||||
},
|
||||
{
|
||||
id: 'relativeStrength',
|
||||
category: 'price',
|
||||
categoryLabel: 'Ⅰ. 가격·탄력성',
|
||||
label: '상대강도 (RS vs BTC)',
|
||||
desc: 'BTC 대비 초과 수익률',
|
||||
mode: 'sort',
|
||||
requestKey: 'relativeStrength',
|
||||
categoryKey: 'priceEnabled',
|
||||
},
|
||||
{
|
||||
id: 'newHighCount',
|
||||
category: 'price',
|
||||
categoryLabel: 'Ⅰ. 가격·탄력성',
|
||||
label: '최근 N일 신고가 달성 횟수',
|
||||
desc: '최근 구간 신고가 경신 일수',
|
||||
mode: 'sort',
|
||||
requestKey: 'newHighCount',
|
||||
categoryKey: 'priceEnabled',
|
||||
},
|
||||
{
|
||||
id: 'tradeAmount',
|
||||
category: 'volume',
|
||||
categoryLabel: 'Ⅱ. 거래량·대금',
|
||||
label: '당일 거래대금',
|
||||
desc: '24h 누적 거래대금',
|
||||
mode: 'sort',
|
||||
requestKey: 'tradeAmount',
|
||||
categoryKey: 'volumeEnabled',
|
||||
},
|
||||
{
|
||||
id: 'volVs5dAvg',
|
||||
category: 'volume',
|
||||
categoryLabel: 'Ⅱ. 거래량·대금',
|
||||
label: '5일 평균 대비 거래대금 증가율',
|
||||
desc: '5일 평균 대비 당일 거래대금',
|
||||
mode: 'sort',
|
||||
requestKey: 'volVs5dAvg',
|
||||
categoryKey: 'volumeEnabled',
|
||||
},
|
||||
{
|
||||
id: 'turnover',
|
||||
category: 'volume',
|
||||
categoryLabel: 'Ⅱ. 거래량·대금',
|
||||
label: '거래량 회전율',
|
||||
desc: '20일 평균 대비 당일 거래량 비율',
|
||||
mode: 'sort',
|
||||
requestKey: 'turnover',
|
||||
categoryKey: 'volumeEnabled',
|
||||
},
|
||||
{
|
||||
id: 'bidAskRatio',
|
||||
category: 'volume',
|
||||
categoryLabel: 'Ⅱ. 거래량·대금',
|
||||
label: '매수 대기 잔량 비율',
|
||||
desc: '호가 매수잔량 / 매도잔량',
|
||||
mode: 'sort',
|
||||
requestKey: 'bidAskRatio',
|
||||
categoryKey: 'volumeEnabled',
|
||||
},
|
||||
{
|
||||
id: 'smartMoney',
|
||||
category: 'flow',
|
||||
categoryLabel: 'Ⅲ. 수급·심리',
|
||||
label: '스마트머니 누적 (OBV)',
|
||||
desc: 'OBV 20일 누적 상승폭 (기관·외국인 대용)',
|
||||
mode: 'sort',
|
||||
requestKey: 'smartMoney',
|
||||
categoryKey: 'flowEnabled',
|
||||
},
|
||||
{
|
||||
id: 'instConsecutive',
|
||||
category: 'flow',
|
||||
categoryLabel: 'Ⅲ. 수급·심리',
|
||||
label: '연속 순매수 일수',
|
||||
desc: '양봉+거래량 증가 연속 일수 (연기금·투신 대용)',
|
||||
mode: 'sort',
|
||||
requestKey: 'instConsecutive',
|
||||
categoryKey: 'flowEnabled',
|
||||
},
|
||||
{
|
||||
id: 'rsiHigh',
|
||||
category: 'flow',
|
||||
categoryLabel: 'Ⅲ. 수급·심리',
|
||||
label: 'RSI (상대강도지수)',
|
||||
desc: 'RSI 14 — 높을수록 강한 모멘텀',
|
||||
mode: 'sort',
|
||||
requestKey: 'rsiHigh',
|
||||
categoryKey: 'flowEnabled',
|
||||
},
|
||||
{
|
||||
id: 'macdPeak',
|
||||
category: 'flow',
|
||||
categoryLabel: 'Ⅲ. 수급·심리',
|
||||
label: 'MACD 오실레이터 최고치',
|
||||
desc: '최근 20일 MACD 히스토그램 신고가',
|
||||
mode: 'sort',
|
||||
requestKey: 'macdPeak',
|
||||
categoryKey: 'flowEnabled',
|
||||
},
|
||||
{
|
||||
id: 'lightCredit',
|
||||
category: 'flow',
|
||||
categoryLabel: 'Ⅲ. 수급·심리',
|
||||
label: '거래량 감소 + 주가 상승',
|
||||
desc: '매물 소화 후 가벼운 상승 (신용잔고↓ 대용)',
|
||||
id: 'maConvergence',
|
||||
category: 'ma',
|
||||
categoryLabel: 'Ⅰ. 정배열',
|
||||
label: '이평밀집도 수렴 (선택)',
|
||||
desc: '5·20·60 이평 간격이 N% 이내 (확산 전 포착)',
|
||||
mode: 'filter',
|
||||
requestKey: 'lightCredit',
|
||||
categoryKey: 'flowEnabled',
|
||||
requestKey: 'maConvergence',
|
||||
categoryKey: 'maAlignEnabled',
|
||||
params: 'maConvergencePct',
|
||||
},
|
||||
// Ⅱ. 상승세
|
||||
{
|
||||
id: 'ma20SlopeUp',
|
||||
category: 'trend',
|
||||
categoryLabel: 'Ⅱ. 상승세',
|
||||
label: '20일 이평 연속 상승',
|
||||
desc: '20일선(생명선) N봉 연속 우상향',
|
||||
mode: 'filter',
|
||||
requestKey: 'ma20SlopeUp',
|
||||
categoryKey: 'trendEnabled',
|
||||
params: 'ma20SlopeBars',
|
||||
},
|
||||
{
|
||||
id: 'earningsGrowth',
|
||||
category: 'fundamental',
|
||||
categoryLabel: 'Ⅳ. 펀더멘털',
|
||||
label: '분기 영업이익 성장률 (YoY)',
|
||||
desc: '주식 전용 — 코인 미지원',
|
||||
mode: 'unsupported',
|
||||
requestKey: 'earningsGrowth',
|
||||
categoryKey: 'fundamentalEnabled',
|
||||
id: 'newHighBreakout',
|
||||
category: 'trend',
|
||||
categoryLabel: 'Ⅱ. 상승세',
|
||||
label: '신고가 돌파·근접',
|
||||
desc: 'N일 고가 돌파 또는 고가 대비 -M% 이내',
|
||||
mode: 'filter',
|
||||
requestKey: 'newHighBreakout',
|
||||
categoryKey: 'trendEnabled',
|
||||
params: 'newHighBreakout',
|
||||
},
|
||||
{
|
||||
id: 'roe',
|
||||
category: 'fundamental',
|
||||
categoryLabel: 'Ⅳ. 펀더멘털',
|
||||
label: 'ROE (자기자본이익률)',
|
||||
desc: '주식 전용 — 코인 미지원',
|
||||
mode: 'unsupported',
|
||||
requestKey: 'roe',
|
||||
categoryKey: 'fundamentalEnabled',
|
||||
id: 'ichimokuAboveCloud',
|
||||
category: 'trend',
|
||||
categoryLabel: 'Ⅱ. 상승세',
|
||||
label: '일목 구름대 상단',
|
||||
desc: '주가 > 선행스팬1 · 선행스팬2',
|
||||
mode: 'filter',
|
||||
requestKey: 'ichimokuAboveCloud',
|
||||
categoryKey: 'trendEnabled',
|
||||
},
|
||||
// Ⅲ. 돈과 힘
|
||||
{
|
||||
id: 'volumeVsPrior200',
|
||||
category: 'volume',
|
||||
categoryLabel: 'Ⅲ. 돈과 힘',
|
||||
label: '직전 봉 대비 거래량',
|
||||
desc: '일봉=전일, 분봉=직전 봉 대비 거래량 %',
|
||||
mode: 'filter',
|
||||
requestKey: 'volumeVsPrior200',
|
||||
categoryKey: 'volumePowerEnabled',
|
||||
params: 'volumeVsPrior',
|
||||
},
|
||||
{
|
||||
id: 'opMargin',
|
||||
category: 'fundamental',
|
||||
categoryLabel: 'Ⅳ. 펀더멘털',
|
||||
label: '매출액 영업이익률',
|
||||
desc: '주식 전용 — 코인 미지원',
|
||||
mode: 'unsupported',
|
||||
requestKey: 'opMargin',
|
||||
categoryKey: 'fundamentalEnabled',
|
||||
id: 'minTurnover5dAvg',
|
||||
category: 'volume',
|
||||
categoryLabel: 'Ⅲ. 돈과 힘',
|
||||
label: '5일 평균 거래대금',
|
||||
desc: '최근 5일 평균 거래대금 하한 (억 원)',
|
||||
mode: 'filter',
|
||||
requestKey: 'minTurnover5dAvg',
|
||||
categoryKey: 'volumePowerEnabled',
|
||||
params: 'minTurnover',
|
||||
},
|
||||
{
|
||||
id: 'pegBelow1',
|
||||
category: 'fundamental',
|
||||
categoryLabel: 'Ⅳ. 펀더멘털',
|
||||
label: 'PEG 1.0 이하',
|
||||
desc: '주식 전용 — 코인 미지원',
|
||||
mode: 'unsupported',
|
||||
requestKey: 'pegBelow1',
|
||||
categoryKey: 'fundamentalEnabled',
|
||||
id: 'volMa5Over20',
|
||||
category: 'volume',
|
||||
categoryLabel: 'Ⅲ. 돈과 힘',
|
||||
label: '거래량 이평 정배열',
|
||||
desc: '5일 거래량 이평 > 20일 거래량 이평',
|
||||
mode: 'filter',
|
||||
requestKey: 'volMa5Over20',
|
||||
categoryKey: 'volumePowerEnabled',
|
||||
},
|
||||
// Ⅳ. 보조지표
|
||||
{
|
||||
id: 'macdGoldenCross',
|
||||
category: 'indicator',
|
||||
categoryLabel: 'Ⅳ. 보조지표',
|
||||
label: 'MACD 골든크로스',
|
||||
desc: 'MACD Line > Signal 또는 MACD > 0',
|
||||
mode: 'filter',
|
||||
requestKey: 'macdGoldenCross',
|
||||
categoryKey: 'indicatorEnabled',
|
||||
},
|
||||
{
|
||||
id: 'rsiBand',
|
||||
category: 'indicator',
|
||||
categoryLabel: 'Ⅳ. 보조지표',
|
||||
label: 'RSI 구간',
|
||||
desc: '과열·침체 구간 제외 (기본 50~70)',
|
||||
mode: 'filter',
|
||||
requestKey: 'rsiBand',
|
||||
categoryKey: 'indicatorEnabled',
|
||||
params: 'rsiBand',
|
||||
},
|
||||
{
|
||||
id: 'dmiBullish',
|
||||
category: 'indicator',
|
||||
categoryLabel: 'Ⅳ. 보조지표',
|
||||
label: '+DI > -DI · ADX',
|
||||
desc: '추세 강도 ADX 하한 이상',
|
||||
mode: 'filter',
|
||||
requestKey: 'dmiBullish',
|
||||
categoryKey: 'indicatorEnabled',
|
||||
params: 'adxMin',
|
||||
},
|
||||
];
|
||||
|
||||
export const TREND_SORT_CONDITION_IDS = TREND_CONDITION_DEFS
|
||||
.filter(c => c.mode === 'sort')
|
||||
.map(c => c.id);
|
||||
|
||||
export const TREND_CATEGORY_ORDER = [
|
||||
{ key: 'priceEnabled' as const, label: 'Ⅰ. 가격·탄력성', cat: 'price' as const },
|
||||
{ key: 'volumeEnabled' as const, label: 'Ⅱ. 거래량·대금', cat: 'volume' as const },
|
||||
{ key: 'flowEnabled' as const, label: 'Ⅲ. 수급·심리', cat: 'flow' as const },
|
||||
{ key: 'fundamentalEnabled' as const, label: 'Ⅳ. 펀더멘털', cat: 'fundamental' as const },
|
||||
export const TREND_CATEGORY_ORDER: {
|
||||
key: TrendCategoryKey;
|
||||
label: string;
|
||||
cat: TrendConditionDef['category'];
|
||||
en: string;
|
||||
}[] = [
|
||||
{ key: 'maAlignEnabled', label: 'Ⅰ. 정배열', cat: 'ma', en: 'Moving Average Alignment' },
|
||||
{ key: 'trendEnabled', label: 'Ⅱ. 상승세', cat: 'trend', en: 'Trend & Momentum' },
|
||||
{ key: 'volumePowerEnabled', label: 'Ⅲ. 돈과 힘', cat: 'volume', en: 'Volume & Liquidity' },
|
||||
{ key: 'indicatorEnabled', label: 'Ⅳ. 보조지표', cat: 'indicator', en: 'Indicators' },
|
||||
];
|
||||
|
||||
/** 카테고리 OFF 시 하위 조건까지 함께 끄기 위한 패치 */
|
||||
export function buildCategoryTogglePatch(
|
||||
catKey: TrendCategoryKey,
|
||||
on: boolean,
|
||||
): Partial<import('./backendApi').TrendSearchRequest> {
|
||||
const patch: Partial<import('./backendApi').TrendSearchRequest> = { [catKey]: on };
|
||||
if (!on) {
|
||||
for (const def of TREND_CONDITION_DEFS.filter(d => d.categoryKey === catKey)) {
|
||||
patch[def.requestKey] = false as never;
|
||||
}
|
||||
}
|
||||
return patch;
|
||||
}
|
||||
|
||||
export function countActiveTrendFilters(
|
||||
filters: import('./backendApi').TrendSearchRequest,
|
||||
): number {
|
||||
let n = 0;
|
||||
for (const def of TREND_CONDITION_DEFS) {
|
||||
if (filters[def.categoryKey] && filters[def.requestKey]) n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user