export type GetApiV1FlowContractsContractSymbolHistoryArgs = {contract_symbol: string, end_session_date?: string | undefined, limit?: number | undefined, include_current?: ('true' | 'false') | undefined, coverage?: 'contiguous' | undefined}; export type GetApiV1FlowContractsContractSymbolHistoryOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Up to 30 trading sessions of contract-day Flow history, back from end_session_date to the first session without Flow data. ET dates use YYYY-MM-DD. * * GET /v1/flow/contracts/{contract_symbol}/history */ export const getApiV1FlowContractsContractSymbolHistory = async (args: GetApiV1FlowContractsContractSymbolHistoryArgs, options?: GetApiV1FlowContractsContractSymbolHistoryOptions) => { const {baseUrl = "https://api.yehangshe.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.end_session_date != null) query.append("end_session_date", String(args.end_session_date)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.include_current != null) query.append("include_current", String(args.include_current)) if (args.coverage != null) query.append("coverage", String(args.coverage)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/flow/contracts/${encodeURIComponent(String(args.contract_symbol))}/history${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 };