Created
January 3, 2020 20:02
-
-
Save jozsefs/092795dc81fbe15ef494b6d3b12c6459 to your computer and use it in GitHub Desktop.
etoro portfolio json export
This file contains 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
const data = [...document.querySelectorAll('.ui-table-row')].map(row => ({ | |
market: row.querySelector('.table-first-name').innerText, | |
units: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-units]').innerText.split('\n')[0].replace(/,/g, ''), | |
avgOpen: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-open-rate]').innerText, | |
invested: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-invested]').innerText.slice(1).replace(/,/g, ''), | |
pl$: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-container-profit]').innerText.replace(/[<,$]/g, ''), | |
plPercent: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-gain]').innerText.replace(/[<,%]/g, ''), | |
value: +row.querySelector('[data-etoro-automation-id=portfolio-overview-table-cell-container-equity]').innerText.replace(/[<,$]/g, '') | |
})); | |
JSON.stringify(data, null, 2); |
Most recent version (make sure to replace € sign with $ or whatever currency you are using):
const data = [...document.querySelectorAll('.et-table-row')].map(row => ({
market: row.querySelector('[automation-id=portfolio-overview-table-body-cell-market-name]').innerText,
units: +row.querySelector('[automation-id=portfolio-overview-table-body-cell-units-value]').innerText.split('\n')[0].replace(/,/g, ''),
avgOpen: +row.querySelector('[automation-id=portfolio-overview-table-body-cell-avg-open-rate]').innerText,
invested: +row.querySelector('[automation-id=portfolio-overview-table-body-cell-invested-value]').innerText.slice(1).replace(/,/g, ''),
pl$: +row.querySelector('[automation-id=portfolio-overview-table-body-cell-profit]').innerText.replace(/[<,€]/g, ''),
plPercent: +row.querySelector('[automation-id=portfolio-overview-table-body-cell-gain]').innerText.replace(/[<,%]/g, ''),
value: +row.querySelector('[automation-id=portfolio-overview-table-body-cell-equity]').innerText.slice(1).replace(/,/g, '')
}));
JSON.stringify(data, null, 2);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Export current portfolio history
Not optimized one-liner, only includes Buy/Sell actions, but no deposits, interest, withdrawels:
Make sure to click "SHOW MORE" at the end of the history page to really export all trades in selected time frame!