feat: saxo history

This commit is contained in:
OpenSquared
2026-07-19 08:49:57 +02:00
parent d4fb15ca9a
commit e7247d4c4c
5 changed files with 131 additions and 33 deletions

View File

@@ -1752,14 +1752,25 @@ export const useDedupeSaxoHistory = () => {
})
}
export const useSaxoHistory = (symbol?: string, dateFrom?: string, dateTo?: string) =>
export const useSaxoHistory = (symbol?: string, asOf?: string) =>
useQuery<SaxoSnapshotRow[]>({
queryKey: ['saxo-history', symbol, dateFrom, dateTo],
queryKey: ['saxo-history', symbol, asOf],
queryFn: () => api.get('/saxo/history', {
params: { ...(symbol ? { symbol } : {}), ...(dateFrom ? { date_from: dateFrom } : {}), ...(dateTo ? { date_to: dateTo } : {}) },
params: { ...(symbol ? { symbol } : {}), ...(asOf ? { as_of: asOf } : {}) },
}).then(r => r.data),
})
export const useDeleteSaxoHistory = () => {
const qc = useQueryClient()
return useMutation({
mutationFn: (symbol: string) => api.delete(`/saxo/history/${encodeURIComponent(symbol)}`).then(r => r.data as { symbol: string; rows_deleted: number }),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['saxo-history'] })
qc.invalidateQueries({ queryKey: ['saxo-symbols'] })
},
})
}
export type SaxoSymbolSummary = { symbol: string; rows_count: number; first_date: string; last_date: string }
export const useSaxoSymbols = () =>