Script News Download

Avatar
  • updated

Hello Community,

I have created this Python script that downloads the news from the site www.forexfactory.com and saves it in the directory (C:\Users\your_name\AppData\Roaming\MetaQuotes\Terminal\Common\Files\News\FF\*. csv) that uses CP.

It does not insert the values of "revised" and "revised_time.", the rest of the values are the same as Andrey has in Google Drive.

You can read more about the News Filter

The news are downloaded from:

Image 3258

You need to download Python 3.x and install the plugins run "pip3 install beautifulsoup4" and all others that you do not have installed

Image 3260


CommunityPowerEA_News_Download.py

Avatar
Ulises Cune
Quote from ferdinand tampubolon

how to use python download by free vpn? 

my isp block forexfactory web 

You can download python from the following URL: https://www.python.org/downloads/

If you get blocked, I can't help you much, sorry.

Avatar
Kirill El

Hi Ulises

Thanks a lot for the script.

In the files that I download using this script, the time is shifted by 8 hours compared to the files from the google-drive folder (from the article about the news filter). It shouldn't be like that, right?


examle (2022-12-01)

Image 4536

Avatar
Quote from Kirill El

Hi Ulises

Thanks a lot for the script.

In the files that I download using this script, the time is shifted by 8 hours compared to the files from the google-drive folder (from the article about the news filter). It shouldn't be like that, right?


examle (2022-12-01)

Image 4536

You can use sNewsLoader.ex5, my script for MT5. It does the same.

https://drive.google.com/file/d/1CAg_3pkgtFR4fUBPiIxzA7HKU8zVTRB1/view?usp=drive_link

Avatar
Kirill El
Quote from Andrey Khatimlianskyi

You can use sNewsLoader.ex5, my script for MT5. It does the same.

https://drive.google.com/file/d/1CAg_3pkgtFR4fUBPiIxzA7HKU8zVTRB1/view?usp=drive_link

Andrey, I tried to use sNewsLoader.ex5 , but it gives me an error

Image 4540

And because of this error, some of the records in the files have incorrect time

Image 4542


Avatar
Ulises Cune
Quote from Kirill El

Hi Ulises

Thanks a lot for the script.

In the files that I download using this script, the time is shifted by 8 hours compared to the files from the google-drive folder (from the article about the news filter). It shouldn't be like that, right?


examle (2022-12-01)

Image 4536

You should adjust the time of your computer 8 hours. The script had contemplated this. I'll check it again on different computers and time zones.

Avatar
Quote from Kirill El

Andrey, I tried to use sNewsLoader.ex5 , but it gives me an error

Image 4540

And because of this error, some of the records in the files have incorrect time

Image 4542


I'll check and fix it, thanks for the report!

Avatar
Ulises Cune

I don't see any major bugs. The schedule changes that you show are "normal". The EA handles it correctly.

Between the "Current News" and the "Past News" on www.forexfactory.com, the values and the name of the news sometimes change, but in essence, it is the same.

Backtesting:

Image 4551

Files:

Image 4550



Avatar
Quote from Kirill El

Andrey, I tried to use sNewsLoader.ex5 , but it gives me an error

Image 4540

And because of this error, some of the records in the files have incorrect time

Image 4542


I've investigated this. They changed html tags, so parsing works wrong.

I'll fix it and update the script

Avatar
jay hu
Quote from Ulises Cune

I don't see any major bugs. The schedule changes that you show are "normal". The EA handles it correctly.

Between the "Current News" and the "Past News" on www.forexfactory.com, the values and the name of the news sometimes change, but in essence, it is the same.

Backtesting:

Image 4551

Files:

Image 4550



Hi Ulises, I had an issue while I run your Python script, please see below:

C:\Users\XXX\Downloads> python CommunityPowerEA_News_Download.py
Mon Jan 1

Mon Jan 1 All Day CHF Bank Holiday
Traceback (most recent call last):
File "C:\Users\XXX\Downloads\CommunityPowerEA_News_Download.py", line 205, in
getEventsCalendar("calendar?month=" + m + "." + str(y), file_path)
File "C:\Users\XXX\Downloads\CommunityPowerEA_News_Download.py", line 67, in getEventsCalendar
calendar__impact = row.find('td', class_='calendar__impact').find('span')['title'][0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "C:\Users\XXX\AppData\Local\Programs\Python\Python311\Lib\site-packages\bs4\element.py", line 1573, in __getitem__
return self.attrs[key]
~~~~~~~~~~^^^^^
KeyError: 'title'

Thank you for your help!

CommunityPowerEA_News_Download.py

Avatar
Ulises Cune

Hello jay hu

The page https://www.forexfactory.com/ changed the html code where it reported the "impact" and that is why the Python script did not work. I fixed it. Thanks for reporting it.

The page changed the date and times of the news from the past. It would be necessary to check it with another source if it is ok.

CommunityPowerEA_News_Download.py
CommunityPowerEA_News_Download.bat