Spaces:
Running on Zero
Running on Zero
Download frontend/src/api.ts from deveshc23/drift-quant: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/spaces/deveshc23/drift-quant/resolve/main/frontend/src/api.ts
- Command line
-
hf download hf://spaces/deveshc23/drift-quant/frontend/src/api.ts
-
curl -L -o api.ts https://huggingface.co/spaces/deveshc23/drift-quant/resolve/main/frontend/src/api.ts
1.7 kB
| export type Metrics = Record<string, number | null>; | |
| export interface ExperimentSummary { | |
| experiment_id: string; | |
| strategy_name: string; | |
| strategy_version: string; | |
| dataset_id: string; | |
| period_start: string; | |
| period_end_exclusive: string; | |
| metrics: Metrics; | |
| } | |
| export interface EquityPoint { | |
| timestamp: string; | |
| equity: number; | |
| gross_exposure: number; | |
| } | |
| export interface Trade { | |
| symbol: string; | |
| entry_time: string; | |
| exit_time: string; | |
| quantity: number; | |
| entry_price: number; | |
| exit_price: number; | |
| gross_pnl: number; | |
| costs: number; | |
| net_pnl: number; | |
| exit_reason: string; | |
| } | |
| export interface DatasetAudit { | |
| rows: number; | |
| symbols: number; | |
| first_timestamp: string; | |
| last_timestamp: string; | |
| invalid_ohlc_rows: number; | |
| zero_volume_rows: number; | |
| intraday_unexpected_gaps: number; | |
| archive_sha256: string; | |
| } | |
| export interface Health { | |
| status: string; | |
| completed_experiments: number; | |
| dataset_audit_available: boolean; | |
| } | |
| async function request<T>(path: string): Promise<T> { | |
| const response = await fetch(path); | |
| if (!response.ok) { | |
| throw new Error(`API request failed (${response.status})`); | |
| } | |
| return response.json() as Promise<T>; | |
| } | |
| export const api = { | |
| health: () => request<Health>("/health"), | |
| audit: () => request<DatasetAudit>("/api/v1/dataset/audit"), | |
| experiments: () => request<{ items: ExperimentSummary[] }>("/api/v1/experiments?limit=100"), | |
| equity: (id: string) => | |
| request<EquityPoint[]>(`/api/v1/experiments/${encodeURIComponent(id)}/equity`), | |
| trades: (id: string, offset = 0) => | |
| request<{ items: Trade[]; total: number }>( | |
| `/api/v1/experiments/${encodeURIComponent(id)}/trades?offset=${offset}&limit=25` | |
| ) | |
| }; | |