export type GetApiV1FlowContractsLookupArgs = {contract_symbol: string, session_date?: string | undefined}; export type GetApiV1FlowContractsLookupOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Resolve one OCC contract symbol into its normalized contract identity and current activity. ET dates use YYYY-MM-DD. * * GET /v1/flow/contracts/lookup */ export const getApiV1FlowContractsLookup = async (args: GetApiV1FlowContractsLookupArgs, options?: GetApiV1FlowContractsLookupOptions) => { const {baseUrl = "https://api.yehangshe.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.contract_symbol != null) query.append("contract_symbol", String(args.contract_symbol)) if (args.session_date != null) query.append("session_date", String(args.session_date)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/flow/contracts/lookup${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 };