{"id":19690828,"url":"https://github.com/ngunyigachie/forex-bot","last_synced_at":"2026-04-27T18:04:01.440Z","repository":{"id":248992166,"uuid":"830386713","full_name":"NgunyiGachie/Forex-Bot","owner":"NgunyiGachie","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-29T10:01:18.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-27T10:59:29.572Z","etag":null,"topics":["financial-analysis","forecasting","forex-prediction","forex-trading","numpy","pandas-python","python"],"latest_commit_sha":null,"homepage":"","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/NgunyiGachie.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-07-18T07:12:57.000Z","updated_at":"2024-12-22T04:26:24.000Z","dependencies_parsed_at":"2024-07-29T13:06:42.650Z","dependency_job_id":null,"html_url":"https://github.com/NgunyiGachie/Forex-Bot","commit_stats":null,"previous_names":["ngunyigachie/forex-bot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NgunyiGachie/Forex-Bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NgunyiGachie%2FForex-Bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NgunyiGachie%2FForex-Bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NgunyiGachie%2FForex-Bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NgunyiGachie%2FForex-Bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NgunyiGachie","download_url":"https://codeload.github.com/NgunyiGachie/Forex-Bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NgunyiGachie%2FForex-Bot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262319701,"owners_count":23293070,"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":["financial-analysis","forecasting","forex-prediction","forex-trading","numpy","pandas-python","python"],"created_at":"2024-11-11T19:06:57.388Z","updated_at":"2026-04-27T18:04:01.390Z","avatar_url":"https://github.com/NgunyiGachie.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backtrader Fibonacci Retracement Strategy\n\n![License](https://img.shields.io/badge/License-MIT-green)\n\nThis project contains a Backtrader strategy for trading using Fibonacci retracement levels combined with Simple Moving Averages (SMA). The strategy aims to identify buy and sell signals based on these technical indicators and execute trades accordingly.\n\n\u003e **Note**: This project is currently in the development stages. Contributions and feedback are welcome!\n\n## Features\n\n- **Fibonacci Retracement Levels**: Calculates and uses Fibonacci retracement levels for trading decisions.\n- **Simple Moving Averages**: Implements short and long-period SMAs to determine the trend.\n- **Buy/Sell Signals**: Generates buy and sell signals based on the SMA and Fibonacci retracement levels.\n- **Stop Loss and Take Profit**: Includes mechanisms for stop loss and take profit orders.\n\n## Requirements\n\n- Python 3.8 or later\n- Backtrader\n- Pandas\n- NumPy\n\nYou can install the necessary packages using pip:\n```bash\npip install backtrader pandas numpy\n```\n\n## Project Structure\nThe project contains the following files and directories\n- `backtest.py`: Main script to run the backtest.\n- `strategies/`:\n    - `fibonacci_retracement.py:` Contains the strategy logic using Fibonacci retracement and SMAs.\n- `data/`: Directory for historical data CSV files.\n\n## Data\nEnsure you have a CSV file with historical trading data in the data/ directory. The CSV file should include the following columns:\n- `Date`: Date of the trading data (format: YYYY-MM-DD)\n- `Open`: Opening price\n- `High`: Highest price\n- `Low`: Lowest price\n- `Close`: closing price\n- `Volume`: Trading volume\n\nExample CSV filename: `fixed_EUR_USD_Historical_Data.csv`\n\n## Strategy\nThe `CombinedSMARetracementStrategy` in `strategies/fibonacci_retracement.py` uses the following parameters:\n- `sma_short_period`: Short-period SMA (e.g., 2 days)\n- `sma_long_period`: Long-period SMA (e.g., 4 days)\n- `stop_loss`: Stop loss percentage (e.g., 1%)\n- `take_profit`: Take profit percentage (e.g., 2%)\n- `fib_levels`: Fibonacci retracement levels (50%, 61.8%, 38.2%)\n\n## Buy Signal Condition\nThe buy signal is generated if:\n- The short-period SMA is above the long-period SMA (indicating an uptrend).\n- The current close price is below the 50% Fibonacci retracement level and previous close price was above it (indicating a pullback).\n\n## sell Signal Condition\nThe sell signal is generated if:\n- The short-period SMA is below the long-period SMA (indicating a downtrend).\n- The current close price is above the 50% retracement level and the previous close was below it (indicating a pullback).\n\n## Running the Backtest\nTo run the backtest, execute the `backtest.py` script:\n```bash\npython backtest.py\n```\nThe script will:\n1. Load the historical data from the CSV file.\n2. Calculate Fibonacci retracement levels.\n3. Initialize and run the Backtrader strategy.\n4. Print the starting and ending portfolio values.\n\nStarting Portfolio Value: 10000.00\nInitial Fibonacci Levels: {'50%': 154.79, '61.8%': 154.12, '38.2%': 155.45}\nBuy Signal - Current Close: 153.89, Previous Close: 155.77, Fib Levels: {'50%': 154.79, '61.8%': 154.12, '38.2%': 155.45}\nSell Signal - Current Close: 153.89, Previous Close: 155.77, Fib Levels: {'50%': 154.79, '61.8%': 154.12, '38.2%': 155.45}\nEnding Portfolio Value: 10000.00\n\n## Troubleshooting\n- Not Enough Data: Ensure your dataset has more rows than the maximum SMA period used in the strategy.\n- IndexError: Verify that your data has no missing values or gaps.\n- Array Assignment Index Out of Range: Verify compatibility between dataset and SMA periods.\n\n## Contributing\nContributions to improve this project are welcome! if you have suggestions, bug reports, or would like to contribute code, please feel free to open an issue or 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\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngunyigachie%2Fforex-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngunyigachie%2Fforex-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngunyigachie%2Fforex-bot/lists"}