diff --git a/frontend/src/api/factor.ts b/frontend/src/api/factor.ts new file mode 100644 index 0000000..b3e403e --- /dev/null +++ b/frontend/src/api/factor.ts @@ -0,0 +1,35 @@ +import { apiClient } from './client' +import { useAuthStore } from '@/stores/auth' + +export interface FactorItem { + name: string + category: string +} + +export interface FactorSubmit { + symbols: string[] + factor_names: string[] + start: string + end: string +} + +export async function getFactors(): Promise { + const { data } = await apiClient.get<{ factors: FactorItem[] }>('/factor/list') + return data.factors +} + +export async function submitFactor(req: FactorSubmit): Promise { + const { data } = await apiClient.post<{ task_id: string }>('/factor/analyze', req) + return data.task_id +} + +export async function getIcSummary(taskId: string): Promise> { + const { data } = await apiClient.get<{ ic_summary: Record }>(`/task/${taskId}/ic-summary`) + return data.ic_summary +} + +/** Report URL with token in query (iframe can't set Authorization header). */ +export function reportUrl(taskId: string, factor: string): string { + const auth = useAuthStore() + return `/api/v1/task/${taskId}/report/${factor}?token=${encodeURIComponent(auth.token ?? '')}` +} diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index de0e552..91bc0cb 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -12,6 +12,7 @@ const routes: RouteRecordRaw[] = [ { path: 'backtest/progress/:id', name: 'bt-progress', component: () => import('@/views/backtest/Progress.vue') }, { path: 'backtest/result/:id', name: 'bt-result', component: () => import('@/views/backtest/Result.vue') }, { path: 'factor/new', name: 'fc-new', component: () => import('@/views/factor/New.vue') }, + { path: 'factor/progress/:id', name: 'fc-progress', component: () => import('@/views/backtest/Progress.vue') }, { path: 'factor/result/:id', name: 'fc-result', component: () => import('@/views/factor/Result.vue') }, ], }, diff --git a/frontend/src/views/backtest/Progress.vue b/frontend/src/views/backtest/Progress.vue index 90605f9..fce622a 100644 --- a/frontend/src/views/backtest/Progress.vue +++ b/frontend/src/views/backtest/Progress.vue @@ -11,7 +11,10 @@ const { status, stage, start } = useTask(taskId) start() watch(status, (s) => { - if (s === 'done') router.push(`/backtest/result/${taskId}`) + if (s === 'done') { + const base = route.path.startsWith('/factor') ? '/factor' : '/backtest' + router.push(`${base}/result/${taskId}`) + } }) function pct(): number { diff --git a/frontend/src/views/factor/New.vue b/frontend/src/views/factor/New.vue index 50ae65b..1c0e5e4 100644 --- a/frontend/src/views/factor/New.vue +++ b/frontend/src/views/factor/New.vue @@ -1,4 +1,82 @@ - + + diff --git a/frontend/src/views/factor/Result.vue b/frontend/src/views/factor/Result.vue index 9c9daf1..274be58 100644 --- a/frontend/src/views/factor/Result.vue +++ b/frontend/src/views/factor/Result.vue @@ -1,4 +1,89 @@ - + +