Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Robinhood Crypto Trading Bot

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.

Features

  • 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

Architecture

Market Data
     ↓
Strategy
     ↓
Trading Signal
     ↓
Risk Manager
     ↓
Execution Engine
     ↓
Robinhood API

Installation

cd /root/Jipred/Robinhood-bot
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Windows:

.venv\Scripts\activate
pip install -r requirements.txt

Environment Setup

Copy the example file and fill in your credentials:

cp .env.example .env

Configure .env:

BASE64_PRIVATE_KEY=
PUBLIC_KEY=
API_KEY=

TRADING_SYMBOL=DOGE-USD
PAPER_TRADING=true
TRADING_ENABLED=false

Never commit .env or share your private key. Robinhood will never ask for it.

Robinhood API Setup

  1. Sign in to Robinhood web classic and open your crypto account settings.
  2. Select Add key and paste your locally generated public key.
  3. Enable the API actions you need (read account, market data, place orders).
  4. 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())
PY

Authentication uses these headers on every request:

  • x-api-key
  • x-timestamp (Unix seconds, valid for 30 seconds)
  • x-signature (Ed25519 signature of {api_key}{timestamp}{path}{METHOD}{body})

Official docs: Robinhood Crypto Trading API

Test Connection

python main.py status

Example output:

Robinhood Trading Bot
---------------------
Connection: OK
Account: OK
Trading Mode: PAPER
Symbol: DOGE-USD
Buying Power: $100.00
Position: 0 DOGE

CLI Commands

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.20

Paper Trading

Paper trading is on by default:

PAPER_TRADING=true

In paper mode, orders are simulated and logged as:

[PAPER] BUY 1 DOGE-USD

No real orders are sent to Robinhood.

Live Trading

Live trading is risky. Only enable it after thorough testing.

Requirements:

PAPER_TRADING=false
TRADING_ENABLED=true

The 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=true

Strategy Development

The bot includes:

  • calculate_rsi() in strategy/indicators.py
  • SimpleStrategy in strategy/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.

Running Tests

pytest -q

Tests mock the Robinhood API and never submit real trades.

Project Structure

Robinhood-bot/
├── main.py
├── config/settings.py
├── robinhood/
│   ├── authentication.py
│   ├── client.py
│   ├── account.py
│   ├── market.py
│   └── orders.py
├── strategy/
├── execution/
├── utils/
└── tests/

Security

  • Credentials load from .env only
  • Private keys are never logged
  • HTTPS is used for all API calls
  • Paper trading is the default
  • Live trading requires explicit opt-in

Disclaimer

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.

About

Robinhood bot Robinhood Trading bot Robinhood bot Robinhood Trading bot Robinhood bot Robinhood Trading bot Robinhood bot Robinhood Trading bot Robinhood bot Robinhood Trading bot Robinhood bot Robinhood Trading bot Robinhood bot Robinhood Trading bot Robinhood bot Robinhood Trading bot Robinhood bot Robinhood Trading bot Robinhood bot Robinhood

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages