How to download your Robinhood transaction history

I wanted to download a nicely formatted list of all my stock transactions (including dividends and cancelled transactions) but noticed there was no way doing that. I wrote up a little JavaScript code to quickly download the transaction list from Robinhood’s website.

Here’s how to do it yourself:

  1. go to https://robinhood.com/account/history in Chrome
  2. Scroll down to the bottom to where it says “Show more items” and click that button (so that all transactions are shown)
  3. Open the Chrome Dev Tools window (Windows — Ctrl + Shift + I, Mac — Option + Cmd + I)
  4. Paste this code into the console
function parseHTML() {
let csv = "Date\tType\tTotal\tTotal for Shares\tPrice per share\n";
const sections = document.querySelectorAll('section');
for (let i = 0; i < sections.length; i++) {
const transactions = sections[i].querySelectorAll(':scope > div') //
for (let j = 0; j < transactions.length; j++) {
const transaction = transactions[j].children[0].children[0];
if (transaction === undefined) {
continue;
}
const date = transaction.children[0]?.innerText.split('\n')[1]
const name = transaction.children[0]?.children[0]?.textContent
const total = transaction.children[0].children[1]?.textContent.replace("+", "");
let pps = '';
let numberOfShares = '';
if (total) {
if (total.includes('shares')) {
pps = total.split(' shares at ')[0];
numberOfShares = total.split(' shares at ')[1];
} else if (total.includes('at')) {
const split = total.split(/(\s+)/);
pps = split[0];
pps = pps.substring(0, pps.indexOf('.') + 3)
numberOfShares = split[split.length - 1];
} else {
pps = '';
numberOfShares = '';
}
}
csv += `${date}\t${name}\t${total}\t${pps}\t${numberOfShares}\n`
}
}
return csv;
}

function download(content, fileName, contentType) {
const a = document.createElement("a");
const file = new Blob([content], {
type: contentType
});
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}

download(parseHTML(), 'transactions.tsv', 'text/plain');

Then…

1. Press ENTER

2. Your TSV should now download!

3. Then open in Google Sheets, Excel etc.

Concluding Thoughts

It was nice using my coding experience in the wild. Keep in mind, as a rule of thumb it’s not a good idea to copy and paste code into Dev Tools from strangers :) but I promise there is no shady code there.

Alternatively if you’re having trouble with the instructions, you can use https://robinhood.com/contact to ask Robinhood directly for a spreadsheet of your transactions and they will email one to you within a day or two.

Originally posted on chriswalz.com

Moving forward.