feat: instrument model
This commit is contained in:
@@ -985,6 +985,7 @@ function TimelineView({ instrument }: { instrument: string }) {
|
||||
const [whatifLoading, setWhatifLoading] = useState(false)
|
||||
const [whatifData, setWhatifData] = useState<TimelinePoint[] | null>(null)
|
||||
const [importingCal, setImportingCal] = useState(false)
|
||||
const [backfilling, setBackfilling] = useState(false)
|
||||
const [calMsg, setCalMsg] = useState<string | null>(null)
|
||||
// What-if filters
|
||||
const [filterImpact, setFilterImpact] = useState<string[]>(['high', 'medium'])
|
||||
@@ -1510,6 +1511,31 @@ function TimelineView({ instrument }: { instrument: string }) {
|
||||
className="flex items-center gap-1 text-xs text-sky-400 hover:text-sky-300 border border-sky-700/40 rounded px-2 py-0.5 transition-colors disabled:opacity-40">
|
||||
<Activity className="w-3 h-3"/> {importingCal ? '…' : 'Import calendrier'}
|
||||
</button>
|
||||
<button
|
||||
disabled={backfilling}
|
||||
onClick={async () => {
|
||||
setBackfilling(true)
|
||||
setCalMsg('Backfill en cours (peut prendre 2-3 min)…')
|
||||
try {
|
||||
// Backfill from 15 months ago to today to fill the April 2025 gap
|
||||
const fromDate = new Date()
|
||||
fromDate.setMonth(fromDate.getMonth() - 15)
|
||||
const r = await api.post<{weeks_scraped: number, total_upserted: number, weeks_skipped: number}>(
|
||||
'/instrument-models/ff-calendar/backfill',
|
||||
{ from_date: fromDate.toISOString().slice(0, 10) }
|
||||
)
|
||||
setCalMsg(`Backfill OK : ${r.data.total_upserted} events, ${r.data.weeks_scraped} semaines (${r.data.weeks_skipped} déjà remplies)`)
|
||||
} catch (e: any) {
|
||||
setCalMsg(`Erreur backfill: ${e?.response?.data?.detail ?? e?.message}`)
|
||||
} finally {
|
||||
setBackfilling(false)
|
||||
setTimeout(() => setCalMsg(null), 8000)
|
||||
}
|
||||
}}
|
||||
className="flex items-center gap-1 text-xs text-emerald-400 hover:text-emerald-300 border border-emerald-700/40 rounded px-2 py-0.5 transition-colors disabled:opacity-40"
|
||||
title="Scrape ForexFactory pour remplir les données manquantes (avril 2025 → aujourd'hui)">
|
||||
<RefreshCw className="w-3 h-3"/> {backfilling ? '…' : 'Sync historique'}
|
||||
</button>
|
||||
<button onClick={() => {
|
||||
// Guidance event : pousse la courbe depuis le début avec absorption lente
|
||||
const simStart = data[0]?.date ?? new Date().toISOString().slice(0, 10)
|
||||
|
||||
Reference in New Issue
Block a user