OpenAlgo MVP is a simplified version of the comprehensive algorithmic trading platform that bridges traders with major brokers through a unified API. Built with Flask, Tailwind CSS, and DaisyUI.
- β Authentication & User Management - Secure login with Argon2 password hashing
- β Order Management API - Place, modify, cancel orders with unified API
- β Real-time Dashboard - WebSocket-powered live updates
- β API Key Management - Generate and manage API keys for integrations
- β Broker Integration - Extensible broker plugin system
- π Market Data API - Real-time quotes, historical data, market depth
- π Portfolio Tracking - Positions, holdings, order book, trade book
- π Symbol Search - Search trading instruments across exchanges
- π‘ WebSocket Streaming - Real-time market data with ZeroMQ message bus
- π― API Analyzer - Test strategies without live execution (sandbox mode)
- π PnL Tracker - Real-time profit/loss monitoring with TradingView charts
- π€ ChartInk Integration - Execute strategies from ChartInk signals
- π TradingView Integration - Webhook support for TradingView alerts
- π¬ Telegram Bot - Trade notifications and command execution
- π Security Features - CORS, CSP, CSRF protection, rate limiting
- π Monitoring Tools - Latency monitor, traffic monitor, performance analytics
- Python 3.12 or higher
- Node.js 18+ (for Tailwind CSS build)
- SQLite (included with Python)
- A broker account with API access
git clone https://github.com/gitmvp-com/openalgo-mvp.git
cd openalgo-mvp# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install Python dependencies
pip install -r requirements.txt# Install Node.js dependencies
npm install
# Build Tailwind CSS
npm run build# Copy sample environment file
cp .sample.env .env
# Edit .env file with your configuration
# IMPORTANT: Generate new security keys!Generate Security Keys:
# Generate APP_KEY
python -c "import secrets; print(secrets.token_hex(32))"
# Generate API_KEY_PEPPER
python -c "import secrets; print(secrets.token_hex(32))"The database will be automatically initialized on first run.
# Development mode
python app.py
# Or use Flask directly
flask runOpen your browser and navigate to:
http://127.0.0.1:5000
# Build and run with Docker Compose
docker-compose up -d
# Access at http://localhost:5000POST /api/v1/placeorder- Place a new orderPOST /api/v1/placesmartorder- Place smart order with position sizingPOST /api/v1/modifyorder- Modify existing orderPOST /api/v1/cancelorder- Cancel specific orderPOST /api/v1/cancelallorder- Cancel all pending ordersPOST /api/v1/closeposition- Close open positionPOST /api/v1/basketorder- Execute multiple orders
POST /api/v1/funds- Get account funds and marginsPOST /api/v1/orderbook- Retrieve order bookPOST /api/v1/tradebook- Get executed tradesPOST /api/v1/positionbook- View current positionsPOST /api/v1/holdings- Get demat holdingsPOST /api/v1/openposition- Check position details
POST /api/v1/quotes- Get real-time quotesPOST /api/v1/depth- Get market depthPOST /api/v1/history- Fetch historical OHLC dataPOST /api/v1/search- Search for symbols
POST /api/v1/analyzer- Test API requests (sandbox)GET /api/v1/ping- Test API connectivity
All API requests require an API key in the header:
curl -X POST http://127.0.0.1:5000/api/v1/funds \
-H "Content-Type: application/json" \
-d '{"apikey": "your-api-key"}'-
Password Security
- Argon2 hashing (PHC winner)
- Pepper-enhanced security
-
API Key Security
- Encrypted storage with Fernet
- Hashed validation
- Time-based caching
-
Session Security
- Secure cookies
- Auto-expiry at 3:30 AM IST
- CSRF protection
-
Rate Limiting
- Login: 5/min, 25/hour
- Orders: 10/second
- API calls: 50/second
-
Browser Security
- Content Security Policy (CSP)
- CORS protection
- Secure headers
OpenAlgo MVP includes three beautiful themes:
- Light Theme - Default clean interface
- Dark Theme - Reduced eye strain for night trading
- Garden Theme - Special theme for analyzer mode
Switch themes instantly from the navbar!
The API Analyzer lets you test trading strategies risk-free:
- Enable Analyzer Mode in Settings
- All orders execute in sandbox environment
- Track virtual positions and P&L
- Test strategies without financial risk
Perfect for:
- Strategy development
- Parameter optimization
- API integration testing
- Learning algorithmic trading
Track order execution performance across brokers:
- Real-time latency tracking
- Success rate analysis
- Broker comparison
Monitor API usage and system performance:
- Endpoint-specific analytics
- Error rate tracking
- Performance metrics
Real-time profit/loss visualization:
- Intraday P&L curves
- Maximum drawdown tracking
- Interactive TradingView charts
OpenAlgo MVP supports a plugin-based broker architecture. Add brokers by:
- Creating a broker plugin in
/broker/[broker_name]/ - Implementing required API methods
- Adding broker to
VALID_BROKERSin.env
Supported broker operations:
- Authentication
- Order placement/modification/cancellation
- Market data fetching
- Position management
- WebSocket streaming
Execute ChartInk scanner strategies:
- Configure ChartInk webhook URL
- Set up strategy parameters
- Automatic trade execution on signals
Webhook-based strategy execution:
- Create TradingView alert
- Configure webhook to OpenAlgo
- Auto-execute trades from alerts
Trade from Telegram:
- Enable bot in Settings
- Connect with
/startcommand - Execute trades via chat commands
- Get real-time notifications
openalgo-mvp/
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ package.json # Node.js dependencies
βββ .sample.env # Environment template
βββ blueprints/ # Flask blueprints (routes)
β βββ auth.py # Authentication
β βββ dashboard.py # Main dashboard
β βββ orders.py # Order management
β βββ apikey.py # API key management
β βββ analyzer.py # Sandbox/analyzer
β βββ chartink.py # ChartInk integration
β βββ telegram.py # Telegram bot
β βββ ... # Other blueprints
βββ broker/ # Broker plugins
βββ database/ # Database models
βββ restx_api/ # RESTful API
βββ static/ # Static assets
β βββ css/ # Compiled CSS
β βββ js/ # JavaScript files
βββ templates/ # HTML templates
βββ utils/ # Utility functions
βββ websocket_proxy/ # WebSocket server
βββ db/ # SQLite databases
Key environment variables in .env:
# Security (REQUIRED - Generate new values!)
APP_KEY='your-app-key-here'
API_KEY_PEPPER='your-pepper-here'
# Broker Configuration
VALID_BROKERS='zerodha,angelone,upstox,...'
BROKER_API_KEY='your-broker-api-key'
BROKER_API_SECRET='your-broker-secret'
# Server Configuration
FLASK_HOST_IP='127.0.0.1'
FLASK_PORT='5000'
FLASK_ENV='development'
# WebSocket Configuration
WEBSOCKET_PORT='8765'
ZMQ_PORT='5555'
# Database URLs
DATABASE_URL='sqlite:///db/openalgo.db'
LATENCY_DATABASE_URL='sqlite:///db/latency.db'
LOGS_DATABASE_URL='sqlite:///db/logs.db'
SANDBOX_DATABASE_URL='sqlite:///db/sandbox.db'
# Security Features
CORS_ENABLED='TRUE'
CSP_ENABLED='TRUE'
CSRF_ENABLED='TRUE'
# Rate Limiting
LOGIN_RATE_LIMIT_MIN='5 per minute'
API_RATE_LIMIT='50 per second'
ORDER_RATE_LIMIT='10 per second'- ALWAYS generate new
APP_KEYandAPI_KEY_PEPPERvalues - NEVER commit
.envfile to version control - Use HTTPS in production (set
HOST_SERVERto https URL) - Keep broker credentials secure
- SQLite is used by default (suitable for single-user)
- For production, consider PostgreSQL/MySQL
- Regular backups recommended for
db/folder
- Set
FLASK_DEBUG='True'for development - Set
FLASK_ENV='production'for production - Use
LOG_LEVEL='DEBUG'for troubleshooting
import requests
url = "http://127.0.0.1:5000/api/v1/placeorder"
headers = {"Content-Type": "application/json"}
data = {
"apikey": "your-api-key",
"strategy": "MyStrategy",
"exchange": "NSE",
"symbol": "RELIANCE",
"action": "BUY",
"quantity": "10",
"price": "2500",
"product": "MIS",
"ordertype": "LIMIT",
"position_size": "10"
}
response = requests.post(url, json=data, headers=headers)
print(response.json())url = "http://127.0.0.1:5000/api/v1/funds"
data = {"apikey": "your-api-key"}
response = requests.post(url, json=data, headers=headers)
print(response.json())const ws = new WebSocket('ws://127.0.0.1:8765');
ws.onopen = () => {
// Authenticate
ws.send(JSON.stringify({
action: 'authenticate',
api_key: 'your-api-key'
}));
// Subscribe to symbols
ws.send(JSON.stringify({
action: 'subscribe',
symbols: ['NSE:RELIANCE', 'NSE:TCS'],
mode: 'ltp'
}));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Market data:', data);
};- Check Python version:
python --version(need 3.12+) - Verify dependencies:
pip install -r requirements.txt - Check
.envconfiguration - Ensure port 5000 is available
- Run:
npm install - Build CSS:
npm run build - Check
static/css/main.cssexists
- Check
WEBSOCKET_PORTin.env - Verify port 8765 is not blocked
- Check firewall settings
- Verify
BROKER_API_KEYandBROKER_API_SECRET - Check broker credentials are active
- Review broker-specific documentation
This is an MVP version based on the original OpenAlgo project. Contributions are welcome!
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
Key points:
- β Free to use, modify, and distribute
- β Must disclose source code
- β Must use same license for derivatives
- β Network use = distribution (must share source)
See LICENSE file for details.
This software is for educational purposes only.
- Do NOT risk money you cannot afford to lose
- USE THE SOFTWARE AT YOUR OWN RISK
- Authors assume NO RESPONSIBILITY for trading results
- Test thoroughly in sandbox mode before live trading
- Consult financial advisors before trading
This MVP is based on OpenAlgo by Marketcalls.
- Flask - Web framework (BSD-3-Clause)
- DaisyUI - UI components (MIT)
- Tailwind CSS - CSS framework (MIT)
- TradingView Lightweight Charts - Charting library (Apache 2.0)
- Socket.IO - Real-time communication (MIT)
- SQLAlchemy - Database ORM (MIT)
- Argon2 - Password hashing (Apache 2.0)
For issues and questions:
- Open an issue on GitHub
- Check the original OpenAlgo documentation
- Join the OpenAlgo Discord
Future enhancements for this MVP:
- Add more broker integrations
- Enhanced backtesting capabilities
- Advanced charting features
- Mobile app support
- Multi-user support with PostgreSQL
- Cloud deployment guides
- Video tutorials
Built with β€οΈ for the algo trading community
Made with GitMVP - AI-powered MVP generator