Mock Server
alpaca-mock is the public mock-server executable for alpaca-rust.
Run It
From an installed binary:
alpaca-mock
From the workspace:
cargo run -p alpaca-mock
Default listen address:
127.0.0.1:3847
Override it with:
ALPACA_MOCK_LISTEN_ADDR
Authentication
Trading routes require Alpaca-style auth headers:
APCA-API-KEY-IDAPCA-API-SECRET-KEY
The mock server uses the API key to isolate per-account mock state.
Public Routes
Unauthenticated:
GET /healthGET /admin/statePOST /admin/resetPOST /admin/faults/http
Authenticated trading routes:
GET /v2/accountGET /v2/account/activitiesGET /v2/account/activities/{activity_type}GET|POST|DELETE /v2/ordersGET|PATCH|DELETE /v2/orders/{order_id}GET /v2/orders:by_client_order_idGET|DELETE /v2/positionsGET|DELETE /v2/positions/{symbol_or_asset_id}POST /v2/positions/{symbol_or_contract_id}/exercisePOST /v2/positions/{symbol_or_contract_id}/do-not-exercise
Admin Endpoints
GET /admin/state
Returns the current mock-state summary.
POST /admin/reset
Clears the current mock state and fault injections.
POST /admin/faults/http
Injects a transport-like HTTP fault for authenticated trading routes.
Example:
{
"status": 503,
"message": "temporary outage"
}
Scope
The current mock server is intentionally focused on the trade mainline:
- account
- orders
- positions
- activities
It is not a generic Alpaca emulator or a replacement for live API verification.
Market Data Dependency
When order or position behavior needs live market prices, the mock server uses the alpaca-data client and real market-data credentials instead of invented price fixtures.