feat: risk

This commit is contained in:
OpenSquared
2026-07-26 14:10:49 +02:00
parent ad7ab35d1d
commit 3704724b0b
8 changed files with 719 additions and 57 deletions

View File

@@ -317,6 +317,25 @@ export const usePnlHistory = () =>
queryFn: () => api.get('/portfolio/pnl-history').then(r => r.data),
})
// P&L-vs-underlying-price payoff diagram for one position (services.portfolio_pricing.
// compute_payoff) — at-expiry (pure intrinsic) + today (current vol held fixed) curves.
export const usePositionPayoff = (posId: string, enabled: boolean) =>
useQuery({
queryKey: ['portfolio-payoff', posId],
queryFn: () => api.get(`/portfolio/positions/${posId}/payoff`).then(r => r.data),
enabled,
})
// Reprices every open position under a handful of named macro scenarios (Risk-Off,
// Risk-On, inflation persistante, dollar fort, baisse des matières premières) to surface
// when several differently-named positions are really the same underlying bet.
export const usePortfolioScenarioExposure = () =>
useQuery({
queryKey: ['portfolio-scenario-exposure'],
queryFn: () => api.get('/portfolio/scenario-exposure').then(r => r.data),
staleTime: 5 * 60_000,
})
export const useAddPosition = () => {
const qc = useQueryClient()
return useMutation({