export type GetApiV1OptionsQuoteContractArgs = {contract: string}; export type GetApiV1OptionsQuoteContractOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Latest known option quote (1 unit per returned quote) * * GET /v1/options/quote/{contract} */ export const getApiV1OptionsQuoteContract = async (args: GetApiV1OptionsQuoteContractArgs, options?: GetApiV1OptionsQuoteContractOptions) => { const {baseUrl = "https://api.yehangshe.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/options/quote/${encodeURIComponent(String(args.contract))}${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 };