추세검색 설정 수정
This commit is contained in:
@@ -1256,6 +1256,12 @@ export const DEFAULT_TREND_SEARCH_REQUEST: TrendSearchRequest = {
|
||||
|
||||
export const TREND_TIMEFRAMES = ['1m', '3m', '5m', '10m', '15m', '30m', '1h', '4h', '1d', '1w', '1M'] as const;
|
||||
|
||||
export interface TrendSearchResultsResponse {
|
||||
results: TrendSearchResultDto[];
|
||||
timeframe?: string;
|
||||
scannedAt?: string;
|
||||
}
|
||||
|
||||
export async function scanTrendSearch(body: TrendSearchRequest): Promise<TrendSearchResultDto[]> {
|
||||
return (await request<TrendSearchResultDto[]>('/trend-search/scan', {
|
||||
method: 'POST',
|
||||
@@ -1263,6 +1269,10 @@ export async function scanTrendSearch(body: TrendSearchRequest): Promise<TrendSe
|
||||
})) ?? [];
|
||||
}
|
||||
|
||||
export async function fetchTrendSearchResults(): Promise<TrendSearchResultsResponse> {
|
||||
return (await request<TrendSearchResultsResponse>('/trend-search/results')) ?? { results: [] };
|
||||
}
|
||||
|
||||
export async function fetchTrendSearchDetail(
|
||||
market: string,
|
||||
timeframe?: string,
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
/**
|
||||
* 추세검색 API
|
||||
*/
|
||||
import { scanTrendSearch as apiScan, fetchTrendSearchDetail as apiDetail } from './backendApi';
|
||||
import {
|
||||
scanTrendSearch as apiScan,
|
||||
fetchTrendSearchDetail as apiDetail,
|
||||
fetchTrendSearchResults as apiResults,
|
||||
} from './backendApi';
|
||||
|
||||
export type {
|
||||
TrendSearchConditionDto,
|
||||
@@ -18,3 +22,7 @@ export async function scanTrendSearch(body: import('./backendApi').TrendSearchRe
|
||||
export async function fetchTrendSearchDetail(market: string, timeframe?: string) {
|
||||
return apiDetail(market, timeframe);
|
||||
}
|
||||
|
||||
export async function loadTrendSearchResults() {
|
||||
return apiResults();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ export interface TrendSearchAppSettings {
|
||||
limit: number;
|
||||
/** 스캔 대상 종목 수 (거래대금 상위) */
|
||||
scanLimit: number;
|
||||
/** 자동 갱신 ON (백엔드 스케줄러·화면 폴링) */
|
||||
autoRefreshEnabled: boolean;
|
||||
/** 자동 갱신 간격(초) */
|
||||
autoRefreshSeconds: number;
|
||||
/** 검색 후 상위 N위까지 투자대상 자동추가 */
|
||||
@@ -38,6 +40,7 @@ export const DEFAULT_TREND_SEARCH_APP_SETTINGS: TrendSearchAppSettings = {
|
||||
minTrendScore: DEFAULT_TREND_SEARCH_REQUEST.minTrendScore,
|
||||
limit: DEFAULT_TREND_SEARCH_REQUEST.limit,
|
||||
scanLimit: DEFAULT_TREND_SEARCH_REQUEST.scanLimit,
|
||||
autoRefreshEnabled: true,
|
||||
autoRefreshSeconds: 3,
|
||||
autoAddTargetsEnabled: false,
|
||||
autoAddTopRank: 5,
|
||||
@@ -65,6 +68,7 @@ export function resolveTrendSearchAppSettings(
|
||||
minTrendScore: clampInt(raw.minTrendScore, 0, 100, d.minTrendScore),
|
||||
limit: clampInt(limit, 5, 50, d.limit),
|
||||
scanLimit: clampInt(scanLimit, 20, 120, d.scanLimit),
|
||||
autoRefreshEnabled: raw.autoRefreshEnabled !== false,
|
||||
autoRefreshSeconds: TREND_SEARCH_REFRESH_OPTIONS.includes(sec as typeof TREND_SEARCH_REFRESH_OPTIONS[number])
|
||||
? sec
|
||||
: d.autoRefreshSeconds,
|
||||
@@ -126,3 +130,27 @@ export function formatTrendRefreshLabel(seconds: number): string {
|
||||
if (seconds < 60) return `${seconds}초`;
|
||||
return `${seconds / 60}분`;
|
||||
}
|
||||
|
||||
/** 설정 변경 감지용 (useEffect 의존성) */
|
||||
export function trendSearchSettingsSignature(s: TrendSearchAppSettings): string {
|
||||
return JSON.stringify(s);
|
||||
}
|
||||
|
||||
/** 캐시/설정 → 추세검색 조건 패널 필드 병합 (timeframe 등 화면 전용 값 유지) */
|
||||
export function mergeFiltersFromTrendSearchSettings(
|
||||
filters: TrendSearchRequest,
|
||||
settings: TrendSearchAppSettings,
|
||||
): TrendSearchRequest {
|
||||
return mergeTrendSearchRequest(filters, settings);
|
||||
}
|
||||
|
||||
/** 추세검색 조건 변경 → 저장할 전체 추세설정 */
|
||||
export function mergeTrendSearchSettingsFromRequest(
|
||||
current: TrendSearchAppSettings,
|
||||
req: Pick<TrendSearchRequest, BullishWeightKey | 'minTrendScore' | 'limit' | 'scanLimit'>,
|
||||
): TrendSearchAppSettings {
|
||||
return resolveTrendSearchAppSettings({
|
||||
...current,
|
||||
...extractTrendSearchAppSettings(req),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user