MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / createUTA

Function createUTA

ui/src/api/trading.ts:177–194  ·  view source on GitHub ↗

* Create a new UTA. The server derives the id from the preset's * fingerprintFields applied to presetConfig — the client doesn't pick * one. Returns 409 (BrokerAlreadyExistsError) if another UTA already * derives to the same id.

(uta: Omit<UTAConfig, 'id'>)

Source from the content-addressed store, hash-verified

175 * derives to the same id.
176 */
177 async createUTA(uta: Omit<UTAConfig, 'id'>): Promise<UTAConfig> {
178 const res = await fetch('/api/trading/config/uta', {
179 method: 'POST',
180 headers: { 'Content-Type': 'application/json' },
181 body: JSON.stringify(uta),
182 })
183 const body = await res.json().catch(() => ({}))
184 if (res.status === 409) {
185 const err = new Error(body.error ?? 'A UTA already exists for this broker identity') as Error & { existing?: { id: string; label: string; presetId: string } }
186 err.name = 'BrokerAlreadyExistsError'
187 err.existing = body.existing
188 throw err
189 }
190 if (!res.ok) {
191 throw new Error(body.error || `Failed to create UTA (${res.status})`)
192 }
193 return body
194 },
195
196 /**
197 * Edit an existing UTA. Cannot create — the id must already be on disk

Callers

nothing calls this directly

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected