6da65b8d8f
Admin-configurable thresholds (min R:R, default 2.0; min confidence, default 70%) defining what counts as an actionable signal: - Admin Settings: new Activation Thresholds panel (GET/PUT /admin/settings/activation) - GET /trades/activation exposes values to all users with access - Signals/Setups: filters initialize from activation values - Track Record: "Qualified signals only" toggle (default on) via min_rr/min_confidence params on /trades/performance; the confidence breakdown always covers the full population so the thresholds can be validated against outcomes - Dashboard: "Qualified" metric and qualified-first Top Setups - Outcome evaluator unchanged: every setup is still evaluated Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
159 lines
4.1 KiB
TypeScript
159 lines
4.1 KiB
TypeScript
import apiClient from './client';
|
|
import type {
|
|
ActivationConfig,
|
|
AdminUser,
|
|
PipelineReadiness,
|
|
RecommendationConfig,
|
|
SystemSetting,
|
|
TickerUniverse,
|
|
TickerUniverseBootstrapResult,
|
|
TickerUniverseSetting,
|
|
} from '../lib/types';
|
|
|
|
// Users
|
|
export function listUsers() {
|
|
return apiClient.get<AdminUser[]>('admin/users').then((r) => r.data);
|
|
}
|
|
|
|
export function createUser(data: {
|
|
username: string;
|
|
password: string;
|
|
role: string;
|
|
has_access: boolean;
|
|
}) {
|
|
return apiClient.post<AdminUser>('admin/users', data).then((r) => r.data);
|
|
}
|
|
|
|
export function updateAccess(userId: number, hasAccess: boolean) {
|
|
return apiClient
|
|
.put<{ message: string }>(`admin/users/${userId}/access`, {
|
|
has_access: hasAccess,
|
|
})
|
|
.then((r) => r.data);
|
|
}
|
|
|
|
export function resetPassword(userId: number, password: string) {
|
|
return apiClient
|
|
.put<{ message: string }>(`admin/users/${userId}/password`, { password })
|
|
.then((r) => r.data);
|
|
}
|
|
|
|
// Settings
|
|
export function listSettings() {
|
|
return apiClient
|
|
.get<SystemSetting[]>('admin/settings')
|
|
.then((r) => r.data);
|
|
}
|
|
|
|
export function updateSetting(key: string, value: string) {
|
|
return apiClient
|
|
.put<{ message: string }>(`admin/settings/${key}`, { value })
|
|
.then((r) => r.data);
|
|
}
|
|
|
|
export function updateRegistration(enabled: boolean) {
|
|
return apiClient
|
|
.put<{ message: string }>('admin/settings/registration', { enabled })
|
|
.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 getActivationSettings() {
|
|
return apiClient
|
|
.get<ActivationConfig>('admin/settings/activation')
|
|
.then((r) => r.data);
|
|
}
|
|
|
|
export function updateActivationSettings(payload: Partial<ActivationConfig>) {
|
|
return apiClient
|
|
.put<ActivationConfig>('admin/settings/activation', 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;
|
|
label: string;
|
|
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 })
|
|
.then((r) => r.data);
|
|
}
|
|
|
|
export function triggerJob(jobName: string) {
|
|
return apiClient
|
|
.post<TriggerJobResponse>(`admin/jobs/${jobName}/trigger`)
|
|
.then((r) => r.data);
|
|
}
|
|
|
|
// Data cleanup
|
|
export function cleanupData(olderThanDays: number) {
|
|
return apiClient
|
|
.post<{ message: string }>('admin/data/cleanup', {
|
|
older_than_days: olderThanDays,
|
|
})
|
|
.then((r) => r.data);
|
|
}
|