This project implements a full algorithmic trading simulation system with support for:
- Historical backtesting
- Real-time paper trading
- Automated strategy execution
- Portfolio state tracking
- Interactive analytics dashboard
- REST + WebSocket market data services
It uses FastAPI, Streamlit, PostgreSQL, and yFinance to recreate a realistic end-to-end trading workflow for research, experimentation, and educational purposes.
- Implements two algorithmic trading strategies:
- SMA Crossover
- RSI Momentum
- Generates deterministic buy/sell signals from historical or live data.
- Simulates virtual trading with cash, positions, and PnL tracking.
- Logs trades and equity snapshots.
- Provides complete historical performance curves.
- REST APIs for trades, equity, portfolio state, and strategy execution.
- WebSockets for streaming live ticks and portfolio updates.
- PostgreSQL storage for persistent analytics.
- Real-time equity & price charts
- Trade markers
- Portfolio metrics
- Backtest trigger button
- Live simulation controls
- FastAPI
- Streamlit
- PostgreSQL
- SQLAlchemy
- yFinance
- Plotly
- TA indicators (
ta)
/trading
├── /backend
│ ├── main.py
│ ├── api.py
│ ├── backtest.py
│ ├── database.py
│ ├── models.py
│ ├── strategies.py
│ ├── paper_trading.py
│
├── dashboard.py
├── connect.py
├── db.py
├── requirements.txt
└── /portfolio_state
git clone https://github.com/shuvivyas/Live-Trading-Simulation.git
cd Live-Trading-Simulation
python -m venv env
env\Scripts\activate (Windows)
source env/bin/activate (Linux/Mac)
pip install -r requirements.txt
- Create PostgreSQL DB:
trading - Update credentials if needed
- Initialize tables: python trading/db.py
uvicorn trading.backend.api:app --reload --port 8000
API Docs → http://127.0.0.1:8000/docs
streamlit run trading/dashboard.py
GET /api/trades
GET /api/equity
GET /api/portfolio
GET /api/run_strategy
WS /ws/market/{symbol}
WS /ws/snapshots
{ "symbol": "AAPL", "strategy": "sma_crossover", "portfolio": { "cash": 0, "position": 44.42, "equity": 11347.88 } }