Schwab Setup Guide
Time: 15 minutes | Difficulty: Advanced | Market: Equities Mode: Full automation (conditional) | API: Schwab Trader API (REST + Streaming) | Docs: developer.schwab.com
This guide wires a Schwab stock trading bot to the Schwab Trader API using the botwir3 runtime. Configure API credentials, connect to US equities, and run automated trading strategies locally.
⚠ Access requirements
Schwab requires developer application approval before API trading access is granted. This may include:
- Registering a developer application at developer.schwab.com
- Approval process (typically 1-3 business days)
- OAuth2 authentication with token refresh (30-minute access tokens, 7-day refresh tokens)
- Non-commercial use terms for individual accounts
Schwab Developer Portal — Application Registration
The user is responsible for obtaining appropriate access and complying with all platform terms.
Before you start
Verify that automated operation is permitted under Schwab's current terms of service before deploying. The Schwab Trader API replaced the legacy TD Ameritrade API. botwir3 provides tools for building structured automation. The user is responsible for compliance with the platform's terms and all applicable regulations.
Schwab Terms of Service | Last verified: May 2026
What you need
- A Schwab brokerage account
- A registered developer application (approved)
- OAuth2 client ID and secret from the developer portal
- The botwir3 runtime downloaded and unzipped
- A strategy config file from the builder
Step 1: Create API credentials
- Register at developer.schwab.com
- Create a new application under My Apps
- Set the callback URL to
https://127.0.0.1(for local OAuth flow) - Wait for approval (1-3 business days)
- Once approved, note the Client ID and Client Secret
- Complete the OAuth2 authorization flow to obtain access and refresh tokens
Permissions required: Trading access is granted through the Schwab Trader API — Individual product. Permissions to disable: N/A. Withdrawal is not available through the API.
🔒 Security. OAuth2 access tokens expire after 30 minutes and must be refreshed using the 7-day refresh token. The bot handles token refresh automatically. Credentials are stored in a local config file and are not transmitted to botwir3 or any third party. botwir3 never sees, stores, or has access to platform credentials.
Step 2: Configure the adapter
Create adapter.json in the bot directory:
{
"adapter": "schwab",
"credentials": {
"client_id": "paste-client-id-here",
"client_secret": "paste-client-secret-here",
"refresh_token": "paste-refresh-token-here"
},
"trading_pair": "AAPL",
"environment": "live",
"rate_limit_ms": 500
}
Common symbols: AAPL, TSLA, SPY, QQQ, MSFT, NVDA. Schwab uses standard ticker symbols.
API keys are stored in a local config file on the machine running the bot. They are not transmitted to botwir3 or any third party. botwir3 never sees, stores, or has access to platform credentials.
Step 3: Test the connection
botwir3 test --adapter schwab
Expected output:
[botwir3] Adapter: schwab
[botwir3] Connection: OK
[botwir3] OAuth2: token valid (refreshes automatically)
[botwir3] Permissions: trading
[botwir3] Rate limit: per API documentation
Step 4: Start the bot
botwir3 start --config my-strategy.json
The runtime loads the strategy, computes the spec hash, connects to Schwab via the local OAuth2 credentials, and begins evaluating signals. The gate function compares proposed actions against the configured spec. The user is responsible for monitoring the bot and verifying execution outcomes.
Rate limits and considerations
| Endpoint | Limit | Notes |
|---|---|---|
| REST API | Rate-limited per documentation | Applies to all endpoints. |
| Streaming | Per connection | Real-time quotes and order updates. |
| OAuth2 tokens | 30-minute access / 7-day refresh | Bot handles refresh automatically. Refresh tokens must be regenerated after 7 days of inactivity. |
ℹ Token management. The 7-day refresh token expires if not used within 7 days. If the bot is stopped for longer than 7 days, the OAuth2 authorization flow must be completed again to obtain a new refresh token.
Pattern Day Trader rule. Accounts under $25,000 are subject to FINRA's Pattern Day Trader rule. The user is responsible for understanding and configuring strategy constraints accordingly.
Common Schwab bot configurations include long-term DCA into index funds (SPY, QQQ), momentum strategies on large-cap equities, and options strategies for accounts with options approval. All actions and decisions are recorded in the local ledger.
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
CONNECTION_REFUSED | OAuth2 token expired or invalid | Re-run the OAuth2 authorization flow to obtain new tokens |
TOKEN_REFRESH_FAILED | Refresh token expired (>7 days inactive) | Complete the full OAuth2 authorization flow again |
APP_NOT_APPROVED | Developer application still pending | Wait for approval (1-3 business days) or check developer portal status |
PERMISSION_DENIED | Account not enabled for the requested operation | Verify account permissions in the Schwab brokerage dashboard |
MANDATE_INTEGRITY_VIOLATION | Config file modified while bot is running | Stop the bot, verify config, restart |
Related guides
- Alpaca Setup Guide — equities, API-first, no approval required
- Interactive Brokers Setup Guide — equities, multi-asset, global
- TradingView → Broker Setup Guide — route TradingView alerts to Schwab
One bot. $129. No subscription. No $749/mo platform. → Build for Schwab