You can use this Google Apps Script to automatically fetch your daily account positions from Indexa Capital and log them to your own Google Sheets document.
Your account data is accessed securely using Indexa's official API.
This can be useful to:
- Keep an offline, up-to-date history of the value of your assets within your own documents.
- Build your own historical charts and Google Sheets integrations without depending on Indexa or their API for past data.
- Build the price history of instruments that do not have a publicly available NAV, such as Indexa's own pension plans for self-employed people.
- Go to script.google.com and create a new project.
- In the code editor, delete the existing code and paste everything from the code.gs file found in this repository.
- Give a name to your project and save it.
- Replace
YOUR_API_TOKEN
with your Indexa Capital API token. Instructions on how to obtain it here. - Replace
YOUR_ACCOUNT_NUMBER
with the number of the account you want to monitor. It is an 8-character alphanumeric code that you can see in the web/app when browsing your account. - Enter the name of the Google Sheets file where you want to store the data. If it doesn't exist, it will be created. If it exists, new sheets will be added to it to store the data.
- If you want the resulting tables to be sorted from newest to oldest, set
newestOnTop
totrue
. This will ensure the latest value is always at the top.
Time for a test run!
Above the code editor, make sure the run
function is selected:
Now hit the Run
button:
Since this is the first run, the script will prompt you for all the required permissions to work with your Google Drive files. Once you grant them, the script should go ahead and create the necessary sheets to store the data (e.g.: one sheet per mutual fund).
The result should look like this:
If something went wrong, you can take a look at the error messages in the log to figure out what happened.
Now all that's left is to program the script so that it runs everyday on its own, without any human intervention.
To do this, just head over to Triggers
in the left side menu, then click the + Add Trigger
button:
Then configure the new trigger as follows:
- Function to run:
run
- What to run:
Main
- Event source:
Time-driven
- Type of time based trigger:
Day timer
- Time of day:
12:00 to 13:00
(or whatever you prefer)
And that's it! Press Save
and you're all set.
The script should run daily from now on, updating all your positions in the spreadsheet if there is new data.
Remember mutual funds and pension plans do not update their prices in bank holidays and other special dates, so you can expect repeated values in those cases.