export type GetApiV1FlowTickersTickerChainArgs = {ticker: string, session_date?: string | undefined, root?: string | undefined, limit?: number | undefined, cursor?: string | undefined}; export type GetApiV1FlowTickersTickerChainOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Ticker Flow contract-day chain, paged at up to 100 rows. ET dates use YYYY-MM-DD. * * GET /v1/flow/tickers/{ticker}/chain */ export const getApiV1FlowTickersTickerChain = async (args: GetApiV1FlowTickersTickerChainArgs, options?: GetApiV1FlowTickersTickerChainOptions) => { 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.root != null) query.append("root", String(args.root)) 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/tickers/${encodeURIComponent(String(args.ticker))}/chain${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 };