Production-ready Python trading bot for the Robinhood Crypto Trading API. Supports secure Ed25519 authentication, paper trading, risk checks, market data, order placement, and a modular strategy layer for future automation.
Robinhood also offers Agentic Trading for AI agents via MCP. This bot uses the direct Crypto Trading API, which is ideal for custom Python strategies and full control over execution.
- Ed25519 request signing per official Robinhood docs
- Account, holdings, market data, and order endpoints (v1 default, v2 optional)
- Paper trading mode (enabled by default)
- Risk manager with order-size and position limits
- CLI for status, balances, prices, and manual orders
- RSI indicator and simple strategy signals (no auto-execution by default)
- Structured logging with sensitive-data redaction
- Unit tests with mocked API responses
Market Data
↓
Strategy
↓
Trading Signal
↓
Risk Manager
↓
Execution Engine
↓
Robinhood API
cd /root/Jipred/Robinhood-bot
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtWindows:
.venv\Scripts\activate
pip install -r requirements.txtCopy the example file and fill in your credentials:
cp .env.example .envConfigure .env:
BASE64_PRIVATE_KEY=
PUBLIC_KEY=
API_KEY=
TRADING_SYMBOL=DOGE-USD
PAPER_TRADING=true
TRADING_ENABLED=falseNever commit .env or share your private key. Robinhood will never ask for it.
- Sign in to Robinhood web classic and open your crypto account settings.
- Select Add key and paste your locally generated public key.
- Enable the API actions you need (read account, market data, place orders).
- Save the issued API key in
.env.
Generate an Ed25519 key pair locally:
python3 - <<'PY'
import base64
import nacl.signing
private_key = nacl.signing.SigningKey.generate()
public_key = private_key.verify_key
print("BASE64_PRIVATE_KEY=" + base64.b64encode(private_key.encode()).decode())
print("PUBLIC_KEY=" + base64.b64encode(public_key.encode()).decode())
PYAuthentication uses these headers on every request:
x-api-keyx-timestamp(Unix seconds, valid for 30 seconds)x-signature(Ed25519 signature of{api_key}{timestamp}{path}{METHOD}{body})
Official docs: Robinhood Crypto Trading API
python main.py statusExample output:
Robinhood Trading Bot
---------------------
Connection: OK
Account: OK
Trading Mode: PAPER
Symbol: DOGE-USD
Buying Power: $100.00
Position: 0 DOGE
python main.py account
python main.py balance
python main.py price DOGE-USD
python main.py position DOGE-USD
python main.py pairs
python main.py signal DOGE-USD
python main.py buy DOGE-USD --quantity 1
python main.py sell DOGE-USD --quantity 1
python main.py buy DOGE-USD --quantity 1 --type limit --price 0.20Paper trading is on by default:
PAPER_TRADING=trueIn paper mode, orders are simulated and logged as:
[PAPER] BUY 1 DOGE-USD
No real orders are sent to Robinhood.
Live trading is risky. Only enable it after thorough testing.
Requirements:
PAPER_TRADING=false
TRADING_ENABLED=trueThe risk manager enforces:
- Valid symbol and quantity
- Max order size (
MAX_ORDER_AMOUNT_USD) - Max position size (
MAX_POSITION_USD) - Sufficient buying power / sell balance
- No duplicate orders
Automated strategy execution additionally requires:
AUTO_TRADE=trueThe bot includes:
calculate_rsi()instrategy/indicators.pySimpleStrategyinstrategy/simple_strategy.py
Signals return BUY, SELL, or HOLD with a confidence score. Strategies do not auto-trade unless AUTO_TRADE=true.
Future strategies (RSI, EMA, MACD, momentum, grid, DCA, AI) can be added under strategy/ without changing the API client.
pytest -qTests mock the Robinhood API and never submit real trades.
Robinhood-bot/
├── main.py
├── config/settings.py
├── robinhood/
│ ├── authentication.py
│ ├── client.py
│ ├── account.py
│ ├── market.py
│ └── orders.py
├── strategy/
├── execution/
├── utils/
└── tests/
- Credentials load from
.envonly - Private keys are never logged
- HTTPS is used for all API calls
- Paper trading is the default
- Live trading requires explicit opt-in
Cryptocurrency trading involves significant risk, including possible loss of principal. AI-driven or automated strategies may behave unexpectedly. You are responsible for monitoring account activity and ensuring the bot operates as intended.