feat: saxo connector
This commit is contained in:
@@ -1741,3 +1741,30 @@ export const useValidateSaxoWatchlist = () =>
|
||||
queryFn: () => api.get('/saxo/validate').then(r => r.data),
|
||||
enabled: false,
|
||||
})
|
||||
|
||||
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) =>
|
||||
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),
|
||||
})
|
||||
|
||||
export const useSaxoCatalogSummary = () =>
|
||||
useQuery<SaxoCatalogSummary[]>({
|
||||
queryKey: ['saxo-catalog-summary'],
|
||||
queryFn: () => api.get('/saxo/catalog/summary').then(r => r.data),
|
||||
})
|
||||
|
||||
export const useRefreshSaxoCatalog = () => {
|
||||
const qc = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: (assetTypes?: string[]) => api.post('/saxo/catalog/refresh', { asset_types: assetTypes ?? null }).then(r => r.data),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ['saxo-catalog'] })
|
||||
qc.invalidateQueries({ queryKey: ['saxo-catalog-summary'] })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user