Overview
The Tradovate integration uses OAuth 2.0 to securely connect your Tradovate demo account and automatically import fill pairs (completed trades) into Deltalytix.Currently supports demo environment only. Live trading support coming soon.
Features
- OAuth 2.0 authentication flow
- Automatic access token renewal
- Fill pair synchronization (buy/sell matched trades)
- Commission tracking from fill fees
- Support for long and short positions
- Tick-based P&L calculation for futures
- Batch API requests for performance
Setup Instructions
Prerequisites
- A Tradovate demo account
- Environment variables configured:
Step 1: Initiate OAuth Flow
Start the OAuth authentication process:app/[locale]/dashboard/components/import/tradovate/actions.ts:562-619
Step 2: Handle OAuth Callback
After user authorization, handle the callback:app/[locale]/dashboard/components/import/tradovate/actions.ts:642-760
Step 3: Sync Trades
Trigger trade synchronization via API:app/api/tradovate/sync/route.ts:7-51
API Reference
POST /api/tradovate/sync
Synchronize trades from Tradovate. Request Body:GET /api/tradovate/synchronizations
Retrieve all Tradovate synchronization configurations. Response:app/api/tradovate/synchronizations/route.ts:7-28
DELETE /api/tradovate/synchronizations
Remove a Tradovate synchronization. Request Body:app/api/tradovate/synchronizations/route.ts:30-61
Authentication Flow
OAuth 2.0 Authorization Code Flow
- Authorization Request: User is redirected to Tradovate OAuth page
- Authorization Callback: Tradovate redirects back with authorization code
- Token Exchange: Exchange code for access token
- Token Storage: Access token is stored in database
app/[locale]/dashboard/components/import/tradovate/actions.ts:1163-1207
Token Renewal
Tokens are automatically renewed before expiration using therenewAccessToken endpoint:
app/[locale]/dashboard/components/import/tradovate/actions.ts:762-812
Trade Synchronization
How It Works
- Fetch Fill Pairs: Retrieve completed trades (buy/sell matches) from Tradovate
- Fetch Fill Details: Get detailed information for each fill including commission
- Fetch Contract Info: Resolve contract symbols and tick details
- Match Orders: Link fills to their originating orders
- Calculate P&L: Compute profit/loss using tick values
- Save Trades: Store trades in Deltalytix format
Fill Pair Processing
Fill pairs represent completed round-trip trades:app/[locale]/dashboard/components/import/tradovate/actions.ts:134-144
Commission Calculation
Commissions are fetched from fill fees and calculated per unit:app/[locale]/dashboard/components/import/tradovate/actions.ts:1088-1111
P&L Calculation
P&L is calculated using tick values for accurate futures pricing:app/[locale]/dashboard/components/import/tradovate/actions.ts:1051-1083
Error Handling
Common Errors
Token Expired
Token Expired
Error:
Token expiredSolution: Tokens are automatically renewed. If renewal fails, re-authenticate:OAuth Credentials Not Configured
OAuth Credentials Not Configured
Error:
Tradovate OAuth credentials not configuredSolution: Ensure environment variables are set:User Not Authenticated
User Not Authenticated
Error:
User not authenticatedSolution: Ensure user is logged in before calling sync:No Fill Pairs Returned
No Fill Pairs Returned
Error: No error, but
savedCount: 0Reason: No completed trades in Tradovate accountSolution: This is normal if there are no trades. The sync completed successfully.Debugging
Enable debug logging by setting environment variable:- OAuth flow details
- API request/response data
- Token renewal attempts
- Fill pair processing
- P&L calculations
app/[locale]/dashboard/components/import/tradovate/actions.ts:41-60
API Endpoints Used
The integration calls these Tradovate API endpoints:| Endpoint | Purpose |
|---|---|
GET /v1/user/list | Get user information |
GET /v1/account/list | List trading accounts |
GET /v1/organization/list | Get prop firm name |
GET /v1/fillPair/list | Fetch completed trades |
GET /v1/fill/items | Get fill details in batch |
GET /v1/fillFee/items | Get commission fees in batch |
GET /v1/order/items | Get order details in batch |
GET /v1/contract/item | Get contract information |
GET /auth/renewAccessToken | Renew OAuth token |
All API calls use the demo environment base URL:
https://demo.tradovateapi.comBest Practices
Token Management
Always check token expiration before syncing and renew if needed
Error Recovery
Implement retry logic with exponential backoff for API failures
Batch Requests
Use batch endpoints to minimize API calls and improve performance
Rate Limiting
Respect Tradovate rate limits with delays between batch requests
Next Steps
View Synchronizations
Manage your Tradovate connections
Configure Webhooks
Set up automatic sync triggers