Migration Tool¶
The migration tool provides a controlled import flow for creating accounts and importing closed BUY/SELL history. It is available through the authenticated manager TCP API and is restricted to SuperAdmins. A migration is first validated in a preview job; data is applied only after an explicit apply request.
Workflow¶
- Normalize source CSV, XLSX, or JSON data into the JSON row format described by the relevant account or closed trade guide.
- Call
MngPreviewMigration. The request accepts 1–1000 rows and returns a safe job snapshot. Invalid rows are reported with zero-based row indexes and field-specific errors. An invalid preview cannot be applied. - Review the validation results and, for closed trades, the per-account balance summaries. Call
MngApplyMigrationwith the preview job ID to enqueue the exact reviewed data. - Poll
MngGetMigrationuntil the job reaches a terminal status.MngGetMigrationslists job summaries. - Remove a non-active job with
MngDeleteMigrationwhen it is no longer needed.
A job can be ready, invalid, queued, running, completed, failed, or interrupted. A 202 apply response means the job was queued in RAM for background processing. The worker persists the queued state before mutation; the response does not confirm persistence or completion. A completed job means the account/trade batch committed; the job-status write can become visible shortly afterward. A failed or interrupted job may be explicitly retried using the same migration ID; the operation is idempotent for that job.
Safety and scope¶
- Imports create accounts only; they do not overwrite existing accounts. Account rows do not set balance, credit, bonus, or group default deposits.
- Closed trades target existing accounts and symbols. Imported source order identifiers are retained only as source references; the platform assigns new order numbers.
- The closed-trade flow preserves each target account's current balance using an ordinary closed balance-correction record committed with the imported history. Review
summariesbefore applying. - Closed-history commit uses a brief platform-wide restore barrier. If another restore/reconciliation operation is in flight, the migration can be rejected or fail and should be checked before retrying.
- Preview and job reads return validation metadata and safe results, never raw input rows or password hashes. Treat the manager API connection and the BackOffice import screen as privileged administrative tools.
- Keep each input batch at or below 1000 rows. Split larger source files into separately reviewed migrations.
Errors¶
Validation errors are reported in the job errors array as {row,field,error}. row is zero-based; field can be empty for row-level or global validation errors. Account validation codes include INVALID_GROUP, MIGRATION_INVALID_ACCOUNT, MIGRATION_INVALID_CUSTOMER, MIGRATION_ACCOUNT_BALANCE_NOT_SUPPORTED, MIGRATION_GUEST_NOT_SUPPORTED, PASSWORD_POLICY_VIOLATION, SECURITY_GUARD_UNAVAILABLE, MIGRATION_PASSWORD_PREPARATION_FAILED, MIGRATION_LOGIN_EXISTS, and MIGRATION_DUPLICATE_SOURCE. Apply-time account failures may include MIGRATION_PASSWORD_POLICY_CHANGED, MIGRATION_PERSIST_FAILED, MIGRATION_ACCOUNT_APPLY_REJECTED, or MIGRATION_ACCOUNT_APPLY_FAILED. Closed-trade validation codes include MIGRATION_INVALID_LOGIN, MIGRATION_INVALID_COMMAND, MIGRATION_INVALID_VOLUME, MIGRATION_INVALID_SYMBOL, MIGRATION_INVALID_TIME, MIGRATION_INVALID_PRICE, MIGRATION_INVALID_AMOUNT, MIGRATION_INVALID_ROW, ACCOUNT_NOT_AVAILABLE, MIGRATION_GUEST_NOT_SUPPORTED, MIGRATION_SYMBOL_NOT_FOUND, MIGRATION_PREVIEW_FAILED, MIGRATION_INVALID_TRADE, MIGRATION_INVALID_ROWS, MIGRATION_ACCOUNT_NOT_AVAILABLE, MIGRATION_GROUP_NOT_AVAILABLE, MIGRATION_SYMBOL_NOT_AVAILABLE, MIGRATION_BALANCE_RECONCILIATION_REQUIRED, MIGRATION_DUPLICATE_SOURCE, and MIGRATION_INVALID_SOURCE_ID. Apply-time history failures may include MIGRATION_INVALID_BATCH, MIGRATION_BATCH_CONFLICT, MIGRATION_QUIESCENCE_REQUIRED, MIGRATION_TRADE_PIPELINE_BUSY, MIGRATION_ORDER_CAPACITY_EXCEEDED, or MIGRATION_STORAGE_UNAVAILABLE.
Command-level failures use the standard TCP envelope with extID, numeric status, and a data.error code. Authentication and manager permission checks can also reject the request (401/403). Command errors are:
| Command | Status and error |
|---|---|
MngPreviewMigration |
400 MIGRATION_INVALID_REQUEST; 413 MIGRATION_PAYLOAD_TOO_LARGE; 409 MIGRATION_JOB_LIMIT; 409 MIGRATION_DUPLICATE_BATCH; 503 MIGRATION_UNAVAILABLE; 403 NOT_ENOUGH_RIGHTS. |
MngApplyMigration |
400 MIGRATION_INVALID_ID; 404 MIGRATION_NOT_FOUND; 409 MIGRATION_NOT_READY; 409 MIGRATION_DUPLICATE_BATCH; 409 MIGRATION_RESULT_NOT_AVAILABLE; 503 MIGRATION_UNAVAILABLE; 403 NOT_ENOUGH_RIGHTS. |
MngGetMigration |
400 MIGRATION_INVALID_ID; 404 MIGRATION_NOT_FOUND; 503 MIGRATION_UNAVAILABLE; 403 NOT_ENOUGH_RIGHTS. |
MngGetMigrations |
503 MIGRATION_UNAVAILABLE; 403 NOT_ENOUGH_RIGHTS. |
MngDeleteMigration |
400 MIGRATION_INVALID_ID; 404 MIGRATION_NOT_FOUND; 409 MIGRATION_BUSY; 503 MIGRATION_UNAVAILABLE; 403 NOT_ENOUGH_RIGHTS. |
For example, a rejected request is returned as:
{"extID":"mig-apply-1","status":409,"data":{"error":"MIGRATION_NOT_READY"}}
Asynchronous apply failures are recorded in the job's error field, for example MIGRATION_PLATFORM_BUSY, MIGRATION_PERSIST_FAILED, or an account/history batch failure code. Check the job instead of retrying blindly.
BackOffice¶
BackOffice provides source-file selection, field mapping, preview, explicit confirmation, and migration history. See the Backoffice migration guide.
Duplicate and recovery boundaries¶
Applying the same ID is idempotent. The server also reserves a fingerprint of normalized prepared rows (excluding password hashes and password-policy fingerprints). A second batch with that same fingerprint is rejected as MIGRATION_DUPLICATE_BATCH; completing or deleting its job record does not remove a committed reservation. This checks an identical prepared batch, not overlapping rows across different files or differently reordered batches. Source IDs remain important for operator reconciliation. Deleting an uncommitted failed job releases its reservation so corrected preparation is possible.
After a restart, reads reconcile interrupted jobs against the account/trade receipt kept with the imported rows. A committed receipt returns the completed result even if the job-status write was interrupted. MIGRATION_APPLY_STATUS_UNKNOWN means the account worker did not answer within the monitoring interval; inspect the same job instead of submitting a new batch. MIGRATION_RESULT_NOT_AVAILABLE indicates that a previously completed result is no longer present, for example after restoring older account/trade data; automatic reapplication is refused.
The explicit correction is an ordinary financial-history record, so it is visible in cash-flow reports. It is not hidden from accounting. v1 does not provide a mode that changes the existing account balance.