Last active
November 17, 2020 01:24
-
-
Save Virksaabnavjot/5928bd4fd532dc7f4002c84a38610a86 to your computer and use it in GitHub Desktop.
Javascript Solution to Export Dividend Data from Trading212 (in JSON) - Trading212 Reporting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//let length = document.getElementsByClassName('r3p0r7s000-subheading'); | |
let length = 3; //you can change me around | |
let data = {dividends : [] }; | |
for (i=0; i <= length; i++){ | |
let companyName = document.getElementsByClassName('r3p0r7s000-subheading')[i].innerHTML; | |
let dividendAmount = document.getElementsByClassName('r3p0r7s000-main-info')[i].innerHTML; | |
var dividend = { | |
"companyName": companyName, | |
"dividendAmount": dividendAmount | |
} | |
data.dividends.push(dividend); | |
} | |
console.log(JSON.stringify(data)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo: https://codepen.io/virksaabnavjot/pen/zYBbJRa?editors=1010
Steps:

Step 1- Open a New Tab in Chrome > Right Click and Select Inspect
Step 2- Now Open your Trading212 Account in this Tab and Open the Dividends section as highlighted in screenshot below (select dates as required)
Solution in Action on Trading212
Step 3- On the Inspect Tool > Go to Console > Paste and Above Code and click enter to run (you can adjust the length value, still working on making that dynamic)
Sample Output - in JSON Format
{"dividends":[{"companyName":"Realty Income","dividendAmount":"+$0.14"},{"companyName":"Nucor","dividendAmount":"+$0.01"},{"companyName":"American Express","dividendAmount":"+$0.08"},{"companyName":"AGNC Investment","dividendAmount":"+$0.01"}]}
Step 4- Convert JSON Data to Table (then you can simply copy and paste it in Excel or Google Sheets)

Tool to convert JSON to a Table: http://json2table.com/
Please leave comments for any questions or feedback.
Thanks
Nav
Visit my blog at: https://mrvirk.com to read about some awesome javascript solutions and investing