Automatic import of classifications

@fizban Thanks a lot, with the new version the script runs successful without errors. :+1:

I have been sucesfull with importing the classifications. Really good I appreciate this import but now i did it the second time with (the first time with file A converted from the program into B now with B converted into file C).
C has now 2 times the classifications. It seems that an update it is ot possible. I guess this as there are limitation with the PP API´s.
The question is for me is now how I am able to copy the classification from File B Fund ABC to my original file where all the other stocks etc are. Is there any more efficient way than doing this manually?

By the way I recoginzed that I get some minor Error due to the fact that the calssification is importing 0,00 % in the classification.
Import_Error1
Import_Error2
This happens in all the classifications Country, Sector,…
thanks

Hi guys. I am a PP newby which doesnt understand anything from coding but is realy into classification.
Can someone use the opportunity to summerise the progress on the automatic classification feature. I think a lot of time and frustration could be safed for a lot of users and it could realy lift PP to another level.

Hi, this is an awesome tool and works as advertised!

I just wonder whether it would be possible to also scrap the classification from the shares in the portfolio - or import an existing classification of shares into the output file.

I have the problem that I have a ETF / shares mixed portfolio and always have to manually classify the shares. Or maybe I am doing something wrong?

Cheers and have a great weekend!

2 Likes

Hello maddhin,

good query. I’ve also asked for such a feature half a year ago.

@fizban And one more thing: The script works well, also if there are single securities/stocks included in the portfolio. Nevertheless it does not consider already existing/assigned classifications of these stocks in the the newly calculated assignments in the “pp_classified.xml” file.
Is there an option to make this possible?
So let’s say I have already assigned “Country–>UnitedStates” to a single security. Then it should be possible that this assignment is considered within the newly calculated classification “Country” as “Country–>UnitedStates”.

Hi guys,

I have several but one portfolio which run well with pp-classifier. For one portfolio (which is OF COURSE my main portfolio!) I always get the following error message:

C:\Users\marti>“C:\Users\marti\OneDrive\Investments\pp-classifier\portfolio-classifier.py” “C:\Users\marti\OneDrive\Investments\PP Depots\DepotMartin - Kopie.xml” “C:\Users\marti\OneDrive\Investments\PP Depots\DepotAnalyseMartin.xml”
Traceback (most recent call last):
File “C:\Users\marti\OneDrive\Investments\pp-classifier\portfolio-classifier.py”, line 729, in
pp_file = PortfolioPerformanceFile(args.input_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\marti\OneDrive\Investments\pp-classifier\portfolio-classifier.py”, line 557, in init
self.pp_tree = ET.parse(filepath)
^^^^^^^^^^^^^^^^^^
File “C:\Users\marti\AppData\Local\Programs\Python\Python311\Lib\xml\etree\ElementTree.py”, line 1218, in parse
tree.parse(source, parser)
File “C:\Users\marti\AppData\Local\Programs\Python\Python311\Lib\xml\etree\ElementTree.py”, line 569, in parse
source = open(source, “rb”)
^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\marti\OneDrive\Investments\PP Depots\DepotMartin - Kopie.xml’

Does anybody know how to fix this?

Hi guys,

I just tried the script, but unfortunatelly I get the following error even when trying the Test-File:

PS C:\Program Files\Finanzen\Portfolio Performance\pp-portfolio-classifier-main> python portfolio-classifier.py test/multifaktortest.xml
Traceback (most recent call last):
File “C:\Program Files\Finanzen\Portfolio Performance\pp-portfolio-classifier-main\portfolio-classifier.py”, line 731, in
pp_file.add_taxonomy(taxonomy)
File “C:\Program Files\Finanzen\Portfolio Performance\pp-portfolio-classifier-main\portfolio-classifier.py”, line 589, in add_taxonomy
securities = self.get_securities()
^^^^^^^^^^^^^^^^^^^^^
File “C:\Program Files\Finanzen\Portfolio Performance\pp-portfolio-classifier-main\portfolio-classifier.py”, line 691, in get_securities
security_h = security.load_holdings()
^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Program Files\Finanzen\Portfolio Performance\pp-portfolio-classifier-main\portfolio-classifier.py”, line 351, in load_holdings
self.holdings.load(isin = self.ISIN, secid = self.secid)
File “C:\Program Files\Finanzen\Portfolio Performance\pp-portfolio-classifier-main\portfolio-classifier.py”, line 418, in load
bearer_token, secid = self.get_bearer_token(secid, domain)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Program Files\Finanzen\Portfolio Performance\pp-portfolio-classifier-main\portfolio-classifier.py”, line 395, in get_bearer_token
resultstringtoken = re.findall(token_regex, response.text)[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Can anybody tell me how to fix the problem?

Hello,

It seems that the Morningstar pages look a bit a different now. So you need to adpat the search pattern in line 394 to something like:
token_regex = r"const maasToken \=\s\"(.+)\""

Cheers.

2 Likes

Thanks a lot, now it is working!

Hi guys, does anybody have any idea why this one file is not working?

I have e.g. the portfolio files of my kids and those files work without any problem.

Anybody any hint how it can be that that one portfolio is not working?

The file-not-found error is nonsense as the file is there in the same folder, etc. as the other files that work…

Any hint is highly appreciated!

C:\Users\marti>“C:\Users\marti\OneDrive\Investments\pp-classifier\portfolio-classifier.py” “C:\Users\marti\OneDrive\Investments\PP Depots\DepotMartin - Kopie.xml” “C:\Users\marti\OneDrive\Investments\PP Depots\DepotAnalyseMartin.xml”
Traceback (most recent call last):
File “C:\Users\marti\OneDrive\Investments\pp-classifier\portfolio-classifier.py”, line 729, in
pp_file = PortfolioPerformanceFile(args.input_file)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\marti\OneDrive\Investments\pp-classifier\portfolio-classifier.py”, line 557, in init
self.pp_tree = ET.parse(filepath)
^^^^^^^^^^^^^^^^^^
File “C:\Users\marti\AppData\Local\Programs\Python\Python311\Lib\xml\etree\ElementTree.py”, line 1218, in parse
tree.parse(source, parser)
File “C:\Users\marti\AppData\Local\Programs\Python\Python311\Lib\xml\etree\ElementTree.py”, line 569, in parse
source = open(source, “rb”)
^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\marti\OneDrive\Investments\PP Depots\DepotMartin - Kopie.xml’

Would be really great when the python solution would work stable …

  • … also for single shares
  • … and most important, it should also updating already existing/imported classifications, so you can run it frequently after some months to update the classifications (to update top10 shares in the fonds/etf, to update percentatges of allocations, etc.).

Hi all, I tried the script today, but it is not running with the multifaktortest.xml. I get the following error messages:

PS C:\Users\becke\OneDrive\Dokumente\pp-portfolio-classifier-main> python portfolio-classifier.py test/multifaktortest.xml Traceback (most recent call last): File "C:\Users\becke\OneDrive\Dokumente\pp-portfolio-classifier-main\portfolio-classifier.py", line 731, in <module> pp_file.add_taxonomy(taxonomy) File "C:\Users\becke\OneDrive\Dokumente\pp-portfolio-classifier-main\portfolio-classifier.py", line 589, in add_taxonomy securities = self.get_securities() File "C:\Users\becke\OneDrive\Dokumente\pp-portfolio-classifier-main\portfolio-classifier.py", line 691, in get_securities security_h = security.load_holdings() File "C:\Users\becke\OneDrive\Dokumente\pp-portfolio-classifier-main\portfolio-classifier.py", line 351, in load_holdings self.holdings.load(isin = self.ISIN, secid = self.secid) File "C:\Users\becke\OneDrive\Dokumente\pp-portfolio-classifier-main\portfolio-classifier.py", line 418, in load bearer_token, secid = self.get_bearer_token(secid, domain) File "C:\Users\becke\OneDrive\Dokumente\pp-portfolio-classifier-main\portfolio-classifier.py", line 395, in get_bearer_token resultstringtoken = re.findall(token_regex, response.text)[0] IndexError: list index out of range

Can someone help me what could be the reason?

Thanks

Seems to be the same error I had. You have to change the portfolio-classifier.py file.

It is working.

Thanks a lot

Hello,
I am trying to use the script but so far I had no success.

When I try to install the libraries I get this :

PS C:\Users\Giuseppe\Desktop\pp-portfolio-classifier-main> py -m pip install -r requirements.txt
Requirement already satisfied: Jinja2==2.11.2 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from -r requirements.txt (line 1)) (2.11.2)
Requirement already satisfied: requests==2.24.0 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from -r requirements.txt (line 2)) (2.24.0)
Requirement already satisfied: requests-cache==0.5.2 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from -r requirements.txt (line 3)) (0.5.2)
Requirement already satisfied: jsonpath_ng==1.5.3 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from -r requirements.txt (line 4)) (1.5.3)
Requirement already satisfied: markupsafe==1.1.1 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from -r requirements.txt (line 5)) (1.1.1)
Requirement already satisfied: beautifulsoup4==4.9.3 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from -r requirements.txt (line 6)) (4.9.3)
Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from requests==2.24.0->-r requirements.txt (line 2)) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from requests==2.24.0->-r requirements.txt (line 2)) (2.10)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from requests==2.24.0->-r requirements.txt (line 2)) (1.25.11)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from requests==2.24.0->-r requirements.txt (line 2)) (2024.2.2)
Requirement already satisfied: ply in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from jsonpath_ng==1.5.3->-r requirements.txt (line 4)) (3.11)
Requirement already satisfied: decorator in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from jsonpath_ng==1.5.3->-r requirements.txt (line 4)) (5.1.1)
Requirement already satisfied: six in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from jsonpath_ng==1.5.3->-r requirements.txt (line 4)) (1.16.0)
Requirement already satisfied: soupsieve>1.2 in c:\users\giuseppe\appdata\local\programs\python\python312\lib\site-packages (from beautifulsoup4==4.9.3->-r requirements.txt (line 6)) (2.5)
PS C:\Users\Giuseppe\Desktop\pp-portfolio-classifier-main>

Then I try to run the script:

PS C:\Users\Giuseppe\Desktop\pp-portfolio-classifier-main> py portfolio-classifier.py Portfolio
C:\Users\Giuseppe\Desktop\pp-portfolio-classifier-main\portfolio-classifier.py:331: SyntaxWarning: invalid escape sequence ‘{’
secid = re.search(‘{“i”:“([^”]+)"’, response).group(1)
Traceback (most recent call last):
File “C:\Users\Giuseppe\Desktop\pp-portfolio-classifier-main\portfolio-classifier.py”, line 11, in
import requests
File “C:\Users\Giuseppe\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests_init_.py”, line 43, in
import urllib3
File “C:\Users\Giuseppe\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3_init_.py”, line 7, in
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
File “C:\Users\Giuseppe\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py”, line 11, in
from .exceptions import (
File “C:\Users\Giuseppe\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\exceptions.py”, line 2, in
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
ModuleNotFoundError: No module named ‘urllib3.packages.six.moves’
PS C:\Users\Giuseppe\Desktop\pp-portfolio-classifier-main>

Can someone help me?

1 Like

Did you adjust the Regex as recommended in the thread?

I have the same problem as Blackter3 with the multifaktortest.xml. And i already adjusted the Regex as recommended before

Ok so I managed to fix the issue. This line

No module named ‘urllib3.packages.six.moves’

made me think that the issue was not the script (i modified line 394 as suggested above) but the urllib3 library. Even if it was installed, uninstalling and reinstalling it fixed my issue. @dj_piepsarm do you have the no module named error too?

I had the same error. But with your solution, it works. Thank you

RequestsDependencyWarning: urllib3 (2.2.1) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "

I still have this like “warning” but it doesnt do much it seems.
I tried also some fixing with blackbox with installing and unistalling different packages, but the result is the same so i choose your fix