{"id":30046678,"url":"https://github.com/pakagronglb/python-correlations-trading-strategy","last_synced_at":"2026-05-18T15:07:10.741Z","repository":{"id":291053843,"uuid":"976428648","full_name":"pakagronglb/python-correlations-trading-strategy","owner":"pakagronglb","description":"A correlation-based trading strategy using Python, analyzing the relationship between two assets to generate trading signals. The strategy is based on the concept of mean reversion in correlation between assets.","archived":false,"fork":false,"pushed_at":"2025-05-02T05:08:57.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-02T06:20:53.514Z","etag":null,"topics":["matplotlib","pandas","pyplot","python","trading","visualisation","yfinance"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pakagronglb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-05-02T05:07:44.000Z","updated_at":"2025-05-02T05:09:43.000Z","dependencies_parsed_at":"2025-05-02T06:20:55.838Z","dependency_job_id":"abf93c6f-4c3d-4b27-8764-153585c3d79c","html_url":"https://github.com/pakagronglb/python-correlations-trading-strategy","commit_stats":null,"previous_names":["pakagronglb/python-correlations-trading-strategy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pakagronglb/python-correlations-trading-strategy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pakagronglb%2Fpython-correlations-trading-strategy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pakagronglb%2Fpython-correlations-trading-strategy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pakagronglb%2Fpython-correlations-trading-strategy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pakagronglb%2Fpython-correlations-trading-strategy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pakagronglb","download_url":"https://codeload.github.com/pakagronglb/python-correlations-trading-strategy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pakagronglb%2Fpython-correlations-trading-strategy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269227166,"owners_count":24381829,"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","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["matplotlib","pandas","pyplot","python","trading","visualisation","yfinance"],"created_at":"2025-08-07T08:47:41.086Z","updated_at":"2026-05-18T15:07:10.729Z","avatar_url":"https://github.com/pakagronglb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📈 Python Correlations Trading Strategy\n\n![Python](https://img.shields.io/badge/python-3.13-blue.svg)\n![Pandas](https://img.shields.io/badge/pandas-2.2.3-blue.svg)\n![YFinance](https://img.shields.io/badge/yfinance-0.2.57-green.svg)\n![Matplotlib](https://img.shields.io/badge/matplotlib-3.10.1-orange.svg)\n![License](https://img.shields.io/badge/license-MIT-green.svg)\n\n## 🎯 Overview\n\nA correlation-based trading strategy using Python, analyzing the relationship between two assets to generate trading signals. The strategy is based on the concept of mean reversion in correlation between assets.\n\n## ✨ Features\n\n- 📊 Real-time stock data fetching with retry logic\n- 🔄 Correlation analysis between two assets\n- 📈 Rolling correlation calculations\n- 🎯 Signal generation based on correlation thresholds\n- 📉 Visualization of correlation patterns and trading signals\n- ⚡ Rate limiting and error handling\n\n## 🛠️ Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/pakagronglb/python-correlations-trading-strategy.git\ncd python-correlations-trading-strategy\n```\n\n2. Create and activate a virtual environment:\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n3. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n## 📋 Requirements\n\n- Python 3.13+\n- pandas\n- yfinance\n- matplotlib\n- numpy\n\n## 🚀 Usage\n\n1. Import the necessary functions:\n```python\nfrom stock_data import fetch_stock_data\nfrom correlation_strategy import calculate_correlation_signals, plot_correlation_signals\n```\n\n2. Fetch stock data:\n```python\nasset1_prices = fetch_stock_data('AAPL')\nasset2_prices = fetch_stock_data('MSFT')\n```\n\n3. Calculate correlation signals:\n```python\nresult = calculate_correlation_signals(data, 'AAPL', 'MSFT', window=50, wide_window=100, std_factor=1)\n```\n\n4. Visualize the results:\n```python\nplot_correlation_signals(result)\n```\n\n## 📊 Strategy Details\n\nThe strategy works by:\n1. Calculating a rolling correlation between two assets\n2. Computing a longer-term average correlation\n3. Identifying significant deviations from the average\n4. Generating signals when correlations move outside normal ranges\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Credits\n\nThis project was inspired by the tutorial from [CodeTrading](https://www.youtube.com/watch?v=O13aUVSs5pQ\u0026ab_channel=CodeTrading).\n\nSpecial thanks to:\n- [CodeTrading](https://www.youtube.com/@CodeTrading) for the original concept and tutorial\n- The yfinance team for providing the stock data API\n- The pandas and matplotlib teams for their excellent data analysis tools\n\n## 📞 Support\n\nFor support, please open an issue in the GitHub repository or contact the maintainers.\n\n## 📈 Disclaimer\n\nThis project is for educational purposes only. Trading stocks involves risk, and past performance is not indicative of future results. Always do your own research and consult with a financial advisor before making investment decisions. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpakagronglb%2Fpython-correlations-trading-strategy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpakagronglb%2Fpython-correlations-trading-strategy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpakagronglb%2Fpython-correlations-trading-strategy/lists"}