Implements FastAPI backend with ML model support for energy trading, including price prediction models and RL-based battery trading policy. Features dashboard, trading, backtest, and settings API routes with WebSocket support for real-time updates.
Energy Trading Backend
FastAPI backend for the energy trading system with ML model support.
Setup
cd backend
pip install -r requirements.txt
cp .env.example .env
Running
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
API Documentation
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Project Structure
backend/
├── app/
│ ├── api/ # API routes and WebSocket
│ ├── services/ # Business logic services
│ ├── tasks/ # Background tasks
│ ├── ml/ # ML models and training
│ ├── models/ # Pydantic models
│ └── utils/ # Utilities
├── models/ # Trained models
├── results/ # Backtest results
└── tests/ # Tests
Training ML Models
# Train price prediction models
python -m app.ml.training.cli price --horizons 1 5 15 60
# Train RL battery policy
python -m app.ml.training.cli rl --episodes 1000
Running Tests
pytest