Unified Broker Interface¶
The Unified Broker Interface (UBI) logs in to ten Indian stock brokers at once and presents them as one trading account behind one REST API. Your program asks for a quote, a position or an order book once, and the answer already covers every broker. When you place an order, you name the instrument, and the API decides which broker sends it.
Start here¶
The site is split into tabs along the top. Most readers want the first card.
-
REST API endpoints
All 29 routes of the UBI API, laid out one group per page with request parameters,
curlexamples, JSON responses and status codes. -
Get started
Install the project, start Redis, MongoDB and TimescaleDB, fill in
.env, and make your first API call. -
Architecture
The three layers, the stores between them, the data shapes every broker is converted into, and why things are built the way they are.
-
Data pipelines
Follow one tick, one order update or one instrument master from the broker's server all the way to the API.
-
Brokers
Which of the ten brokers supports what, as a matrix and a chart, with each broker's peculiarities.
-
Operations
The systemd services, the daily schedule in IST, every script in
bin/, and the offline test suites.
The project in numbers¶
The table below counts what the repository holds today, so you can judge the size of each part before you read about it.
| What | Count | Where |
|---|---|---|
| Brokers | 10 | stock_brokers/api/ |
| REST API routes | 29 | unified_broker_interface/blueprints/ |
| Endpoint groups (blueprints) | 7 | session, users, brokers, exchanges, instruments, portfolio, orders |
| Synthetic order types in the order engine | 54 | unified_broker_interface/utilities/order_engine/ |
| Data stores | 3 | Redis, MongoDB, TimescaleDB |
| Offline test suites | 19 | test_runs/ |
What one API call replaces¶
Without UBI, a program that trades through several brokers has to speak each broker's own dialect. The comparison below shows what changes.
| Task | Without UBI | With UBI |
|---|---|---|
| Log in | Ten different flows, some through a headless browser and a TOTP | POST /api/session/connect once a day |
| Name an instrument | Ten different token formats and symbol spellings | One instrument_id, or exchange, segment and symbol |
| Read positions | Ten requests, ten response shapes | GET /api/portfolio/positions |
| Read a live price | Ten websocket protocols | GET /api/instruments/ltp |
| Place an order | Choose a broker, then build its own request | POST /api/orders/place; the API chooses the broker |
| Close everything in an emergency | Cancel and close at every broker by hand | POST /api/orders/flatten |
This software trades real money
The order routes send real orders to real broker accounts, and the scripts under bin/<broker>/ log in to live accounts. Read Orders before calling anything that places, changes or cancels an order.