Skip to content

A Google Apps Script that can be scheduled to log your daily Indexa Capital positions to Google Sheets

Notifications You must be signed in to change notification settings

victor-marino/indexa-gsheets-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 

Repository files navigation

Description

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.

Usage

Creating the project

  1. Go to script.google.com and create a new project.
  2. In the code editor, delete the existing code and paste everything from the code.gs file found in this repository.
  3. Give a name to your project and save it.

Configuring your settings

  1. Replace YOUR_API_TOKEN with your Indexa Capital API token. Instructions on how to obtain it here.
  2. 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.
  3. 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.
  4. If you want the resulting tables to be sorted from newest to oldest, set newestOnTop to true. This will ensure the latest value is always at the top.

Time for a test run!

Testing the script

Above the code editor, make sure the run function is selected:

google_app_script_run

Now hit the Run button:

Captura de pantalla 2024-02-29 a las 19 17 59

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:

Captura de pantalla 2024-02-29 a las 19 34 33

If something went wrong, you can take a look at the error messages in the log to figure out what happened.

Scheduling runs

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:

Captura de pantalla 2024-02-29 a las 19 39 36

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)

Captura de pantalla 2024-02-29 a las 19 45 35

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.

About

A Google Apps Script that can be scheduled to log your daily Indexa Capital positions to Google Sheets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published