{"id":24739509,"url":"https://github.com/concaption/new-stock-backtesting","last_synced_at":"2025-10-08T13:15:43.794Z","repository":{"id":274143071,"uuid":"916137806","full_name":"concaption/new-stock-backtesting","owner":"concaption","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-25T07:02:20.000Z","size":1278,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T18:47:28.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/concaption.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}},"created_at":"2025-01-13T14:26:26.000Z","updated_at":"2025-01-25T07:02:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c272fae-dbb7-419f-9ca4-7fdf2b99c5e2","html_url":"https://github.com/concaption/new-stock-backtesting","commit_stats":null,"previous_names":["concaption/new-stock-backtesting"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/concaption/new-stock-backtesting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/concaption%2Fnew-stock-backtesting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/concaption%2Fnew-stock-backtesting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/concaption%2Fnew-stock-backtesting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/concaption%2Fnew-stock-backtesting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/concaption","download_url":"https://codeload.github.com/concaption/new-stock-backtesting/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/concaption%2Fnew-stock-backtesting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278949114,"owners_count":26073972,"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-10-08T02:00:06.501Z","response_time":56,"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":[],"created_at":"2025-01-27T22:59:29.494Z","updated_at":"2025-10-08T13:15:43.773Z","avatar_url":"https://github.com/concaption.png","language":"Python","readme":"# Stock Analysis Tool\n\nA powerful stock analysis tool that combines market data from Polygon.io with Google Trends search data to identify potential trading opportunities. This tool analyzes pre-market activity, gap-up percentages, and search trend changes to help identify stocks with significant movement potential.\n\n[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/concaption/new-stock-backtesting)\n\n## Features\n\n- Combined analysis using both market data and search trends\n- Pre-market volume analysis\n- Parallel processing for date ranges\n- Gap-up percentage calculation\n- Market capitalization filtering\n- Google Trends hourly analysis (4-6 AM PST)\n- Customizable filtering criteria\n- Excel report generation with conditional formatting\n- Colored console logging\n- Concurrent processing with rate limiting\n- Trading calendar aware (handles holidays and market closures)\n\n## Prerequisites\n\n- Python 3.8+\n- Polygon.io API key\n- SERP API key (for Google Trends data)\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/concaption/new-stock-backtesting.git\ncd new-stock-backtesting\n```\n\n2. Install required packages:\n```bash\npip install -r requirements.txt\n```\n\n3. Set up environment variables:\n```bash\ncp .env.example .env\n```\n\nEdit the `.env` file and add your API keys:\n```\nPOLYGON_API_KEY=your_polygon_api_key\nSERPAPI_KEY=your_serp_api_key\n```\n\n4. Create required directories:\n```bash\nmkdir -p data output logs\n```\n\n5. Add the holidays.csv file to the data directory with required fields:\n- Date (YYYY-MM-DD format)\n- Market Status (Closed/Early Close)\n\n## Usage\n\n### Basic Analysis\n\nAnalyze a single stock:\n```bash\npython main.py analyze --ticker AAPL\n```\n\nAnalyze multiple stocks from a JSON file:\n```bash\npython main.py analyze --ticker-file tickers.json\n```\n\nDate range analysis with parallel processing:\n```bash\npython main.py analyze --ticker AAPL --start-date 2024-01-02 --end-date 2024-12-31 --max-parallel 10\n```\n\n### Analysis Options\nDate Options:\n- `--date`: Single date analysis (YYYY-MM-DD)\n- `--start-date`: Start date for range analysis (YYYY-MM-DD)\n- `--end-date`: End date for range analysis (YYYY-MM-DD)\n- `--max-parallel`: Maximum number of parallel date analyses (default: 5)\n\nFilter Options:\n- `--min-trends-change`: Minimum Google Trends change percentage (default: 50.0)\n- `--min-premarket-volume`: Minimum premarket volume (default: 50000)\n- `--min-price`: Minimum stock price (default: 3.0)\n- `--min-gap-up`: Minimum gap up percentage (default: 2.0)\n- `--min-market-cap`: Minimum market cap (can use B/M suffix, e.g., 100M)\n\nAnalysis Control:\n- `--trends-only`: Only perform Google Trends analysis\n- `--polygon-only`: Only perform Polygon analysis\n- `--batch-size`: Number of concurrent requests (default: 5)\n- `--verbose`: Increase verbosity level (-v or -vv)\n\nExamples:\nSingle date analysis:\n```bash\npython main.py analyze --ticker AAPL --date 2024-01-15 --min-trends-change 75 --min-gap-up 3 --min-market-cap 1B -v\n```\nDate range analysis:\n```bash\npython main.py analyze --ticker AAPL --start-date 2024-01-01 --end-date 2024-12-31 --max-parallel 10 --min-trends-change 50\n```\nMultiple stocks over date range:\n```bash\npython main.py analyze --ticker-file stocks.json --start-date 2024-01-01 --end-date 2024-01-31 --max-parallel 5 --batch-size 10\n```\n\n## Output\n\nThe tool generates:\n1. Excel files with analysis results in the output directory (one file per analyzed date)\n2. Detailed logs in the `logs` directory\n3. Console output with color-coded status messages\n4. Summary statistics for date range analyses\n\n### Excel Output Format\n\nThe Excel output includes:\n- Date\n- Ticker\n- Company Name\n- Pre-market Volume\n- Gap Up %\n- Market Cap\n- Open Price\n- High Price\n- Close Price\n- Open to High %\n- Open to Close %\n\nPositive and negative percentage values are highlighted in green and red respectively.\n\n## Project Structure\n\n```\n├── src/\n│   ├── combined_analyzer.py   # Main analysis logic\n│   ├── excel_handler.py       # Excel file generation\n│   ├── google_trends.py       # Google Trends analysis\n│   ├── logger_config.py       # Logging configuration\n│   ├── polygon.py            # Polygon.io API interface\n│   └── trading_calendar.py   # Market calendar management\n├── data/\n│   └── holidays.csv          # Market holidays data\n├── logs/                     # Log files directory\n├── output/                   # Analysis results\n├── main.py                   # CLI interface\n├── requirements.txt          # Dependencies\n└── README.md                 # This file\n```\n\n## Performance Considerations\nWhen running date range analysis:\n* `max-parallel` controls how many dates are analyzed simultaneously\n* `batch-size` controls how many stocks are analyzed concurrently within each date\n* Both values affect API rate limits and system resource usage\n* Recommended starting values: max-parallel=5, batch-size=5\n* Adjust based on your API limits and system capabilitie\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## Acknowledgments\n\n- Polygon.io for market data\n- SERP API for Google Trends data\n- Click for CLI interface\n- OpenPyXL for Excel handling\n\n## Author\n\n@concaption - January 2025","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconcaption%2Fnew-stock-backtesting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconcaption%2Fnew-stock-backtesting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconcaption%2Fnew-stock-backtesting/lists"}