export type GetApiV1VolatilityForecastSymbolArgs = {symbol: string, dist?: string | undefined}; export type GetApiV1VolatilityForecastSymbolOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v1/volatility/forecast/{symbol} */ export const getApiV1VolatilityForecastSymbol = async (args: GetApiV1VolatilityForecastSymbolArgs, options: GetApiV1VolatilityForecastSymbolOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.dist != null) query.append("dist", String(args.dist)) if (ApiKey !== undefined) headers.set("X-Api-Key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/volatility/forecast/${encodeURIComponent(String(args.symbol))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };