export type GetApiApiV1PricesSymbolHistoryArgs = {symbol: string, startTime?: number | undefined, endTime: number, interval: '1Min' | '3Min' | '5Min' | '15Min' | '1H' | '1D' | '1W', adjustment?: ('raw' | 'split' | 'dividend' | 'spin-off' | 'all') | undefined, limit?: number | undefined}; export type GetApiApiV1PricesSymbolHistoryOptions = {baseUrl?: string | undefined, TradingApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get historical price bars * * GET /api/v1/prices/{symbol}/history * * Also accepts auth: TradingApiNonce, TradingApiTimestamp, TradingApiSignature, ApiChainId, ApiProductType */ export const getApiApiV1PricesSymbolHistory = async (args: GetApiApiV1PricesSymbolHistoryArgs, options?: GetApiApiV1PricesSymbolHistoryOptions) => { const {baseUrl = "https://rwa-api.anchored.finance/rwa/trading", fetch: fetchFn = fetch, TradingApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.startTime != null) query.append("startTime", String(args.startTime)) if (args.endTime != null) query.append("endTime", String(args.endTime)) if (args.interval != null) query.append("interval", String(args.interval)) if (args.adjustment != null) query.append("adjustment", String(args.adjustment)) if (args.limit != null) query.append("limit", String(args.limit)) if (TradingApiKey !== undefined) headers.set("x-api-key", TradingApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/prices/${encodeURIComponent(String(args.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 res.blob() };