This script is designed to assist with backtesting by allowing you to analyze historical market data and news events as if they were live. This can be especially useful when using replay functions on platforms like TradingView or FXReplay.com.
- Date Synchronization: Automatically traverses dates within a specified range and fetches data for each day (and uses cache for multiple requests)
- Data Filtering: Filters events based on desired currencies and impact levels.
- Comprehensive Output: Presents filtered data in a table format, including date, time, currency, impact, event name, actual, forecast, and previous values.
- Backtesting Enhancement: Ideal for boosting your backtesting experience by providing historical context in sync with market data.
To run this script, you need the following Python packages:
pip install undetected-chromedriver
pip install selenium
pip install tabulate
pip install pandas
pip install matplotlib
pip install pickle
pip install redis
pip install seaborn
Caching is implemented via Redis to enhance performance, especially for repeated data fetches. To install Redis, follow the official installation guides:
Ensure Redis is running on your machine before running the script.
The script uses Chrome via `undetected-chromedriver` for scraping. The path to Chrome may differ depending on your operating system. If you are not using Windows or if Chrome is installed in a different location, you may need to update the `chrome_path` variable in the script:
chrome_path = "/path/to/your/chrome/executable"
To use this script, follow these steps:
-
Set Date Range: Manually set the
start_date
andend_date
in the script -
Configure Filters: Set the desired currencies and impact levels for scraping news data
-
Define Forex Pairs: Specify the forex pairs you want to analyze for correlation, ordered alphabetically
-
Set Resampling Timeframe: Define the timeframe for resampling the forex data. The
new_timeframe
variable can be set to different values, such as:'1min'
: Resample to 1-minute intervals'5min'
: Resample to 5-minute intervals'15min'
: Resample to 15-minute intervals'30min'
: Resample to 30-minute intervals'1h'
: Resample to 1-hour intervals'4h'
: Resample to 4-hour intervals (default)
-
Run the Script
New requests and functionality are always welcome! If you have ideas for improvements, feel free to open an issue or submit a pull request.
- ForexFactory.com: This script is not affiliated with ForexFactory.com. Scraping data from ForexFactory.com is against their Terms of Service. By using this script, you agree to take full responsibility for any consequences arising from such use.
- No Liability: The author of this script assumes no liability for any outcomes related to the use of this script. Use it at your own risk.
This script is released under the MIT License. This license is a permissive open-source license that is simple and easy to understand. It places very few restrictions on reuse and is generally accepted in the open-source community.