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
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>
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
Thanks. I’m a noob. In this part of your instruction “ py portfolio-classifier.py <input_file>” . where I have to copy my input Xxx.xml file ? I put it in c:\ …. It seems not working. In the case it is correct to put it in c:\ … is it correct to write “ py portfolio-classifier.py c:\test.xml . Thanks
Thanks. It is not working. I receive the same error message.
$ py portfolio-classifier.py C:/Test.xml
C:\Users\samue\OneDrive\GIT\portfolio-classifier.py:331: SyntaxWarning: invalid escape sequence ‘{’
secid = re.search(‘{“i”:“([^”]+)"’, response).group(1)
Traceback (most recent call last):
File “C:\Users\samue\OneDrive\GIT\portfolio-classifier.py”, line 11, in
import requests
File “C:\Users\samue\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests_init_.py”, line 43, in
import urllib3
File “C:\Users\samue\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\samue\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py”, line 11, in
from .exceptions import (
File “C:\Users\samue\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’
how can I adapt the search pattern ? I see the file portfolio-classifier but i don’t know how to open and adapt it.
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\"(.+)\""
portfolio-classifier.py is a Python script. The script itself is in text form. So you need to open the file portfolio-classifier.py with any text editor (as explained by Rafa) and substitute line 394 with token_regex = r"const maasToken \=\s\"(.+)\"".
thanks for your support but the problem is not solved. Probably i’m doing other mistakes. This is the message that I received . Can you help me to understand where is the error ?
$ py portfolio-classifier.py C:/Test.xml
C:\Users\samue\OneDrive\GIT\portfolio-classifier.py:331: SyntaxWarning: invalid escape sequence ‘{’
secid = re.search(‘{“i”:“([^”]+)"’, response).group(1)
Traceback (most recent call last):
File “C:\Users\samue\OneDrive\GIT\portfolio-classifier.py”, line 11, in
import requests
File “C:\Users\samue\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests_init_.py”, line 43, in
import urllib3
File “C:\Users\samue\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\samue\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py”, line 11, in
from .exceptions import (
File “C:\Users\samue\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’