Paper trading is one of the best ways to validate a strategy without risking real capital. The problem: most setups are either too manual (spreadsheets) or too heavyweight (commercial platforms with lock-in). This post walks through TradeSight - a lightweight, open-source Python bot that runs 4 concurrent strategies against Alpaca's paper trading API.
Alpaca gives you a free paper trading API that mirrors real market conditions - real prices, realistic fills, market hours enforcement. No signup fee, no monthly cost. Their Python SDK (alpaca-py) handles authentication, order submission, and position tracking cleanly.
pip install alpaca-py pandas numpy
TradeSight runs 4 strategies in parallel, each managing its own position slice:
import pandas as pd
from alpaca.data.historical import StockHistoricalDataClient
from alpaca.data.requests import StockBarsRequest
from alpaca.data.timeframe import TimeFrame
def get_macd_signal(symbol, api_key, secret_key):
client = StockHistoricalDataClient(api_key, secret_key)
request = StockBarsRequest(
symbol_or_symbols=symbol,
timeframe=TimeFrame.Hour,
limit=100
)
bars = client.get_stock_bars(request).df
close = bars["close"]
ema_fast = close.ewm(span=12, adjust=False).mean()
ema_slow = close.ewm(span=26, adjust=False).mean()
macd = ema_fast - ema_slow
signal = macd.ewm(span=9, adjust=False).mean()
if macd.iloc[-1] > signal.iloc[-1] and macd.iloc[-2] <= signal.iloc[-2]:
return "BUY"
elif macd.iloc[-1] < signal.iloc[-1] and macd.iloc[-2] >= signal.iloc[-2]:
return "SELL"
return "HOLD"
| Strategy | Net P&L | Top Trade | Notes |
|---|---|---|---|
| MACD Crossover | +.89 | JPM +.12 | Strong in trending regime |
| RSI Mean Reversion | -.77 | - | High VIX kills mean reversion |
| VWAP Reversion | -/bin/bash.75 | - | 0% win rate this period |
| Bollinger Breakout | +.44 | NVDA +.90 | More breakouts in volatile market |
In a high-VIX environment, momentum strategies outperform mean-reversion plays. Mean reversion assumes prices return to equilibrium - that breaks down in volatile regimes.
git clone https://github.com/rmbell09-lang/tradesight
cd tradesight
cp .env.example .env
# Add Alpaca paper trading API key + secret
pip install -r requirements.txt
python paper_trader.py
TradeSight is MIT-licensed. Fork it, modify it, run your own strategies. github.com/rmbell09-lang/tradesight
Regime detection is the obvious next step - automatically weighting strategies based on market conditions. When VIX exceeds 20, reduce RSI allocation and increase MACD weight. Also planning WebSocket reconnect logic and a 7-day ticker cooldown after stop-losses.
Building something similar? Open an issue or star the repo.