{"id":23933736,"url":"https://github.com/The-Swarm-Corporation/BackTesterAgent","last_synced_at":"2025-09-11T16:32:38.559Z","repository":{"id":263514353,"uuid":"890649146","full_name":"The-Swarm-Corporation/BackTesterAgent","owner":"The-Swarm-Corporation","description":"An enterprise-grade AI-powered backtesting framework built on the Swarms framework for automated trading strategy validation and optimization.","archived":false,"fork":false,"pushed_at":"2024-12-23T09:53:28.000Z","size":2332,"stargazers_count":5,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-02T16:47:33.348Z","etag":null,"topics":["ai","backtesting","data","finance","finance-agents","jpmorgan","yahoofinance"],"latest_commit_sha":null,"homepage":"https://swarms.ai/","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/The-Swarm-Corporation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["kyegomez"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-11-19T00:00:28.000Z","updated_at":"2024-12-22T12:50:53.000Z","dependencies_parsed_at":"2024-11-19T00:45:38.394Z","dependency_job_id":"d6ec9ac2-1f41-45ba-91cb-609d4975a500","html_url":"https://github.com/The-Swarm-Corporation/BackTesterAgent","commit_stats":null,"previous_names":["the-swarm-corporation/backtesteragent"],"tags_count":0,"template":false,"template_full_name":"kyegomez/Python-Package-Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-Swarm-Corporation%2FBackTesterAgent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-Swarm-Corporation%2FBackTesterAgent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-Swarm-Corporation%2FBackTesterAgent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-Swarm-Corporation%2FBackTesterAgent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/The-Swarm-Corporation","download_url":"https://codeload.github.com/The-Swarm-Corporation/BackTesterAgent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232658687,"owners_count":18556988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","backtesting","data","finance","finance-agents","jpmorgan","yahoofinance"],"created_at":"2025-01-06T00:29:52.447Z","updated_at":"2025-01-06T00:33:51.191Z","avatar_url":"https://github.com/The-Swarm-Corporation.png","language":"Python","funding_links":["https://github.com/sponsors/kyegomez"],"categories":["Building","💰 Financial Services \u0026 Trading"],"sub_categories":["Testing","Trading \u0026 Investment"],"readme":"\n\n# BackTesterAgent 🚀\n\n[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge\u0026logo=discord\u0026logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge\u0026logo=youtube\u0026logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge\u0026logo=x\u0026logoColor=white)](https://x.com/kyegomezb)\n\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![Swarms](https://img.shields.io/badge/Powered%20by-Swarms-orange)](https://github.com/kyegomez/swarms)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Downloads](https://static.pepy.tech/personalized-badge/backtesteragent?period=total\u0026units=international_system\u0026left_color=grey\u0026right_color=brightgreen\u0026left_text=Downloads)](https://pepy.tech/project/backtesteragent)\n\nAn enterprise-grade AI-powered backtesting framework built on the Swarms framework for automated trading strategy validation and optimization.\n\n## 🌟 Features\n\n- **Advanced Technical Analysis**: Comprehensive suite of technical indicators (SMA, RSI, MACD)\n- **Real-Time Data Integration**: Seamless integration with Yahoo Finance for live market data\n- **AI-Powered Decision Making**: Leveraging GPT-4 through the Swarms framework\n- **Robust Portfolio Management**: Sophisticated position tracking and trade execution\n- **Enterprise-Grade Logging**: Detailed logging with Loguru for production environments\n- **Type-Safe Implementation**: Comprehensive type hints and dataclass usage\n- **Performance Analytics**: In-depth metrics including Sharpe ratio and maximum drawdown\n- **Interactive Visualizations**: Real-time trading activity and portfolio performance charts\n\n## 🛠️ Installation\n\n```bash\npip3 install -U backtester-agent\n```\n\n## 📋 Requirements\n\n- Python 3.8+\n- backtester package: `pip3 install -U backtester-agent`\n- API Key for OpenAI\n\n## 🚀 Quick Start\n\n```python\nfrom backtester_agent.main import run_backtest\n\nrun_backtest(cash=500.0, symbol=\"AAPL\", start_date=\"2024-11-16\", end_date=\"2024-11-18\", trade_size=10)\n```\n\n## 📊 Example Output\n\n```plaintext\n2024-01-18 10:30:15 | INFO | Starting backtest for AAPL\n2024-01-18 10:30:16 | INFO | Processing 252 trading days\n2024-01-18 10:30:45 | SUCCESS | Backtest completed\n\nBacktest Results:\nInitial Portfolio Value: $100,000.00\nFinal Portfolio Value: $125,432.10\nTotal Return: 25.43%\nSharpe Ratio: 1.85\nMaximum Drawdown: -8.32%\nTotal Trades: 45\n```\n\n## 🔧 Configuration\n\nConfigure the agent through environment variables or a config file:\n\n```env\nOPENAI_API_KEY=your_api_key_here\nWORKSPACE_DIR=\"agent_workspace\"\nSWARMS_API_KEY=your_swarms_api_key_here # Get from swarms.ai dashboard\n```\n\n## 🏗️ Architecture\n\n```mermaid\ngraph TD\n    A[FinancialData] --\u003e|Price Data| B[BackTester]\n    B --\u003e|Market State| C[FinancialAgent]\n    C --\u003e|Decisions| D[Portfolio]\n    D --\u003e|Execution| B\n    E[Technical Indicators] --\u003e|Analysis| C\n```\n\n## 📈 Performance Metrics\n\nThe BackTesterAgent provides comprehensive performance analytics:\n\n- Total Return\n- Sharpe Ratio\n- Maximum Drawdown\n- Trade Count\n- Win/Loss Ratio\n- Risk-Adjusted Return\n\n## 🔍 Logging and Monitoring\n\nDetailed logging is implemented using Loguru:\n\n```python\nlogger.add(\n    \"backtester_{time}.log\",\n    rotation=\"500 MB\",\n    retention=\"10 days\",\n    level=\"INFO\"\n)\n```\n\n## 🔒 Security\n\n- Environment variable management for sensitive data\n- Secure API key handling\n- Rate limiting for API calls\n- Error handling and validation\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## 📜 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- [Swarms Framework](https://github.com/kyegomez/swarms) for the foundational AI capabilities\n- [Yahoo Finance](https://finance.yahoo.com/) for market data\n- All contributors and maintainers\n\n## 📞 Support\n\n- Documentation: [Link to Docs]\n- Issues: [GitHub Issues](https://github.com/yourusername/backtesteragent/issues)\n- Email: support@backtesteragent.com\n- Discord: [Join our community](https://discord.gg/backtesteragent)\n\n## 🗺️ Roadmap\n\n- [ ] Advanced strategy optimization\n- [ ] Multi-asset portfolio support\n- [ ] Machine learning integration\n- [ ] Real-time trading capabilities\n- [ ] Enhanced risk management features\n\n## 📊 Benchmarks\n\nPerformance benchmarks against standard trading strategies:\n\n| Strategy | Return | Sharpe Ratio | Max Drawdown |\n|----------|---------|--------------|--------------|\n| Buy \u0026 Hold | 15.2% | 0.95 | -12.3% |\n| BackTesterAgent | 25.4% | 1.85 | -8.3% |\n| Market Index | 12.1% | 0.82 | -15.7% |\n\n---\n\nBuilt with ❤️ by [Swarms](https://swarms.ai)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThe-Swarm-Corporation%2FBackTesterAgent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FThe-Swarm-Corporation%2FBackTesterAgent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThe-Swarm-Corporation%2FBackTesterAgent/lists"}