HellAmbro / Trading212API

Unofficial Trading212 API
MIT License
57 stars 27 forks source link

get portfolio not working #14

Closed klllo closed 1 year ago

klllo commented 1 year ago

im getting this error. i dont know whats cousing it or how to fix it. once in a blue moon it works though Traceback (most recent call last): File "c:\Users\flori\OneDrive\stock\playground.py", line 242, in portfolio = trading212.get_portfolio_composition() File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\pytrading212\trading212.py", line 190, in get_portfolio_composition self.driver.find_element_by_class_name(right_sidepanel_portfolio_class).click() File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 89, in click self._execute(Command.CLICK_ELEMENT) File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 773, in _execute return self._parent.execute(command, params) File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in execute self.error_handler.check_response(response) File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element

...
is not clickable at point (29, 135). Other element would receive the click:
...
(Session info: chrome=104.0.5112.81) Stacktrace: Backtrace: Ordinal0 [0x00A378B3+2193587] Ordinal0 [0x009D0681+1771137] Ordinal0 [0x008E41A8+803240] Ordinal0 [0x00918C84+1019012] Ordinal0 [0x00916C48+1010760] Ordinal0 [0x0091493B+1001787] Ordinal0 [0x00913699+997017] Ordinal0 [0x00909223+954915] Ordinal0 [0x0092D7AC+1103788] Ordinal0 [0x00908C04+953348] Ordinal0 [0x0092D9C4+1104324] Ordinal0 [0x0093DAE2+1170146] Ordinal0 [0x0092D5C6+1103302] Ordinal0 [0x009077E0+948192] Ordinal0 [0x009086E6+952038] GetHandleVerifier [0x00CE0CB2+2738370] GetHandleVerifier [0x00CD21B8+2678216] GetHandleVerifier [0x00AC17AA+512954] GetHandleVerifier [0x00AC0856+509030] Ordinal0 [0x009D743B+1799227] Ordinal0 [0x009DBB68+1817448] Ordinal0 [0x009DBC55+1817685] Ordinal0 [0x009E5230+1856048] BaseThreadInitThunk [0x75F36739+25] RtlGetFullPathName_UEx [0x77CD90AF+1215] RtlGetFullPathName_UEx [0x77CD907D+1165]

klllo commented 1 year ago

and in your docu you say

close webdriver

trading212.close() this should be trading212.finish()

HellAmbro commented 1 year ago

and in your docu you say

close webdriver

trading212.close() this should be trading212.finish()

You are right, thanks, i forgot to modify the documentation

HellAmbro commented 1 year ago

im getting this error. i dont know whats cousing it or how to fix it. once in a blue moon it works though Traceback (most recent call last): File "c:\Users\flori\OneDrive\stock\playground.py", line 242, in portfolio = trading212.get_portfolio_composition() File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\pytrading212\trading212.py", line 190, in get_portfolio_composition self.driver.find_element_by_class_name(right_sidepanel_portfolio_class).click() File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 89, in click self._execute(Command.CLICK_ELEMENT) File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 773, in _execute return self._parent.execute(command, params) File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in execute self.error_handler.check_response(response) File "C:\Users\flori\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element

... is not clickable at point (29, 135). Other element would receive the click: ...

(Session info: chrome=104.0.5112.81) Stacktrace: Backtrace: Ordinal0 [0x00A378B3+2193587] Ordinal0 [0x009D0681+1771137] Ordinal0 [0x008E41A8+803240] Ordinal0 [0x00918C84+1019012] Ordinal0 [0x00916C48+1010760] Ordinal0 [0x0091493B+1001787] Ordinal0 [0x00913699+997017] Ordinal0 [0x00909223+954915] Ordinal0 [0x0092D7AC+1103788] Ordinal0 [0x00908C04+953348] Ordinal0 [0x0092D9C4+1104324] Ordinal0 [0x0093DAE2+1170146] Ordinal0 [0x0092D5C6+1103302] Ordinal0 [0x009077E0+948192] Ordinal0 [0x009086E6+952038] GetHandleVerifier [0x00CE0CB2+2738370] GetHandleVerifier [0x00CD21B8+2678216] GetHandleVerifier [0x00AC17AA+512954] GetHandleVerifier [0x00AC0856+509030] Ordinal0 [0x009D743B+1799227] Ordinal0 [0x009DBB68+1817448] Ordinal0 [0x009DBC55+1817685] Ordinal0 [0x009E5230+1856048] BaseThreadInitThunk [0x75F36739+25] RtlGetFullPathName_UEx [0x77CD90AF+1215] RtlGetFullPathName_UEx [0x77CD907D+1165]

It's working for me, can you please try again and let me know. Runexample.py and let me now. Thanks

klllo commented 1 year ago

it still happens from time to time but i tink i found a work around. the link https://demo.trading212.com/rest/v1/equity/value-order/min-max?instrumentCode=TICKER returns the maxSellQuantity which i need. maybe you could implement it in your api?

klllo commented 1 year ago
def quantity(self, order_id):
    response = requests.get(
        f"{self.base_url}/rest/v1/equity/value-order/min-max?instrumentCode={order_id}", headers=self.headers
    )
    return json.loads(response.content.decode("utf-8"))
klllo commented 1 year ago

this works for me :)

HellAmbro commented 1 year ago

Hi, i will update the API asap. Thanks for your help and support. I will let you now when the API will be updated. Thanks again.