pkpio / pkpio.github.io

https://pkp.io
1 stars 0 forks source link

blog/exporting-trading-212-to-yahoo-finance/ #3

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Export Trading212 transactions toΒ CSV - Praveen Kumar Pendyala

Trading212 has been amazing since I started using it in January 2020. However, despite many requests, linked below, from the community to support exporting of transactions, there is no solution from the team, yet.

https://pkp.io/blog/exporting-trading-212-to-yahoo-finance/

janikasild commented 3 years ago

Im so happy I found your page, this is exactly that I need! I managed to do all the steps, but after setup.sh the process got stuck:

Requirement already satisfied: six<2,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from virtualenv) (1.15.0) Creating a virtual environment.. Activating virtual environment.. Installing requirements..

I have a patched Catalina OS mac, can this be the reason? Or something else? Big thanks and thanks for writing the script! I so hope I can set it up and running.

matteorizzo commented 3 years ago

Hi, I managed to set it up, hopefully correctly, but while it does find transactions, it doesn't write any to the files.

It seems to work for Invest, but I'm trying to download CFD positions, is that the problem?

pkpio commented 3 years ago

Thanks for trying @matteorizzo. Responding inline.

Hi, I managed to set it up, hopefully correctly, but while it does find transactions, it doesn't write any to the files.

It should write two files, a json and a csv file.

It seems to work for Invest, but I'm trying to download CFD positions, is that the problem?

That could be it! I have tested only using the ISA account in UK. Expected that it might just work for Invest. Haven't tested with CFD, sorry πŸ˜”

pkpio commented 3 years ago

Im so happy I found your page, this is exactly that I need! I managed to do all the steps, but after setup.sh the process got stuck:

Requirement already satisfied: six<2,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from virtualenv) (1.15.0) Creating a virtual environment.. Activating virtual environment.. Installing requirements..

I have a patched Catalina OS mac, can this be the reason? Or something else? Big thanks and thanks for writing the script! I so hope I can set it up and running.

Sorry for the late response. I missed the notification of your comment somehow. Will look into fixing that and responding quicker in future.

Sometimes it takes a while to install the dependencies. Maybe wait it out? I built and testing this on macOS Catalina as well.

Allentsai0731 commented 3 years ago

hey, I got a problem here, I am at the last step (Run setup.sh), my problem is how do I do that ? could u explain the last step in more detail?

thank you

pkpio commented 3 years ago

hey, I got a problem here, I am at the last step (Run setup.sh), my problem is how do I do that ? could u explain the last step in more detail?

thank you

It installs the python dependencies. What's the problem? Could you post the log?

Allentsai0731 commented 3 years ago

so I was trying to do it form what I learned from google, sorry that i have no background knowledge in python..., this is where i got:

Type help() for interactive help, or help(object) for help about object.

from selenium import webdriver browser = webdriver.Chrome('/Users/ping-chihtsai/Desktop/chromedriver') browser.get('https://live.trading212.com/')

in short, I have everything prepared, I just don't know how to Run this "setup.sh" in python

thanks for ur time!

pkpio commented 3 years ago

so I was trying to do it form what I learned from google, sorry that i have no background knowledge in python..., this is where i got:

Type help() for interactive help, or help(object) for help about object.

from selenium import webdriver browser = webdriver.Chrome('/Users/ping-chihtsai/Desktop/chromedriver') browser.get('https://live.trading212.com/')

in short, I have everything prepared, I just don't know how to Run this "setup.sh" in python

thanks for ur time!

Which platform are you using?

Allentsai0731 commented 3 years ago

I am using Python 3.9.1 (IDLE)

pkpio commented 3 years ago

I am using Python 3.9.1 (IDLE)

I mean operating system. I can only help with Linux or Mac. For Windows I'm afraid the scripts won't work. If you are using either Linux or Mac, you the setup.sh in a terminal application.

Allentsai0731 commented 3 years ago

hey I ran the command with terminal, however, I got an error message as follows: setup.sh Collecting virtualenv Downloading virtualenv-20.2.2-py2.py3-none-any.whl (5.7 MB) |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 5.7 MB 485 kB/s Collecting appdirs<2,>=1.4.3 Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB) Collecting six<2,>=1.9.0 Downloading six-1.15.0-py2.py3-none-any.whl (10 kB) Collecting filelock<4,>=3.0.0 Downloading filelock-3.0.12-py3-none-any.whl (7.6 kB) Collecting distlib<1,>=0.3.1 Downloading distlib-0.3.1-py2.py3-none-any.whl (335 kB) |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 335 kB 512 kB/s Installing collected packages: appdirs, six, filelock, distlib, virtualenv Successfully installed appdirs-1.4.4 distlib-0.3.1 filelock-3.0.12 six-1.15.0 virtualenv-20.2.2 WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available. You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -m pip install --upgrade pip' command. Creating a virtual environment.. Activating virtual environment.. Installing requirements.. ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

I am doing it on my Mac 11.1 Big Sur

pkpio commented 3 years ago

@Allentsai0731 you should run the script by going to the same folder as the setup.sh file in terminal. cd path-to-folder-with-setup.sh

Allentsai0731 commented 3 years ago

hey, sorry for another question,

what do i do with this step:Download and extract latest version of selenium webdriver to driver/

i mean I have downloaded and extracted it, but I am not sure I do I do with this file or where do i put it.

Thanks still trying to figure it out with step is wrong

Allentsai0731 commented 3 years ago

here is my error message:

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/username/Desktop/Trading212-CSV-Exporter-main/export.py", line 208, in exporter.run() File "/Users/username/Desktop/Trading212-CSV-Exporter-main/export.py", line 30, in run self.tearDown() File "/Users/username/Desktop/Trading212-CSV-Exporter-main/export.py", line 137, in tearDown self.browser.close() AttributeError: 'T212Exporter' object has no attribute 'browser'

pkpio commented 3 years ago

@Allentsai0731 Have you downloaded the selenium driver to the driver/ folder? All folders are relative to this scripts directory

Allentsai0731 commented 3 years ago

I am not sure, where exactly is this "driver/ folder"? or do I create one? and under which path?

Allentsai0731 commented 3 years ago

about the driver, I copy to usr/local/bin and it runs

chromedriver Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280@{#1761}) on port 9515 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully.

then I repeated the steps, and got another error:

/Users/username/.env/bin/python3: can't open file '/Users/username/export.py': [Errno 2] No such file or directory

Zorgosto commented 3 years ago

Hey, thanks for the script. I can run the script but I encounter this error for some reason: Traceback (most recent call last): File "C:\Users\user\Desktop\Trading212-CSV-Exporter\export.py", line 210, in exporter.run() File "C:\Users\user\Desktop\Trading212-CSV-Exporter\export.py", line 23, in run self.login() File "C:\Users\user\Desktop\Trading212-CSV-Exporter\export.py", line 45, in login emailEl.send_keys(self.config['Trading212']['Email']) File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\configparser.py", line 960, in getitem raise KeyError(key) KeyError: 'Trading212'

It seems like the program can't find the item from the config.ini file?

rainonthemoon commented 3 years ago

I get this error..

Logging in... Traceback (most recent call last): File "export.py", line 208, in exporter.run() File "export.py", line 22, in run self.login() File "export.py", line 44, in login loginEl.click() File "/Users/vishal/Desktop/Downloads/Trading212-CSV-Exporter-main/.env/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click self._execute(Command.CLICK_ELEMENT) File "/Users/vishal/Desktop/Downloads/Trading212-CSV-Exporter-main/.env/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute return self._parent.execute(command, params) File "/Users/vishal/Desktop/Downloads/Trading212-CSV-Exporter-main/.env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/Users/vishal/Desktop/Downloads/Trading212-CSV-Exporter-main/.env/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable (Session info: chrome=87.0.4280.141)

Zorgosto commented 3 years ago

You can now export the data from the Trading212 app as csv. I think they added that feature in one of the latest updates.

pkpio commented 3 years ago

You can now export the data from the Trading212 app as csv. I think they added that feature in one of the latest updates.

I will look make a convertor for Trading212 CSV format to Yahoo Finance

callyb123 commented 3 years ago

Hey man, thanks for this. Did you manage to get anywhere with the T212>YF convertor?

pkpio commented 3 years ago

@callyb123 yes I did. I been using it for a while now. I will update this article to reflect that.

https://github.com/praveendath92/trading212-csv

callyb123 commented 3 years ago

@callyb123 yes I did. I been using it for a while now. I will update this article to reflect that.

https://github.com/praveendath92/trading212-csv

Really appreciate this!