export type DeleteApiRestApiV1AccountsAccountIdPositionsPositionIdArgs = {accountId: string, positionId: string, pendingOnly?: boolean | undefined}; export type DeleteApiRestApiV1AccountsAccountIdPositionsPositionIdOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Close an account position or cancel a pending order * * DELETE /rest/api/v1/accounts/{accountId}/positions/{positionId} */ export const deleteApiRestApiV1AccountsAccountIdPositionsPositionId = async (args: DeleteApiRestApiV1AccountsAccountIdPositionsPositionIdArgs, options?: DeleteApiRestApiV1AccountsAccountIdPositionsPositionIdOptions) => { const {baseUrl = "https://api.metacopier.io", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.pendingOnly != null) query.append("pendingOnly", String(args.pendingOnly)) if (ApiKeyAuth !== undefined) headers.set("X-API-KEY", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/rest/api/v1/accounts/${encodeURIComponent(String(args.accountId))}/positions/${encodeURIComponent(String(args.positionId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };