Access my portofolio with python

I have been looking for an api for trading 212 but I couldn’t find anything official. Do we have any information regarding the time that this will be become available? I am currently using a script to read my trading 212 emails and find out which positions I have and at what average price. However, this solution is not ideal since it gets slower as time goes on (my investing emails are constantly increasing because of my trades and it requires more and more time to read everything). If anybody has any suggestions on how to programmatically get the investment portofolio please feel free to write them. (Selenium is not really an option since when you open trading 212 on the browser it kicks you out from the app)
Thank you!

1 Like

I’ve never heard anything about an API. Has something been mentioned?

I manually (and laboriously) add things to spreadsheets. To get prices I use IEX Cloud (for free), or scrape the LSE. This isn’t ideal but I don’t make huge trades, though when investing in a Pie with many securities it can be quite time consuming. Of course the price updates are then done automatically using any simple script you like.

As for being kicked out of the app… that is really annoying. There are multiple accounts so you’d think you could have multiple windows open!

I think you could make your current process more efficient. See below thread. It imports trade activity from contract notes to a google sheet, and then archives the email.

You don’t need to re read every single contract note email each time you want to review your portfolio, that’s not a terribly efficient design.

This would then leave 212 to work on building a more robust system to deal with the additional user base, and add more value add features.

The information you need is already available, and users on this forum have built some excellent tools.

Hope the link helps.

1 Like

Or just download your transaction history … build your current positions… overlay prices - from iex, scrape from t212 or wherever… simples, fast… works for me


Yes, I read that before posting here but it only mentioned the api as something for the future with no particular date in mind. Also since I only want to see what I have currently in my portofolio and not actually trade I posted the question in case there is an easier solution that I haven’t thought about.

Yeah that’s what I do.

Download the full transaction history from the 212 app, import to google sheets, and then use google finance to source prices.

Probably much easier!

1 Like

No man, I always prefer to work on automating something for 2 hours rather than do it in 20 minutes. If the messages from trading 212 are sent to a gmail acount I already have the code ready to add everything to a csv. If you are interested I might change it to save the positions in excel instead and upload it in github. You ll only have to pip install a line from gmail and pyexcel.

Thank you very much. I actually didn’t read every email, I had a search string like this:

searchString = “from:( subject:(Contract Note Statement from Trading 212)”

and you can get all the emails that have an id that matches this search. I haven’t had a problem yet because always when I receive an email from trading 212 with this title it contains a change in my positions. I will read that thread in case it makes my program faster.

Wow, I wish I had found these earlier. Thank you.

No worries.

When you run your script, you could have it pull back the latest date/timestamp of its results.

Then next time when it runs, it stops when it passes that record to append your data. That way you won’t have to change too much coding?

yes, but we still should have an API for doing other stuff like actually sending trades or whatever. I would really appreciate it if they gave us an eta or just any news on an API.

1 Like

The problem with an API, would be the cost of developing and testing its robustness, so poor coding doesn’t result in a bottleneck from certain users impacting others.

I would also suspect that any API service would come at a cost to the API users and I’m not even aware of other brokers out there that provide this.

Its a good idea, but not important to most users I would think.

I suspect an API may already be in use internally.

I already save data to CSV, and then just import them (automatically) into LibreOffice. I have no use for Excel.

However, I have learnt something here today. Huzzah!

Yes, that’s what I am planning to do