28 lines
1022 B
Markdown
28 lines
1022 B
Markdown
# System Arm
|
|
|
|
## Daily Login
|
|
- Zerodha Kite access tokens expire daily.
|
|
- Users must complete a broker login once per trading day.
|
|
- Use `/api/broker/login` to start the login flow.
|
|
|
|
## Arm Flow
|
|
1) User logs in to Zerodha.
|
|
2) UI calls `POST /api/system/arm`.
|
|
3) Backend validates broker session and arms all active runs.
|
|
4) Scheduler resumes from the latest committed state and starts execution.
|
|
|
|
## Failure States
|
|
- Broker auth expired: `POST /api/system/arm` returns 401 with `redirect_url`.
|
|
- Run status `ERROR`: skipped and returned in `failed_runs`.
|
|
- Missing broker credentials: `/api/broker/login` returns 400.
|
|
|
|
## Recovery
|
|
- Reconnect broker via `/api/broker/login`.
|
|
- Reset runs in `ERROR` (admin or manual reset), then re-arm.
|
|
- Re-run `POST /api/system/arm` to resume.
|
|
|
|
## Determinism Guarantees
|
|
- Arm is idempotent: already `RUNNING` runs are not re-written.
|
|
- Event ledger uses logical time uniqueness to prevent duplicate events.
|
|
- Next execution is computed from stored strategy frequency and latest state.
|