feat: option
This commit is contained in:
@@ -1706,6 +1706,25 @@ export const useSnapshotSaxoNow = () =>
|
||||
mutationFn: (symbol: string) => api.post(`/saxo/snapshot-now/${encodeURIComponent(symbol)}`).then(r => r.data),
|
||||
})
|
||||
|
||||
export const useSnapshotAllSaxoNow = () =>
|
||||
useMutation({
|
||||
mutationFn: () => api.post('/saxo/snapshot-now').then(r => r.data as { results: Record<string, number> }),
|
||||
})
|
||||
|
||||
export const useSaxoSettings = () =>
|
||||
useQuery<{ snapshot_minutes: number }>({
|
||||
queryKey: ['saxo-settings'],
|
||||
queryFn: () => api.get('/saxo/settings').then(r => r.data),
|
||||
})
|
||||
|
||||
export const useUpdateSaxoSettings = () => {
|
||||
const qc = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: (snapshotMinutes: number) => api.put('/saxo/settings', { snapshot_minutes: snapshotMinutes }).then(r => r.data),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ['saxo-settings'] }),
|
||||
})
|
||||
}
|
||||
|
||||
export type SaxoSnapshotRow = {
|
||||
id: string; symbol: string; snapshot_date: string; spot: number | null
|
||||
expiry_date: string; strike: number; option_type: 'call' | 'put'
|
||||
@@ -1745,11 +1764,13 @@ export const useValidateSaxoWatchlist = () =>
|
||||
export type SaxoCatalogEntry = { uic: number; symbol: string; asset_type: string; description: string; updated_at: string }
|
||||
export type SaxoCatalogSummary = { asset_type: string; count: number; last_refreshed: string }
|
||||
|
||||
export const useSaxoCatalog = (assetType?: string, q?: string) =>
|
||||
export const useSaxoCatalog = (assetType?: string, q?: string, opts?: { enabled?: boolean; limit?: number }) =>
|
||||
useQuery<SaxoCatalogEntry[]>({
|
||||
queryKey: ['saxo-catalog', assetType, q],
|
||||
queryFn: () => api.get('/saxo/catalog', { params: { ...(assetType ? { asset_type: assetType } : {}), ...(q ? { q } : {}) } }).then(r => r.data),
|
||||
enabled: !!(assetType || q),
|
||||
queryKey: ['saxo-catalog', assetType, q, opts?.limit],
|
||||
queryFn: () => api.get('/saxo/catalog', {
|
||||
params: { ...(assetType ? { asset_type: assetType } : {}), ...(q ? { q } : {}), ...(opts?.limit ? { limit: opts.limit } : {}) },
|
||||
}).then(r => r.data),
|
||||
enabled: opts?.enabled ?? !!(assetType || q),
|
||||
})
|
||||
|
||||
export const useSaxoCatalogSummary = () =>
|
||||
|
||||
Reference in New Issue
Block a user