Command-line interface reference for QuantumVest administration, data operations, and development tasks.
QuantumVest provides CLI tools through shell scripts and Python scripts for administration, development, and operational tasks.
| Component | Location | Purpose |
|---|---|---|
| Setup Scripts | scripts/ |
Environment setup and installation |
| Backend CLI | code/backend/ |
Database, API, and data operations |
| AI Model CLI | code/ai_models/ |
Model training and evaluation |
| DevOps Scripts | scripts/ |
Deployment and maintenance |
No separate CLI installation required. Scripts are available after repository clone.
git clone https://github.com/quantsingularity/QuantumVest.git
cd QuantumVest
chmod +x scripts/*.sh # Make scripts executableMost scripts support common options:
| Option | Description | Example |
|---|---|---|
--help |
Show help message | ./script.sh --help |
--verbose |
Enable verbose output | ./script.sh --verbose |
--config FILE |
Use custom config file | ./script.sh --config custom.conf |
Complete environment setup for QuantumVest.
Usage:
./scripts/setup_quantumvest_env.sh [OPTIONS]Description: Installs all dependencies, creates virtual environments, and configures the application.
What it does:
- Creates Python virtual environment
- Installs backend dependencies
- Installs frontend dependencies
- Sets up database connections
- Initializes configuration files
Example:
# Standard setup
./scripts/setup_quantumvest_env.sh
# With verbose output
VERBOSE=1 ./scripts/setup_quantumvest_env.shEnvironment-specific configuration setup.
Usage:
./scripts/env_setup.sh [environment]Arguments:
| Argument | Description | Example |
|---|---|---|
| environment | Target environment (dev/staging/prod) | staging |
Example:
# Setup development environment
./scripts/env_setup.sh dev
# Setup production environment
./scripts/env_setup.sh prodStart all QuantumVest services.
Usage:
./scripts/run_quantumvest.sh [OPTIONS]Options:
| Option | Description | Example |
|---|---|---|
--backend-only |
Start only backend | --backend-only |
--frontend-only |
Start only frontend | --frontend-only |
--port PORT |
Custom port | --port 8080 |
Example:
# Start all services
./scripts/run_quantumvest.sh
# Start backend only on port 8000
./scripts/run_quantumvest.sh --backend-only --port 8000Start Flask backend server directly.
Usage:
cd code/backend
source venv/bin/activate
python app.py [OPTIONS]Environment Variables:
| Variable | Default | Description |
|---|---|---|
| FLASK_APP | app.py | Application entry point |
| FLASK_ENV | development | Environment mode |
| FLASK_HOST | 0.0.0.0 | Server host |
| FLASK_PORT | 5000 | Server port |
Example:
# Development server
FLASK_ENV=development python app.py
# Production with Gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:appDatabase migration and initialization.
Usage:
cd code/backend
source venv/bin/activate
python migrate_db.py [COMMAND]Commands:
| Command | Description | Example |
|---|---|---|
init |
Initialize database | python migrate_db.py init |
migrate |
Create migration | python migrate_db.py migrate |
upgrade |
Apply migrations | python migrate_db.py upgrade |
downgrade |
Revert migration | python migrate_db.py downgrade |
seed |
Seed default data | python migrate_db.py seed |
Examples:
# Initialize database
python migrate_db.py init
# Create migration for model changes
python migrate_db.py migrate -m "Add portfolio metrics table"
# Apply all pending migrations
python migrate_db.py upgrade
# Revert last migration
python migrate_db.py downgrade
# Seed database with default assets
python migrate_db.py seedFetch market data for assets.
Usage:
cd code/backend
python -m data_pipeline.data_fetcher [OPTIONS]Options:
| Option | Description | Example |
|---|---|---|
--symbol SYMBOL |
Asset symbol | --symbol AAPL |
--type TYPE |
Asset type (stock/crypto) | --type stock |
--days DAYS |
Historical days | --days 365 |
--output FILE |
Output file | --output data.csv |
Examples:
# Fetch Apple stock data for 1 year
python -m data_pipeline.data_fetcher --symbol AAPL --type stock --days 365
# Fetch Bitcoin data
python -m data_pipeline.data_fetcher --symbol BTC --type crypto --days 180
# Fetch and save to file
python -m data_pipeline.data_fetcher --symbol TSLA --days 730 --output tsla_data.csvDirect stock data operations.
Usage:
python -c "from data_pipeline.stock_api import StockDataFetcher; \
fetcher = StockDataFetcher(); \
data = fetcher.get_stock_data('AAPL'); \
print(data)"Example:
# Get current stock price
python -c "from data_pipeline.stock_api import StockDataFetcher; \
print(StockDataFetcher().get_stock_data('AAPL')['price'])"
# Get historical data
python -c "from data_pipeline.stock_api import StockDataFetcher; \
history = StockDataFetcher().get_historical_data('MSFT', period='1y'); \
print(history.head())"Train AI prediction models.
Usage:
cd code/ai_models
python train_prediction_model.py [OPTIONS]Options:
| Option | Type | Required | Default | Description | Example |
|---|---|---|---|---|---|
| --asset_type | string | No | stock | Asset type | --asset_type crypto |
| --symbol | string | Yes | - | Asset symbol | --symbol AAPL |
| --epochs | int | No | 100 | Training epochs | --epochs 200 |
| --batch_size | int | No | 32 | Batch size | --batch_size 64 |
| --lookback | int | No | 60 | Lookback window | --lookback 90 |
| --output | string | No | models/ | Model output dir | --output trained/ |
Examples:
# Train AAPL stock model
python train_prediction_model.py --symbol AAPL --epochs 150
# Train BTC crypto model with custom params
python train_prediction_model.py \
--asset_type crypto \
--symbol BTC \
--epochs 200 \
--batch_size 64 \
--lookback 90
# Train and save to custom location
python train_prediction_model.py --symbol GOOGL --output ./trained_models/Train portfolio optimization models.
Usage:
cd code/ai_models
python train_optimization_model.py [OPTIONS]Options:
| Option | Description | Example |
|---|---|---|
| --data_path PATH | Training data path | --data_path ../resources/datasets/ |
| --model_type TYPE | Model type (rf/xgb/nn) | --model_type xgb |
| --evaluate | Run evaluation | --evaluate |
Example:
# Train optimization model
python train_optimization_model.py --data_path ../resources/datasets/
# Train with XGBoost
python train_optimization_model.py --model_type xgb --evaluate
# Evaluate existing model
python train_optimization_model.py --evaluatePreprocess data for model training.
Usage:
cd code/ai_models/training_scripts
python data_preprocessing.py [OPTIONS]Options:
| Option | Description | Example |
|---|---|---|
| --input FILE | Input data file | --input raw_data.csv |
| --output FILE | Output file | --output processed.csv |
| --features LIST | Feature columns | --features price,volume |
Example:
# Preprocess raw data
python data_preprocessing.py \
--input ../../resources/datasets/raw_stock_data.csv \
--output ../../resources/datasets/processed_data.csv
# Select specific features
python data_preprocessing.py \
--input raw.csv \
--output processed.csv \
--features price,volume,ma_50,ma_200Run complete test suite.
Usage:
./scripts/run_all_tests.sh [OPTIONS]Options:
| Option | Description | Example |
|---|---|---|
| --coverage | Generate coverage report | --coverage |
| --verbose | Verbose output | --verbose |
| --fast | Skip slow tests | --fast |
Example:
# Run all tests
./scripts/run_all_tests.sh
# Run with coverage
./scripts/run_all_tests.sh --coverage
# Fast test run
./scripts/run_all_tests.sh --fastRun backend tests only.
Usage:
./scripts/run_backend_tests.shExample:
# Run backend tests
./scripts/run_backend_tests.sh
# Run specific test file
cd code/backend
pytest tests/test_endpoints.py -v
# Run with coverage
pytest --cov=. --cov-report=htmlDirect pytest usage for backend.
Usage:
cd code/backend
pytest [OPTIONS] [PATH]Common Options:
| Option | Description | Example |
|---|---|---|
| -v | Verbose output | pytest -v |
| -k EXPR | Run tests matching expression | pytest -k "test_login" |
| --cov | Coverage report | pytest --cov=. |
| -x | Stop on first failure | pytest -x |
| --pdb | Debug on failure | pytest --pdb |
Examples:
# Run all tests
pytest
# Run specific test file
pytest tests/test_endpoints.py
# Run tests matching pattern
pytest -k "test_portfolio"
# Run with coverage
pytest --cov=. --cov-report=html
# Stop on first failure
pytest -x
# Run in parallel (requires pytest-xdist)
pytest -n autoDeploy to environment.
Usage:
./scripts/deploy.sh [environment] [OPTIONS]Arguments:
| Argument | Description | Example |
|---|---|---|
| environment | Target environment | staging, production |
Options:
| Option | Description | Example |
|---|---|---|
| --skip-tests | Skip test execution | --skip-tests |
| --no-backup | Skip database backup | --no-backup |
| --force | Force deployment | --force |
Examples:
# Deploy to staging
./scripts/deploy.sh staging
# Deploy to production with tests
./scripts/deploy.sh production
# Force deploy without backup
./scripts/deploy.sh production --force --no-backupBuild frontend for production.
Usage:
./scripts/build_frontend.shExample:
# Build frontend
./scripts/build_frontend.sh
# The built files will be in web-frontend/build/Run code quality checks.
Usage:
./scripts/lint-all.sh [OPTIONS]Options:
| Option | Description | Example |
|---|---|---|
| --fix | Auto-fix issues | --fix |
| --check-only | Check without fixing | --check-only |
Example:
# Check code quality
./scripts/lint-all.sh
# Auto-fix issues
./scripts/lint-all.sh --fix
# Check only (CI mode)
./scripts/lint-all.sh --check-onlySystem maintenance operations.
Usage:
./scripts/maintenance.sh [COMMAND]Commands:
| Command | Description | Example |
|---|---|---|
| backup | Backup database | backup |
| restore | Restore database | restore |
| clean | Clean old logs | clean |
| optimize | Optimize database | optimize |
Examples:
# Backup database
./scripts/maintenance.sh backup
# Restore from backup
./scripts/maintenance.sh restore
# Clean old logs
./scripts/maintenance.sh clean
# Optimize database
./scripts/maintenance.sh optimize# Setup
./scripts/setup_quantumvest_env.sh
# Start services
./scripts/run_quantumvest.sh
# Database operations
cd code/backend && python migrate_db.py upgrade
# Fetch data
python -m data_pipeline.data_fetcher --symbol AAPL --days 365
# Train model
cd code/ai_models && python train_prediction_model.py --symbol AAPL
# Run tests
./scripts/run_all_tests.sh
# Deploy
./scripts/deploy.sh staging
# Lint code
./scripts/lint-all.sh --fix
# Maintenance
./scripts/maintenance.sh backup1. Permission Denied
chmod +x scripts/*.sh2. Virtual Environment Not Found
cd code/backend
python3 -m venv venv
source venv/bin/activate3. Module Not Found
cd code/backend
source venv/bin/activate
pip install -r requirements.txt4. Database Connection Failed
# Check PostgreSQL is running
sudo systemctl status postgresql
# Check connection string in .env
cat .env | grep DATABASE_URL- Usage Guide: See USAGE.md for practical examples
- API Reference: Check API.md for REST API usage
- Developer Guide: Read CONTRIBUTING.md for development workflow
- Troubleshooting: See TROUBLESHOOTING.md for more issues
For script internals and customization, refer to inline script documentation