{"id":47932160,"url":"https://github.com/trsdn/meta-strategy","last_synced_at":"2026-04-04T07:20:22.107Z","repository":{"id":338229931,"uuid":"1157096470","full_name":"trsdn/meta-strategy","owner":"trsdn","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-13T20:22:42.000Z","size":490,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-13T21:37:34.716Z","etag":null,"topics":["ai-scrum","algorithmic-trading","backtesting","bitcoin","bollinger-bands","crypto","pine-script","python","quantitative-finance","strategy","supertrend","trading","tradingview"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trsdn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-02-13T12:29:38.000Z","updated_at":"2026-02-13T20:22:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/trsdn/meta-strategy","commit_stats":null,"previous_names":["trsdn/meta-strategy"],"tags_count":1,"template":false,"template_full_name":"trsdn/copilot-scrum-autonomous","purl":"pkg:github/trsdn/meta-strategy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trsdn%2Fmeta-strategy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trsdn%2Fmeta-strategy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trsdn%2Fmeta-strategy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trsdn%2Fmeta-strategy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trsdn","download_url":"https://codeload.github.com/trsdn/meta-strategy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trsdn%2Fmeta-strategy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31391365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-scrum","algorithmic-trading","backtesting","bitcoin","bollinger-bands","crypto","pine-script","python","quantitative-finance","strategy","supertrend","trading","tradingview"],"created_at":"2026-04-04T07:20:20.263Z","updated_at":"2026-04-04T07:20:22.088Z","avatar_url":"https://github.com/trsdn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Meta Strategy\n\n[![CI](https://github.com/trsdn/meta-strategy/actions/workflows/ci.yml/badge.svg)](https://github.com/trsdn/meta-strategy/actions/workflows/ci.yml)\n[![version](https://img.shields.io/badge/version-1.0.0-blue)](https://github.com/trsdn/meta-strategy/releases/tag/v1.0.0)\n[![python](https://img.shields.io/badge/python-3.11+-3776AB?logo=python\u0026logoColor=white)](https://www.python.org)\n[![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)\n[![tests](https://img.shields.io/badge/tests-128%20passing-brightgreen)](tests/)\n[![mypy](https://img.shields.io/badge/mypy-strict-blue)](pyproject.toml)\n[![AI Scrum](https://img.shields.io/badge/built%20with-AI%20Scrum-blueviolet)](https://trsdn.github.io/ai-scrum/)\n\n\u003e 🤖 **Built by using [AI Scrum](https://trsdn.github.io/ai-scrum/)** — autonomous AI-driven development with structured sprints, quality gates, and continuous delivery.\n\n\u003e 📊 **[View the Strategy Validation Report](docs/validation-report.html)** — backtested results with equity curves, trade lists, and statistical significance tests.\n\n\u003e 🎬 **Based on:** [Convert TradingView Indicators into Strategies with AI](https://www.youtube.com/watch?v=ETuIpsL_7Mc) by Michael Automates\n\nAI-powered TradingView indicator-to-strategy converter with a full local backtesting engine. Translates Pine Script indicators into backtestable strategies, runs them locally on real market data, and provides optimization, risk analysis, and reporting tools.\n\n## What This Does\n\nTradingView **indicators** show signals on a chart but can't be backtested. TradingView **strategies** can be backtested (Win Rate, Profit Factor, Drawdown). This tool:\n\n1. **Converts** indicators → strategies via structured AI prompts\n2. **Backtests** strategies locally with real market data (no TradingView needed)\n3. **Optimizes** parameters via grid search with train/test split\n4. **Validates** walk-forward with rolling/expanding windows and overfitting detection\n5. **Analyzes** risk with Monte Carlo simulation and extended metrics\n6. **Reports** results as HTML dashboards, CSV, or JSON\n\n## Strategy Catalog\n\nAll 6 strategies have YAML definitions, indicator sources, and generated AI prompts.\n\n| Strategy | Entry | Exit |\n|----------|-------|------|\n| **Bollinger Bands** | Close \u003e Upper Band (breakout) | Close \u003c Lower Band |\n| **SuperTrend** | Direction flips to +1 (bullish) | Direction flips to -1 (bearish) |\n| **Bull Market Support Band** | EMA \u003e SMA crossover | SMA \u003e EMA crossunder |\n| **RSI** | RSI \u003c 30 + above 200 SMA | RSI \u003e 70 |\n| **MACD** | MACD crosses above signal | MACD crosses below signal |\n| **Confluence** | BB breakout + RSI \u003c 70 + MACD \u003e Signal | Close \u003c BB lower OR RSI \u003e 80 |\n\n\u003e **Note:** `backtest-all` normalizes Buy \u0026 Hold returns across strategies by accounting for indicator warmup periods. Use `--interval` to test on different timeframes (1h, 4h, 1d).\n\n## Quick Start\n\n```bash\n# Install\nuv sync --extra dev\n\n# Run all backtests (daily candles, BTC-USD)\nmeta-strategy backtest-all\n\n# Backtest on hourly candles\nmeta-strategy backtest bollinger-bands --symbol BTC-USD --interval 1h\n\n# Optimize parameters with train/test split\nmeta-strategy optimize bollinger-bands --top 10 --split 0.7\n\n# Walk-forward analysis (rolling windows)\nmeta-strategy walk-forward bollinger-bands --mode rolling --train-bars 500 --step 100\n\n# Monte Carlo simulation\nmeta-strategy monte-carlo bollinger-bands --simulations 1000\n\n# Extended risk metrics\nmeta-strategy risk-metrics bollinger-bands\n\n# Multi-asset comparison\nmeta-strategy multi-asset bollinger-bands --symbols BTC-USD,ETH-USD,SPY\n\n# Generate HTML dashboard\nmeta-strategy dashboard --output dashboard.html\n\n# Export results\nmeta-strategy export --fmt json\nmeta-strategy export --fmt csv\n```\n\n## CLI Commands\n\n| Command | Description |\n|---------|-------------|\n| `backtest` | Run backtest for a single strategy |\n| `backtest-all` | Run all strategies with normalized B\u0026H comparison |\n| `multi-asset` | Run a strategy across multiple assets |\n| `optimize` | Grid search with train/test split and overfitting detection |\n| `walk-forward` | Walk-forward validation (sequential/rolling/expanding) |\n| `monte-carlo` | Monte Carlo trade resampling simulation |\n| `risk-metrics` | Extended risk metrics (Sortino, Calmar, etc.) |\n| `report` | Generate HTML report with equity curve |\n| `dashboard` | Generate comparison dashboard for all strategies |\n| `export` | Export results to CSV or JSON |\n| `generate` | Generate AI prompt from strategy definition |\n| `validate` | Validate a YAML strategy definition |\n| `validate-pine` | Validate Pine Script for common pitfalls |\n| `list` | List available strategy definitions |\n\n### Key Options\n\n| Option | Available On | Description |\n|--------|-------------|-------------|\n| `--interval` | backtest, backtest-all, optimize, walk-forward | Candle interval: 1h, 4h, 1d (default: 1d) |\n| `--split` | optimize | Train/test split ratio (default: 0.7) |\n| `--mode` | walk-forward | Window mode: sequential, rolling, expanding |\n| `--cash` | all backtest commands | Initial capital (default: $100k) |\n\n## Development\n\n```bash\nuv run pytest tests/ -v        # Run tests (85+ tests)\nuv run ruff check src/          # Lint\nuv run ruff format src/         # Format\nuv run mypy src/                # Type check\n```\n\n## Project Structure\n\n```\n├── src/meta_strategy/\n│   ├── backtest.py       # 6 strategy classes, indicators, optimization, walk-forward\n│   ├── reports.py        # HTML reports, SVG equity charts, CSV/JSON export\n│   ├── risk.py           # Monte Carlo simulation, extended risk metrics\n│   ├── models.py         # StrategyDefinition Pydantic model\n│   ├── engine.py         # Prompt template engine\n│   ├── validator.py      # Pine Script pitfall validator\n│   └── cli.py            # Typer CLI (14 commands)\n├── strategies/\n│   ├── definitions/      # 6 YAML strategy definitions\n│   ├── indicators/       # 6 Pine Script indicator sources\n│   └── ai-*.pine         # Generated AI conversion prompts\n├── tests/                # 85+ tests\n└── docs/\n    ├── sprints/          # Sprint logs and velocity tracking\n    └── architecture/     # ADRs\n```\n\n## Limitations\n\n- **Not a substitute for TradingView backtesting.** Local backtests use `backtesting.py` with yfinance data. Fill logic, slippage, and commission handling differ from TradingView's engine. Results are directionally useful but not identical.\n- **No slippage modeling.** All trades fill at the next bar's open price. Real-world slippage on volatile assets (especially crypto) can significantly reduce returns.\n- **Commission approximation.** Default 0.1% per trade. Actual exchange fees vary by platform and volume tier.\n- **Sub-daily data limited to ~730 days** (yfinance constraint). Daily candles have no lookback limit.\n- **BMSB on sub-daily timeframes** uses simulated weekly moving averages from daily-equivalent rolling windows, which may not match TradingView's `request.security()` behavior.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrsdn%2Fmeta-strategy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrsdn%2Fmeta-strategy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrsdn%2Fmeta-strategy/lists"}