export type GetApiV2UserAccountsServerAccountIdPricesStreamArgs = {server: 'oanda' | 'oanda-demo' | 'otms' | 'v20' | 'v20-demo' | 'oj' | 'oj-demo' | 'opt' | 'ftmo-1', accountId: string, includeDepth?: boolean | undefined, includeHomeConversions?: boolean | undefined, includeDailyChanges?: boolean | undefined, instruments: Array, includeLastPrice?: boolean | undefined}; export type GetApiV2UserAccountsServerAccountIdPricesStreamOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v2/user/accounts/{server}/{accountId}/prices/stream */ export const getApiV2UserAccountsServerAccountIdPricesStream = async (args: GetApiV2UserAccountsServerAccountIdPricesStreamArgs, options: GetApiV2UserAccountsServerAccountIdPricesStreamOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/event-stream") if (args.includeDepth != null) query.append("includeDepth", String(args.includeDepth)) if (args.includeHomeConversions != null) query.append("includeHomeConversions", String(args.includeHomeConversions)) if (args.includeDailyChanges != null) query.append("includeDailyChanges", String(args.includeDailyChanges)) if (args.instruments != null) query.append("instruments", args.instruments.join(',')) if (args.includeLastPrice != null) query.append("includeLastPrice", String(args.includeLastPrice)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/user/accounts/${encodeURIComponent(String(args.server))}/${encodeURIComponent(String(args.accountId))}/prices/stream${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.text() };