export type GetApiFinancialDatasetsPricesArgs = {ticker: string, interval: string, start_date: string, end_date: string, cursor?: string | undefined}; export type GetApiFinancialDatasetsPricesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get end-of-day (EOD) historical price data for stocks. * * GET /financial-datasets/prices */ export const getApiFinancialDatasetsPrices = async (args: GetApiFinancialDatasetsPricesArgs, options?: GetApiFinancialDatasetsPricesOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.ticker != null) query.append("ticker", String(args.ticker)) if (args.interval != null) query.append("interval", String(args.interval)) if (args.start_date != null) query.append("start_date", String(args.start_date)) if (args.end_date != null) query.append("end_date", String(args.end_date)) if (args.cursor != null) query.append("cursor", String(args.cursor)) const url = `${baseUrl.replace(/\/+$/, '')}/financial-datasets/prices${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 };