The goal of this project is to get your Trading212 portfolio, calculate your returns and show everything in a graph without having to log in to the trading 212 website. This is achieved by getting the order information from a provided csv and/or the gmail of the user and searching in yahoo finance for the current price of the stock using the ISIN.
This project is designed for accounts with EURO currency. It converts Usd, GBp, and Nok to euro. You can add more conversions by adding a conversion variable in the yahooInfo function. (dont forget to use it after the āconvert everything to euros if necessaryā comment)
Place your (order data).csv which you can download from Trading212 (instructions here)and selecting ONLY the orders as included data. You need to name this file as orders and replace my own file.
You can also use your gmail (if it receives the emails from Trading212) in order to automatically update the orders data. Beware my script only gets the data from the āContract Note Statement from Trading 212ā so if you are informed about an order via the āMonthly statementā the code wonāt know anything about it.
If you donāt want to get the newest changes in your account using gmail then the Money Invested chart will be in your currency (even though it will show Euros) and the Current Stock Value chart will be in euros. The profit/loss bars will also be wrong since they will subtract from Current Stock Value the Money Invested (in your case it will be Euro - Usd). However, the fix in this case is reatively easy and I will post the answer probably today in the readme of my github.
If you are going to use the email fuctionality the script will probably break. This is because when it gets strings from the email to get the numbers it needs, I have used the word Euro that the string contains to split it where I want. It is a little more difficult to fix this because I donāt have an email from trading 212 in another currency to test it.
This project has been developed exclusively by me. English is my second language and it sounded kind of arrogant to use the word āIā so many times.
Itās okay man. I also updated the readme in case you want to use it for Usd. You did well to point it out in case anybody else wants to change the currency
Well done for sharing this! Open banking in action!!
If you could add Revolut Trading support, so that I could see a consolidated view of both my Revolut Trading and T212 portfolios, this would be a killer app!
Also a feature to generate the file I need to file my taxes on trade gain/loss !
There has been some time and I canāt edit the orginal post, but I have updated the program to use whatever currency you use in trading 212. You can always read the readme to see the most up to date instructions.
To change the currency to your own trading212 currency go to myPortfolio.py and change the variables USER_CURRENCY and USER_SYMBOL accordingly. For example for GBP you need to have USER_CURRENCY = "GBP" and USER_SYMBOL = "Ā£"
Unfortunately, I havenāt added the ability to change everything from trading212 currency to another currency because thatās something very specific and doesnāt concern a lot of people. In your case, you will have to have `USER_CURRENCY = āUSDā because thatās the currency your account uses.
Taxes is something very difficult to make in a program like this because they depend on your income. What is more, even if 2 people made the exact same money they will pay different taxes if they live in a different country. Thatās why itās almost impossible for me to implement and to tell you the truth I am too bored to even consider it
Thanks for this update. In my scenario where I make a small ā¬ gain just on currency fluctuation when the USD stock price does not move, will your software flag it as a ā¬ gain ?
Nice work. Iāve been building something similar to this myself. Iāll give it a try.
Hopefully in the future we can get an official API which just lets us download our portfolio as JSON. You can get that data already, but you have to intercept the WebSockets stream via the browser.