feat: saxo history
This commit is contained in:
@@ -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 = () =>
|
||||
|
||||
Reference in New Issue
Block a user