export type GetApiFinancialDatasetsPricesSnapshotArgs = {ticker: string}; export type GetApiFinancialDatasetsPricesSnapshotOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the real-time price snapshot for a stock, including the current price, day change, and day change percent. * * GET /financial-datasets/prices/snapshot */ export const getApiFinancialDatasetsPricesSnapshot = async (args: GetApiFinancialDatasetsPricesSnapshotArgs, options?: GetApiFinancialDatasetsPricesSnapshotOptions) => { 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)) const url = `${baseUrl.replace(/\/+$/, '')}/financial-datasets/prices/snapshot${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 };