export type UpdateApiV2UserAccountsServerAccountIdTradesIdArgs = {server: 'oanda' | 'oanda-demo' | 'otms' | 'v20' | 'v20-demo' | 'oj' | 'oj-demo' | 'opt' | 'ftmo-1', accountId: string, id: string, body: {instrument?: string | undefined, stopLoss?: number | undefined, takeProfit?: number | undefined, stopLossType?: ('NORMAL' | 'GUARANTEED') | undefined, trailingStop?: number | undefined, trackingData?: ({instrumentCategory?: string | undefined, instrumentCategoryCountry?: string | undefined, isCFD?: boolean | undefined}) | undefined}}; export type UpdateApiV2UserAccountsServerAccountIdTradesIdOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * PUT /v2/user/accounts/{server}/{accountId}/trades/{id} */ export const updateApiV2UserAccountsServerAccountIdTradesId = async (args: UpdateApiV2UserAccountsServerAccountIdTradesIdArgs, options: UpdateApiV2UserAccountsServerAccountIdTradesIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/user/accounts/${encodeURIComponent(String(args.server))}/${encodeURIComponent(String(args.accountId))}/trades/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };