Big refactoring
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import apiClient from './client';
|
||||
import type { AdminUser, SystemSetting } from '../lib/types';
|
||||
import type {
|
||||
AdminUser,
|
||||
PipelineReadiness,
|
||||
RecommendationConfig,
|
||||
SystemSetting,
|
||||
TickerUniverse,
|
||||
TickerUniverseBootstrapResult,
|
||||
TickerUniverseSetting,
|
||||
} from '../lib/types';
|
||||
|
||||
// Users
|
||||
export function listUsers() {
|
||||
@@ -48,6 +56,41 @@ export function updateRegistration(enabled: boolean) {
|
||||
.then((r) => r.data);
|
||||
}
|
||||
|
||||
export function getRecommendationSettings() {
|
||||
return apiClient
|
||||
.get<RecommendationConfig>('admin/settings/recommendations')
|
||||
.then((r) => r.data);
|
||||
}
|
||||
|
||||
export function updateRecommendationSettings(payload: Partial<RecommendationConfig>) {
|
||||
return apiClient
|
||||
.put<RecommendationConfig>('admin/settings/recommendations', payload)
|
||||
.then((r) => r.data);
|
||||
}
|
||||
|
||||
export function getTickerUniverseSetting() {
|
||||
return apiClient
|
||||
.get<TickerUniverseSetting>('admin/settings/ticker-universe')
|
||||
.then((r) => r.data);
|
||||
}
|
||||
|
||||
export function updateTickerUniverseSetting(universe: TickerUniverse) {
|
||||
return apiClient
|
||||
.put<TickerUniverseSetting>('admin/settings/ticker-universe', { universe })
|
||||
.then((r) => r.data);
|
||||
}
|
||||
|
||||
export function bootstrapTickers(universe: TickerUniverse, pruneMissing: boolean) {
|
||||
return apiClient
|
||||
.post<TickerUniverseBootstrapResult>('admin/tickers/bootstrap', null, {
|
||||
params: {
|
||||
universe,
|
||||
prune_missing: pruneMissing,
|
||||
},
|
||||
})
|
||||
.then((r) => r.data);
|
||||
}
|
||||
|
||||
// Jobs
|
||||
export interface JobStatus {
|
||||
name: string;
|
||||
@@ -55,12 +98,31 @@ export interface JobStatus {
|
||||
enabled: boolean;
|
||||
next_run_at: string | null;
|
||||
registered: boolean;
|
||||
running?: boolean;
|
||||
runtime_status?: string | null;
|
||||
runtime_processed?: number | null;
|
||||
runtime_total?: number | null;
|
||||
runtime_progress_pct?: number | null;
|
||||
runtime_current_ticker?: string | null;
|
||||
runtime_started_at?: string | null;
|
||||
runtime_finished_at?: string | null;
|
||||
runtime_message?: string | null;
|
||||
}
|
||||
|
||||
export interface TriggerJobResponse {
|
||||
job: string;
|
||||
status: 'triggered' | 'busy' | 'blocked' | 'not_found';
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function listJobs() {
|
||||
return apiClient.get<JobStatus[]>('admin/jobs').then((r) => r.data);
|
||||
}
|
||||
|
||||
export function getPipelineReadiness() {
|
||||
return apiClient.get<PipelineReadiness[]>('admin/pipeline/readiness').then((r) => r.data);
|
||||
}
|
||||
|
||||
export function toggleJob(jobName: string, enabled: boolean) {
|
||||
return apiClient
|
||||
.put<{ message: string }>(`admin/jobs/${jobName}/toggle`, { enabled })
|
||||
@@ -69,7 +131,7 @@ export function toggleJob(jobName: string, enabled: boolean) {
|
||||
|
||||
export function triggerJob(jobName: string) {
|
||||
return apiClient
|
||||
.post<{ message: string }>(`admin/jobs/${jobName}/trigger`)
|
||||
.post<TriggerJobResponse>(`admin/jobs/${jobName}/trigger`)
|
||||
.then((r) => r.data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
import apiClient from './client';
|
||||
|
||||
export interface IngestionSourceResult {
|
||||
status: 'ok' | 'error' | 'skipped';
|
||||
message?: string | null;
|
||||
records?: number;
|
||||
classification?: string;
|
||||
confidence?: number;
|
||||
}
|
||||
|
||||
export interface FetchDataResult {
|
||||
symbol: string;
|
||||
sources: Record<string, IngestionSourceResult>;
|
||||
}
|
||||
|
||||
export function fetchData(symbol: string) {
|
||||
return apiClient
|
||||
.post<{ message: string }>(`ingestion/fetch/${symbol}`)
|
||||
.post<FetchDataResult>(`ingestion/fetch/${symbol}`)
|
||||
.then((r) => r.data);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
import apiClient from './client';
|
||||
import type { TradeSetup } from '../lib/types';
|
||||
|
||||
export function list() {
|
||||
return apiClient.get<TradeSetup[]>('trades').then((r) => r.data);
|
||||
export interface TradeListParams {
|
||||
direction?: 'long' | 'short';
|
||||
min_confidence?: number;
|
||||
recommended_action?: 'LONG_HIGH' | 'LONG_MODERATE' | 'SHORT_HIGH' | 'SHORT_MODERATE' | 'NEUTRAL';
|
||||
}
|
||||
|
||||
export function list(params?: TradeListParams) {
|
||||
return apiClient.get<TradeSetup[]>('trades', { params }).then((r) => r.data);
|
||||
}
|
||||
|
||||
export function bySymbol(symbol: string) {
|
||||
return apiClient.get<TradeSetup[]>(`trades/${symbol.toUpperCase()}`).then((r) => r.data);
|
||||
}
|
||||
|
||||
export function history(symbol: string) {
|
||||
return apiClient.get<TradeSetup[]>(`trades/${symbol.toUpperCase()}/history`).then((r) => r.data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user