Closed VVIERV00 closed 2 years ago
Hi,
I think you are referring to the session timeout
, there is a limit of time a session is valid when unused.
Here are the sections related to session timeout
in the documentation :
Is that what you are looking for ?
I am referring to that the problem only happens with Orders, not Update's. I don't know why, I will try to debug. The final exception is
NoneType' object has no attribute 'confirmation_id'.
It then shouldn't have relation with timeouts
Issue Can you describe how to reproduce this issue ?
Code Is it possible to show the code which fails ?
Sorry for the late reply. I can confirm it is still failing:
order = Order(
action=actionType,
order_type=orderType,
price=lastPrice,
product_id=productId,
size=shares,
time_type=Order.TimeType.GOOD_TILL_DAY,)
checking_response = self.trading_api.check_order(order=order)
time.sleep(0.7)
try:
confirmation_id = checking_response.confirmation_id
free_space_new = checking_response.free_space_new
response_datetime = checking_response.response_datetime
transaction_fees = checking_response.transaction_fees
transaction_opposite_fees = checking_response.transaction_opposite_fees
transaction_taxes = checking_response.transaction_taxes
logging.debug(f"DEGIRO_{actionType}_CHECK_RESPONSE confirmation_id {confirmation_id} free_space_new {free_space_new} response_datetime {response_datetime} transaction_fees {transaction_fees} transaction_opposite_fees {transaction_opposite_fees} transaction_taxes {transaction_taxes}")
confirmation_response = self.trading_api.confirm_order(
confirmation_id=confirmation_id, order=order
)
logging.debug(f"DEGIRO_{actionType}_RESPONSE confirmation_response {confirmation_response} checking_response {checking_response}")
except Exception as e:
The exception e contains:
'NoneType' has no attribute 'confirmationId
And right before an exception is caught in action_check_order:134
try:
response_raw = session.send(prepped, verify=False)
response_raw.raise_for_status()
response_dict = response_raw.json()
except Exception as e:
Exception e:
400 Client Error: Bad Request for url: https://trader.degiro.nl/trading/secure/v5/checkOrder;jsessionid=D1AA41FB58C704CXXXXXXXXX.prod_a_XXX_X?intAccount=XXXXXXXX&sessionId=D1AA41FB58C704CXXXXXX.prod_a_XXX_X
Other API calls still seem to work properly (such as fetching portfolio). And the problem seems to happen after some hours of the API running, but still can't tell.
Questions
1/ So the call to check_order
method failed ?
2/ Is it failing at every single call of check_order
? randomly ? or after a certain duration ?
Looks like Degiro's website is being updated these days, that might be related.
I found the error! DeGiro doesn't keep an updated margin, also happens on the web. Sometimes you will make an operation, but the margin will take a while to update. Did you know about the issue and any workaround?
How did you find out about the margin ?
Making operations and checking the website margin showed. If lucky it will refresh in a couple of seconds, but there are times that it take up to 20 minutes to refresh. Degiro's website actually provides the date of the margin calculation. Using the margin to calculate ops (let say you want to use 10% of the available margin) can lead to failures as it's incorrect data.
The website doesn't seem to use any API call to calculate this margin
.
I am interested in knowing more on that margin
.
Feel free to join me on Discord if you want to see that together.
Thanks
I will eventually have to deal with that margin, so expect me on Discord. Thank you again.
Hi! first, thank you for the work you have put into this API. With the session still running (I can fetch the portfolio) given enough time, all actions return this error 400 Client Error: Bad Request for url: https://trader.degiro.nl/trading/secure/v5/checkOrder;jsessionid=D1AA41FB58C704CXXXXXXXXX.prod_a_XXX_X?intAccount=XXXXXXXX&sessionId=D1AA41FB58C704CXXXXXX.prod_a_XXX_X
The URL seems to be the same as when it performs the actions at the beginning of execution. Could it be an error with the sessionId?