Comments (8)
Hi Chavithra,
Thank you for all, now error content is fully available and unnecessary lines have been removed.
I don't have a Discord account yet, I'll create one soon.
Regards
from degiro-connector.
Hello Ben,
to see the error messages : one solution is to use the logs
.
Here is how to setup logging level
:
import logging
logging.basicConfig(level=logging.DEBUG)
from degiro-connector.
Hello Chavithra,
Thank you, logging was already in DEBUG level, but the log doesn't return the confirmation error details.
Here is a way to reproduce:
Open an order for a price too low on stock : SOON | CH0012549785 limit 1.00CHF, size 1. (Displayed price at 12h48 is 350.10CHF with 15 minutes delay.)
Validate order, then confirm.
A popup shows this error message:
Le prix renseigné 1.0000 est trop bas par rapport au dernier prix 347.7000. Le prix minimum est de 278.1600.
Doing this by degiro_connector with:
order = Order(
action=Order.Action.BUY,
order_type=Order.OrderType.LIMIT,
price=1,
product_id=353484,
size=1,
time_type=Order.TimeType.GOOD_TILL_DAY,
)
checking_response = self.trading_api.check_order(order=order, raw=False)
# SEND CONFIRMATION
confirmation_response = self.trading_api.confirm_order(
confirmation_id=checking_response.confirmation_id,
order=order,
raw=True
)
All we got is a None response without content:
type(confirmation_response)
Out[21]: NoneType
In the log :
CRITICAL:degiro_connector.trading.actions.action_confirm_order:<Response [400]>
CRITICAL:degiro_connector.trading.actions.action_confirm_order:400 Client Error: Bad Request for url: https://trader.degiro.nl/trading/secure/v5/order/[...]
It seams to fail in confirmation response treatment.
Using another degiro python api from lolokraus : degiro), I can retrieve the error message and get the useful datas from the error text. The error returned has this content :
{"errors":[{"text":"Le prix renseigné 1.0000 est trop bas par rapport au dernier prix 347.7000. Le prix minimum est de 278.1600."}]}
If the error content could be returned instead of None, that would be useful for realtime price or tick size.
Thank you
Ben
from degiro-connector.
Le prix renseigné 1.0000 est trop bas par rapport au dernier prix 347.7000. Le prix minimum est de 278.1600.
You are French ?
Ok got your issue.
Released a new version with better error logging
.
Does that fit your need ?
from degiro-connector.
Thank you for your quick reaction!
I am Swiss, in the french speaking part.
I can now read the error in the log, but an error occurs:
UnboundLocalError: local variable 'response_dict' referenced before assignment
One objective is to use error content to get the tick size and correct the failing orders. Error logging is interesting, but won't help for automated orders correction.
I think these modifications in "action_confirm_order.py" may do the job (not sure it respects your coding style). The error content is retrieved if raw is set to True:
@classmethod
def confirm_order(
cls,
confirmation_id: str,
credentials: Credentials,
order: Order,
session_id: str,
logger: logging.Logger = None,
raw: bool = False,
session: requests.Session = None,
) -> Union[Order.ConfirmationResponse, Dict, None]:
if logger is None:
logger = cls.build_logger()
if session is None:
session = cls.build_session()
int_account = credentials.int_account
url = urls.ORDER_CONFIRM
url = f"{url}/{confirmation_id};jsessionid={session_id}"
params = {
"intAccount": int_account,
"sessionId": session_id,
}
order_dict = cls.order_to_api(order=order)
request = requests.Request(
method="POST",
url=url,
json=order_dict,
params=params,
)
prepped = session.prepare_request(request)
response_raw = None
try:
response_raw = session.send(prepped, verify=False)
response_raw.raise_for_status()
response_dict = response_raw.json()
except requests.HTTPError as e:
logger.fatal(response_raw.status_code)
logger.fatal(response_raw.text)
response_dict = response_raw.json()
except Exception as e:
logger.fatal(e)
response_dict = response_raw.json()
if raw is True:
return response_dict
else:
return None
if (
isinstance(response_dict, dict)
and "data" in response_dict
and "orderId" in response_dict["data"]
):
order.id = response_dict["data"]["orderId"]
if raw is True:
return response_dict
else:
return cls.confirmation_response_to_grpc(
payload=response_dict,
)
else:
if raw is True:
return response_dict
else:
return None
from degiro-connector.
So you are not only using this for debugging
: you want to returned error to do some automation with it ?
Maybe we can reach each other on Discord so we can find a solution which fit.
from degiro-connector.
@b-aeby Please see my ongoing issue #54 to return the fault data.
from degiro-connector.
from degiro-connector.
Related Issues (20)
- Order placement error
- Order placement error HOT 3
- connection errors HOT 1
- How to retrieve only today p/l?
- password encryption-decryption
- Incorrect padding HOT 4
- ConnectionError: 400 Client Error: Bad Request for url: https://trader.degiro.nl/login/secure/login HOT 6
- Historical prices? HOT 4
- ConnectionError: 429 Client Error: Too Many Requests for url: https://trader.degiro.nl/login/secure/login/totp HOT 2
- Checking response error when placing an order HOT 2
- Getting None on TransactionsHistory and AccountOverview after weekend update HOT 1
- Automated Tools to be disallowed from October 1st? HOT 5
- Quotecast API freezes after exactly 1 hour since August 30, 2022 HOT 2
- "Get Portfolio" does not returns the tickers names HOT 1
- Access to Order Book HOT 2
- Closing price end of day
- Protobuffer generated code out of date HOT 3
- Portfolio values not up to date
- Account blocked due to too many login attempts HOT 1
- Real-time data fetch issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from degiro-connector.