Automatic import of classifications

Domicile: I would like to inquire whether it is possible to set up and query the “domicile” field as well. I believe this would be significant for many people. For example, if someone dies with $60,000 in assets with a U.S. domicile, their heirs will have to pay estate tax. For this reason, it wouldn’t hurt to check this as well.

Furthermore, it could be significant from a tax perspective as well, because, for example, in the case of GB and IE domiciles, no withholding tax is deducted, but in the case of DE, NL, and FR, for example, 15% is deducted based on my country’s double taxation agreement…

If this can be implemented, I think it would be a very useful feature.

Domicile is not a taxonomie attribute but a security one.

(Python 3.12.3. I had no issues yet with any python3 version).

I still had the issue with connection errors. For me it looks like something on morningstar side eg. loadbalancer switching to another server or something similar. With the help of AI I changed the requests.get calls to requests_get_with_retry. This works fine for me. If you want I can send you the file

@tommi296: Maybe you can post the code here. I will then integrate it. Sounds like a useful increase in robustness.

see attached zip file. 8 requests.get-calls have been replaced with requests_get_with_retry calls. There are 5 retries with increasing waiting time (5s, 10s, 15s, 20s, 25s). Looks like this:

[ISHARES CORE EM IMI ACC]:
@ Retrieving data for fund IE00BKM4GZ66 from Morningstar API
(Name: “iShares Core MSCI EM IMI ETF USD Acc”)
(Ongoing Charge IE00BKM4GZ66: 0.18%)
(Fund type: “Equity”)
Connection error, retrying in 5s… (attempt 1/5)

portfolio-classifier.zip (20,2 KB)

Thank you very much @tommi296.

It is now added to new-api-branch (together with a deletion of cache.sqlite file, if it hasn’t been used in the last five minutes).

Hello @rylorin ,

I have 3 questions for you (and a big thank you for your contribution with localization of our taxonomies) :

  • I did not success in grouping Industries below Sectors, as a nested taxonomy. Is there a way by a local.json file ?
  • I did not success in wiewing “bond_style”, putting it in local.json but no output : {
    “active”: true,
    “name”: “Obligations > Styles”
    },
  • What are the viewIds for holdings, to get only Top100 for example instead of all ?

Hi Guys,

New in PP and really a newbie of a newbie with regards to programming.

Can you please point me to the correct direction on how to do this taxonomy thing using phyton?

For “my version” of the script, please go to github and download the new-api-branch of the script.
The link is in the following post:

Unfortunately, I haven’t properly updated the README yet for that branch. But it would need to contain something like this:

Installation

Requires Python 3 (and Portfolio Performance).

Steps:

  1. download this repository from github (aka: git clone this repository)

  2. run pip3 install -r requirements.txt in the install directory

  3. test the script by running: python portfolio-classifier.py test/multifaktortest.xml -stocks in the install directory. Then open the resulting file pp_classified.xml in Portfolio Performance.

Note: You might want to install and run this in a Python virtual environment. Make sure you have venv installed and cd to the install directory. Run python -m venv ppc-env (ppc-env is then the name of the new virtual environment). Run source ppc-env/bin/activate to enter the virtual environment. Run pip3 install -r requirements.txt (as in step 2 above). Use the script (as e.g. in step 3 above). When done, exit the virtual environment with deactivate.

Command Line Parameters

For the most recent set of command line parameters run: python portfolio-classifier.py -h

Here is what you will get:

And then please read the “How it works” chapter in the existing README.

Hope that helps.

(And if you would like to have some pre-defined colours for the taxonomies, have a look at the files in pp-portfolio-classifier/docs/taxonomy-json-templates/ and use e.g. AllTaxonomies.json. Best before even running the script for the first time).

Hi, I managed to install and run the code using gemini. LOL

Now I have this error:

WARNING: MORNINGSTAR API HAS CHANGED.

THIS VERSION OF THE SCRIPT WILL PROBABALY NOT WORK ANYMMORE.

Please try new-api-branch instead.

usage: portfolio-classifier.py [-h] [-d DOMAIN] [-stocks]

                           input_file \[output_file\]

portfolio-classifier.py: error: unrecognized arguments: python portfolio-classifier.py test/multifaktortest.xml

You didn’t install new-api-branch. You installed main branch. Please install new-api-branch. (See link in the referenced post or see discussion earlier in this thread:
Automatic import of classifications - #326 by Alfons1Qvor12)

I am totally lost now, I have done the following:

  1. deleted the folder.
  2. git clone the new-api-branch
  3. run the requirement.txt
  4. run the python

I am still getting this error:
WARNING: MORNINGSTAR API HAS CHANGED.

THIS VERSION OF THE SCRIPT WILL PROBABALY NOT WORK ANYMMORE.

Btw, I am using a MAC, not sure if it matters

Hi,

For some reason you still have the main branch. The new-api-branch does not have this error message. Check the file portfolio-classifier.py. The file on new-api-branch is almost double the size (~102 kB vs ~59 kB) and has about 2250 lines of code (main has only about 1150). It is sufficient, if you just replace this file with the new-api-branch version.

(I don’t think that Mac, Linux or Windows matters. Python should work similarly on all.)

Managed to make it working by downloading the folder and not cloning. Thanks for putting up with a newb like me. lol

Hi,

I tried your scrip and it was working well on a small Portfolio (with 18 etf/shares). But if I’m running it on a larger portfolio (43 etf/shares/bonds) I get the error message:

Loading XML file: XXX.xml
TypeError: sec.note.match is not a function
at ….node_modules\pp-portfolio-classifier\dist\xml-helper.js:90:44
at Array.map ()
at XMLHandler.getSecurities (….node_modules\pp-portfolio-classifier\dist\xml-helper.js:79:56)
at main (…\node_modules\pp-portfolio-classifier\dist\index.js:68:35)
at Object. (…node_modules\pp-portfolio-classifier\dist\index.js:95:1)
at Module._compile (node:internal/modules/cjs/loader:1830:14)
at Object..js (node:internal/modules/cjs/loader:1961:10)
at Module.load (node:internal/modules/cjs/loader:1553:32)
at Module._load (node:internal/modules/cjs/loader:1355:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)

any hints?

regards Thomas

Hello Thomas,

I have about 170 etf/shares/bonds actives in my portfolio without problem.
I think that the problem should be related to the note field content of one of your assets.

Regards

Hello,

1/ Unfortunately It does not work as (you) expected. You can use for example:

    "sector_in_industry": {
      "active": true,
      "parentTaxonomy": "industry",
      "parentCategory": "Semiconductors",
      "childTaxonomy": "stock_sector",
      "targetTaxonomy": "industry"
    },
    "industry_below_sector": {
      "active": true,
      "parentTaxonomy": "stock_sector",
      "parentCategory": "Technology",
      "childTaxonomy": "industry",
      "targetTaxonomy": "stock_sector"
    }

But you will only get Industries below Technology sector.

This is an interesting feature that could be implemented.
2/ I didn’t neither, that’s why it not active in the default configuration . I need to investigate more.

3/ all available views are listed in `docs/views.xml`. The Top100 view doesn’t exist. But a contributor send me a patch for this feature that I will try to publish in the next following days.
Regards

Hello,

1/ Thanks for the tip, I will try it.
3/ It’s me :wink:

Have a nice day

thanks a lot. I removed comments in the note field. now it works fine.

regards Thomas