Broker tutorials
How to Import Upstox Trades Into a Trading Journal
TradeLore's Upstox integration requests historical trades by segment and date range, normalises the response, and matches the result into the journal workflow.
Connect and request historical trades
The implementation uses an Upstox login and callback flow, then requests historical trades through the broker endpoint for configured segments and paginated date ranges. The sync combines those responses before normalising them.
Check Upstox's current developer documentation before setup; source fields, export options and API limits can change.
Imported fields and supported instruments
The normaliser retains the source trade ID, date, segment, exchange, symbol, side, quantity and price, and maps option type where supplied. The current code maps equity distinctly and handles futures/options segments according to the source response. It is safer to verify a live account's segment coverage than to assume every instrument is supported.
Historical import is request-based and paginated; the precise date window is implementation-dependent and should be checked in the current sync configuration.
Errors and security
- Reconnect when the access token or callback state is invalid.
- Inspect segment and date parameters when a session is missing.
- Compare imported totals with Upstox before reviewing performance.
- Keep credentials in the authenticated connection flow and revoke access through the broker when no longer needed.
What you need before connecting Upstox
The current Upstox workflow uses an Upstox developer app with API key, API secret and a redirect URL. TradeLore settings displays the redirect URL that must be placed in the app. Save those credentials before clicking Connect Upstox; the login route checks server configuration and saved credentials before generating the authorisation URL.
Check Upstox's current developer documentation before creating the app. App-creation steps, redirect requirements and API limits can change.
Step by step: Upstox OAuth connection
1. Open Upstox settings in TradeLore and copy the displayed redirect URL. 2. Create or open the Upstox app and set that redirect URL. 3. Save the API key and secret in TradeLore. 4. Click Connect Upstox. TradeLore generates a random state, stores it in short-lived HTTP-only cookies, and redirects to Upstox with the client ID, redirect URI and state. 5. Approve the login. 6. The callback checks the returned code and state, exchanges the code with the client ID, secret and redirect URL, encrypts the access token, saves the broker identity and returns to TradeLore.
A missing code, missing state or state mismatch stops the callback. If the token exchange is rejected, reconnect after checking the redirect URL and app credentials.
Historical sync: segments, pages and retention
The sync requests Upstox historical trades for EQ, FO, COM and CD segments. It uses a six-month retained window in the current implementation and paginates each segment with a page size of 500 until the API reports the final page. It then combines all segments before normalising them.
The normaliser keeps trade ID, trade date, exchange, segment, option type, quantity, price, expiry, strike, instrument name, symbol and transaction type where supplied. Because the current Upstox historical response exposes a date rather than an intraday timestamp in the normaliser, TradeLore sets the stored trade time to midnight for that record. Do not promise time-of-day analysis from this import without verifying the current source fields.
The six-month window is a TradeLore implementation detail, not a promise about Upstox retention. Check the current Upstox documentation before using a different date range or relying on a particular API limit.
Common errors and reconciliation
| Problem | Action |
|---|---|
| Reconnect or 401/403 | Reconnect Upstox to refresh the stored access token. |
| Missing segment | Check the source response and the requested EQ/FO/COM/CD segment. |
| Missing trade | Check date window, page metadata and broker history. |
| Wrong timestamp expectation | Remember the current normaliser uses the trade date at midnight. |
| Duplicate concern | Compare the stable user/date/trade ID used by the normaliser. |
| Incomplete row | Check trade ID, symbol, date, side, positive quantity and price. |
Validate one day and one segment first. Once totals and fields match the source, sync the remaining retained window and review the resulting trades.
Keep reading
Make review part of your trading day
Treat the first Upstox sync as a reconciliation exercise, not a reporting shortcut.
Start using TradeLore