How dividend data for Portfolio Slicer is stored locally

Note - this page describes the behavior of the PowerShell scripts that were created by Maxim specifically for Portfolio Slicer. We adding documentation about Maxim's script behavior after realizing that they are used by the majority of Portfolio Slicer users.

Dividend data location

When you execute the script to extract dividend data from different sources, that dividend data is downloaded from some internet source and it is stored on your computer in the folder "<DataRootFolder>\Dividends". You can change <DataRootFolder> value in psConfig.txt file. By default, this parameter value is not specified and that implies that data root folder is "..\" - that is value relative to your script folder location.

Example 1: Your Portfolio Slicer scripts are located in the folder "c:\PortfolioSlicer\Scripts" and in psConfig.txt you have not specified "DataRootFolder" (value is empty).

<DataRootFolder>
</DataRootFolder>
In such configuration, your dividend data will be stored in the folder "c:\PortfolioSlicer\Dividends".

Example 2: Your Portfolio Slicer scripts are located in the folder "c:\PortfolioSlicer\Scripts" and in psConfig.txt you have specified "DataRootFolder" value as "c:\OneDrive\PortfolioSlicer\".

<DataRootFolder>
c:\OneDrive\PortfolioSlicer\
</DataRootFolder>
In such configuration, your dividend data will be stored in the folder "c:\OneDrive\PortfolioSlicer\Dividends".

Dividend file naming

In the Dividends folder, we will have 1 dividend file for each symbol with the name “_Symbol_.txt”. If the Symbol has special characters “:“, “^” or “&“, then these characters will be replaced with character “_“. Examples: For symbol “CCL” dividend data will be stored in the file “_CCL_.txt”. For symbol “TSE:XEI” dividend will be stored in the file “_TSE_XEI_.txt”. For symbol “ABC.L” dividend data will be stored in the file “_ABC.L_.txt”.

Dividends file content

Symbol dividend file contains multiple lines where each line represents dividend payment for that symbol for the specified date. Each line in this file has 3 values separated by a comma:

  1. The first value is dividend date in the format YYYY-MM-DD. Example: 2017-09-16. This value represents date when dividend amount will be added to Portfolio Slicer.
  2. The second value is dividend amount per share for that payment date. Please note that numeric value should be represented using North American number format, that is using “.” (dot) as decimal separator. Example: 123.45
  3. The third value is a symbol. Example: DVY
Here is an example of dividend file records:

Here are important rules about dividend files:

  • Dividend files MUST NOT have header line (first line describing each column).
  • Order of the records in the file is absolutely not important. But if for some reason you want to find last dividend date in the file, we recommend that you copy this table data into excel, convert that data range into table and then order it by date.
  • Scripts do not delete data from dividends files, but just append data to the end of the file. So if you run daily updates, you will notice that dividends with the latest day will be at the end of the file. But again, order of the records is not important.
  • There should NOT be any double quotes around any values.
  • Each file should have data just for one symbol.
  • For each day there should be just one record.
  • You can edit the file in any text editor, like notepad. You can adjust dividend values or delete duplicate records. You can delete multiple records, but if you do so, keep in mind, that generally, you might want to delete records within specific period where period ends with last dividend date!
  • When new dividend data is appended, scripts append data just after latest date of the record already in the file. If you have any missing dividend dates and want to re-extract dividends for them, then you need to delete all records that have a date after missing dividend dates and re-run extract script. Example - your dividends file has records up to 2017-09-19, but data for all month 2017-08 is missing. In such case delete all data from 2017-08-01 until 2017-09-19 and re-run extract. After this deletion, extract script will find last dividend date in file as 2017-07-31 and will request data from 2017-08-01 until today’s date.
  • Based on the above principle, if you change MinDate parameter value, dividends that are already in the file will not be changed. So if your MinDate was set to earlier date, then older dividends will not be extracted. At the same time, if you MinDate was set to later date, existing dividend records will not be deleted. So if you change MinDate, your should backup existing dividend file, remove the file from Dividends folder and re-run extract script.
  • It is always a good idea to backup your dividend files and/or store them on cloud-based (OneDrive, DropBox, GDrive) folder. Sometimes some dividend providers will stop supporting some symbols. Other times you will manually edit the file and accidentally change the file format. Or your computer could just crash and you will lose your files. Be prepared for that - always backup ALL data.

Manual dividend files

Any file that has extension .txt and is in Dividend folder OR “\Dividend\Manual” subfolder will be included into a final PSData\Dividends.csv file! It is recommended, that in Dividends folder you just keep symbols that you are currently actively extracting dividends for. For symbols that you do not trade anymore, it is recommended to move their dividend files to “\Manual” subfolder and remove that symbol from psConfig.txt or change parameter not to get Dividends for that symbol.

If you are planning to manually add dividend payment information, create a file for each symbol in a Dividends\Manual folder and add one line per each payment as per the example above.

How to specify symbol information for dividend extraction

In the psConfig.txt file, there are multiple sections (Yahoo, Google, GoogleWeb, Stooq, AlphaVantage) where you can specify symbols that you want to get quotes for using related scripts. At this point, we have just one script that gets dividend data from Yahoo finance website, so if you want to get dividend payment information automatically, you should make sure that your symbol can get data from Yahoo Finance website.
Here is an order of parameters that can be used when specifying Symbol:

Symbol,MinDate,MaxDate,IntraDayFlag[Y|N],[DividendFlag[Y|N],FactorHistory,FactorIntraDay,FactorDividend
As you can see 5th parameter is reserved for DividendFlag with possible values Y or N. If this parameter is not specified, then the default value of N will be used, so no dividend data will be extracted for that symbol!

Again, at this point DividendFlag symbol parameter value can be used just for Yahoo section and it will be ignored in all other sections!

Here are examples on how symbols can be specified:

  • AAPL
  • AAPL,2015-01-10
  • AAPL,,,/li>
  • AAPL,2015-01-10,2017-01-10,,Y
  • AAPL,,2017-01-10,Y,Y
  • LSE.L,,,,Y,0.01,0.01
If you specified your symbol in Yahoo section as per above examples, then for the first 3 lines NO DIVIDEND INFORMATION will be extracted and for last 3 lines script will attempt to get dividend payment information from Yahoo Finance website.

How dividends data is updated

Dividends for each symbol can come from different data sources, but as of writing this page, there is just one script (“Scripts\GetDividends-Yahoo.ps1”) that extracts dividend payment information from Yahoo Finance website. For each symbol script does following:

  • Script will calculate file name where the dividends should be stored.
  • Script will check if dividend file for that symbol already exists. If file is found, then script will find date for the latest dividend in that file and the next dividend request date will be that date plus 1 day. If file does not exists, then next dividend request date will be either SymbolMinDate (if specified next to symbol in the corresponding section) or parameters MinDate (from psConfig.txt) value.
  • Script will request dividends from calculated next dividend date until today.
  • Script will append newly received dividends (if any are available) to symbol dividend file.

Script logs

If you want to get more details on what happened during script execution, you should check log files in the folder “\Scripts\Log”. For every .ps1 script there will be same name log file with extension .txt. For example, for script GetDividends-Yahoo.ps1 there will be log file GetDividends-Yahoo.txt with detail log information. Usually this log file will contain URL that was send to source server to get dividend data. Example of the log file content: