export type GetApiV1OptionsContractDailyContractArgs = {contract: string, from: string, to: string}; export type GetApiV1OptionsContractDailyContractOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Daily EOD series for a single option contract (on-demand materialization) * * GET /v1/options/contract-daily/{contract} */ export const getApiV1OptionsContractDailyContract = async (args: GetApiV1OptionsContractDailyContractArgs, options?: GetApiV1OptionsContractDailyContractOptions) => { const {baseUrl = "https://api.yehangshe.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/options/contract-daily/${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 };