export type GetApiV1FlowContractsContractSymbolBarsArgs = {contract_symbol: string, session_date?: string | undefined, series?: ('contract' | 'premium') | undefined, limit?: number | undefined, cursor?: string | undefined}; export type GetApiV1FlowContractsContractSymbolBarsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Intraday contract or net-premium bars for one option contract, paged at up to 100 rows. ET dates use YYYY-MM-DD. * * GET /v1/flow/contracts/{contract_symbol}/bars */ export const getApiV1FlowContractsContractSymbolBars = async (args: GetApiV1FlowContractsContractSymbolBarsArgs, options?: GetApiV1FlowContractsContractSymbolBarsOptions) => { const {baseUrl = "https://api.yehangshe.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.session_date != null) query.append("session_date", String(args.session_date)) if (args.series != null) query.append("series", String(args.series)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/flow/contracts/${encodeURIComponent(String(args.contract_symbol))}/bars${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 };