feat: instrument model

This commit is contained in:
OpenSquared
2026-07-03 09:59:26 +02:00
parent 980c797f53
commit f4e57e9d84
3 changed files with 139 additions and 180 deletions

View File

@@ -120,22 +120,17 @@ interface EventDetail {
}
interface CalendarEvent {
analysis_id: number
event_id: number
title: string
start_date: string
date: string
event_time: string
currency: string
impact: string
event_name: string
label: string
actual_value: string | null
forecast_value: string | null
previous_value: string | null
category: string
is_future: boolean
days_offset: number
pip_prediction: number
lifecycle_factor: number
remaining_pips: number
calibration: {
absorption_days: number
rise_days: number
plateau_days: number
decay_type: string
}
}
// ── Constants ─────────────────────────────────────────────────────────────────
@@ -1215,19 +1210,19 @@ function TimelineView({ instrument }: { instrument: string }) {
const r = await api.get<CalendarEvent[]>(
`/instrument-models/${instrument}/calendar-events?days_back=365&days_forward=90`
)
const imported: VirtualEventForm[] = r.data.map(ev => ({
id: ev.analysis_id.toString(),
date: ev.start_date,
const imported: VirtualEventForm[] = r.data.map((ev, i) => ({
id: `ff_${ev.date}_${ev.currency}_${i}`,
date: ev.date,
category: ev.category,
pips: ev.pip_prediction,
label: ev.title || ev.category,
absorption_days: ev.calibration.absorption_days,
rise_days: ev.calibration.rise_days,
plateau_days: ev.calibration.plateau_days,
decay_type: ev.calibration.decay_type,
pips: 0, // utilisateur saisit la magnitude
label: ev.label,
absorption_days: 14,
rise_days: 1,
plateau_days: 0,
decay_type: 'exp',
}))
if (imported.length === 0) {
setCalMsg('Aucun event analysé pour cet instrument utilisez CausalLab d\'abord')
setCalMsg('Aucun event FF calendrier (high/medium) pour cette période sync en cours ou calendrier vide')
} else {
setVirtuals(prev => {
const existingIds = new Set(prev.map(v => v.id))