Adds Copilot-friendly instructions.md and scripts/backtest_generate_signals.py (walk-forward historical signal generation). Based on v1.6 enrichments:
- Multi-timeframe alignment (15m + 1h)
- Relative strength vs sector ETF (default
XLK) + SPY fallback - Time-of-day bucket (open/mid/close)
- Volatility regime filter for KNN priors
- Signals DB stores expectations + LLM plan + enrichments
- Centralized database architecture with SQLAlchemy ORM
- External database support (PostgreSQL, MySQL, etc.)
python -m venv .venv && source .venv/bin/activate
pip install -e .# Generate a trading signal for Apple stock
python scripts/run_swing_agent.py --symbol AAPL --interval 30m --lookback-days 30- New to SwingAgent? Start with the Getting Started Guide
- Want hands-on experience? Follow the Tutorial
- Have questions? Check the FAQ
π Complete Documentation - Everything you need to know
- Getting Started - Setup and first signal
- Tutorial - Your first week of trading
- Use Cases - Real-world trading scenarios
- Best Practices - Professional tips
- FAQ - Common questions
- Glossary - Trading terms explained
- API Reference - Function documentation
- Architecture - System design
- Configuration - Customization options
- Development - Contributing guide
SwingAgent combines technical analysis, machine learning, and AI to generate 1-2 day swing trading signals:
β
Technical Analysis: Fibonacci retracements, trend analysis, momentum indicators
β
Pattern Recognition: ML-based historical pattern matching
β
AI Insights: OpenAI-powered explanations and action plans
β
Risk Management: Automatic stop-loss and take-profit calculations
{
"symbol": "AAPL",
"entry": {
"side": "long",
"entry_price": 185.50,
"stop_price": 182.20,
"take_profit": 190.80,
"r_multiple": 1.61
},
"confidence": 0.72,
"expected_winrate": 0.58,
"action_plan": "Strong uptrend with Fibonacci support..."
}SwingAgent v1.6.1 uses a centralized database architecture with SQLAlchemy ORM. By default, it uses a single SQLite file, but supports external databases for production deployments.
# Uses data/swing_agent.sqlite automatically
python scripts/run_swing_agent.py --symbol AMD --interval 30m --lookback-days 30# Option 1: Direct URL
export SWING_DATABASE_URL="postgresql://user:pass@localhost:5432/swing_agent"
# Option 2: Individual components
export SWING_DB_TYPE=postgresql
export SWING_DB_HOST=localhost
export SWING_DB_NAME=swing_agent
export SWING_DB_USER=your_username
export SWING_DB_PASSWORD=your_password
# Then run normally
python scripts/run_swing_agent.py --symbol AMD# For Kubernetes deployments with CNPG operator
export SWING_DB_TYPE=cnpg
export CNPG_CLUSTER_NAME=swing-postgres
export CNPG_NAMESPACE=default
export SWING_DB_NAME=swing_agent
export SWING_DB_USER=swing_user
export SWING_DB_PASSWORD=your_password
# Test configuration
python scripts/test_cnpg.py- Centralized Storage: Signals and vector patterns stored in single database
- Multiple Backends: SQLite for development, PostgreSQL/MySQL for production
- Kubernetes Ready: Native CloudNativePG (CNPG) support for scalable deployments
- Migration Tools: Automated migration from legacy separate databases
For detailed database setup:
- EXTERNAL_DATABASES.md - PostgreSQL/MySQL setup
- CNPG_SETUP.md - CloudNativePG for Kubernetes
- k8s/cnpg/ - Complete Kubernetes deployment manifests
python scripts/run_swing_agent.py --symbol AMD --interval 30m --lookback-days 30 --sector XLKpython scripts/backtest_generate_signals.py --symbol AMD --interval 30m --lookback-days 180 --warmup-bars 80 --sector XLK --no-llmpython scripts/eval_signals.py --max-hold-days 2.0python scripts/backfill_vector_store.pypython scripts/analyze_performance.pypython scripts/train_ml_model.py --db data/swing_agent.sqliteGenerates baseline classification and regression models from the vector store and saves them to models/.
# Migrate existing separate SQLite files to centralized database
python -m swing_agent.migrate --data-dir data/# First set up external database connection
export SWING_DATABASE_URL="postgresql://user:pass@localhost:5432/swing_agent"
# Migrate from centralized SQLite to external database
python -m swing_agent.migrate --sqlite-to-external "$SWING_DATABASE_URL"# Show current database configuration
python scripts/db_info.py --info
# Test database connection
python scripts/db_info.py --test
# Initialize database tables
python scripts/db_info.py --init