Portfolio Slicer Data Scripts

Overview

Portfolio Slicer comes with a set of PowerShell scripts that are used to create files for Portfolio Slicer reports for Excel and Power BI.

Most of these scripts were created by community volunteers.

The scripting language PowerShell was chosen because:

  • Each Windows computer comes with PowerShell pre-installed.
  • Anyone can open an existing script, review the code, and confirm what that script does.

Script general information

All scripts come as one unit in the folder PSDataExtract. At the top level of this folder, there are multiple .bat files and a subfolder called Scripts, where all PowerShell scripts reside.

You can move this PSDataExtract folder, together with all of its subfolders, to any location on your computer. It does not have to be next to your Portfolio Slicer report files.

As a general rule, you will execute batch files (.bat) that call PowerShell scripts in a preset order. You might also consider scheduling these batch file executions, so you do not have to run them manually.

In the Scripts subfolder, next to the PowerShell scripts, there is a special file, psConfig.txt, that contains all configuration parameters. Before running the scripts for the first time, open this psConfig.txt file in Notepad (or any other editor) and change the parameter values to match your environment and data requirements. After that, you will need to edit this file only when you want to add different investments to your portfolio and therefore require quotes for those new investments.

Script logs

In the Scripts subfolder, there is a Log subfolder. Every script creates a log file in that folder with the same name as the script, but with a .txt extension.

You can review these log files and confirm whether the scripts were executed without errors.

Using your own scripts

You do not have to use the provided scripts to enjoy Portfolio Slicer. You are welcome to create your own scripts or code to create the necessary files for Portfolio Slicer reports. If you create your own scripts or code, please make sure that the files you create match the required formatting.

You might also consider using Artificial Intelligence (AI) prompts or bots to create these extract files for you.

Script types

We can group the existing scripts into 4 categories:

  • Scripts that extract data from the PortfolioSlicer-Source.xlsx file (for example: GetExcelSrcData.ps1, GetExcelCostBasis.ps1).
  • Scripts that add data in the required format (for example: psAppendGeneratedQuotes.ps1, psCreateDateFile.ps1)
  • Scripts that get quotes or exchange rate data from the web (for example: GetQuotes-Yahoo.ps1, GetExchRates-ECB.ps1)
  • Scripts that check or manage existing data files (for example: psCheckFiles.ps1, psArchiveOldQuotes.ps1)

Script that adds fixed prices quotes data

There is one script that adds fixed-price quotes to the Quotes.csv file. This is helpful when you have an investment with the same price over its life.

You can read more about this script here.

Scripts that get data from web

These scripts were created and are supported by community volunteers. Please understand that there are no guarantees that these web data sources will be available forever.

You can read more about choosing data source for quotes here.

You can read more about choosing data source for currency exchange here.

To be responsible, these scripts are built in a way that saves the data they receive locally. For example, your initial request for quotes could be from date 2000-01-01 up to today. All quotes received will be saved on your local computer, and the next time you request quotes, only the missing dates will be requested and added. This way, you are not repeatedly requesting large data sets from the web source, but only the data you are missing.

You can read more about how quote data is stored locally here and how currency exchange data is stored locally here.