degiroasync.core’s documentation
Contains core data structures and helpers for degiroasync.
- Key structures that are reused regularly through degiroasync API the below:
- Credentials 
- SessionCore 
- ORDER 
- PRODUCT 
- TRANSACTION 
- POSITION 
- ResponseError 
 
Check out their respective documentation for more details.
- exception degiroasync.core.BadCredentialsError
- Error raised when web API returns a badCredentials error. This is a specialized class of ReponseError. 
- class degiroasync.core.Config
- exception degiroasync.core.ContextError
- Raised when unexpected or incorrect context is detected. - Example: when some required Session attributes are missing. 
- class degiroasync.core.Credentials(username: str, password: str, totp_secret: str | None = None, one_time_password: str | None = None)
- Holds credentials for Web API. - If 2FA is enabled on the account, either totp_secret or one_time_password must be provided for the login to be successful. - totp_secret can be obtained in a 2FA editor/app (e.g. andOTP) in the ‘Secret’ field. - If use of one_time_password is chosen instead, be mindful that login must be called promptly as one_time_password expires frequently. 
- class degiroasync.core.ORDER
- Constants for orders in web API. - class ACTION(value)
- BUY
- Use when placing a _BUY_ order on a product. 
- SELL:
- Use when placing a _SELL_ order on a product. 
 - Check ORDER.TYPE for types of orders. - For use with checkOrder HTTP endpoint - or check_order degiroasync API calls. 
 - class STATUS(value)
- CONFIRMED
- The order was accepted by the platform. 
- REJECTED
- The order was not accepted by the platform. 
- PENDING
- The order is ‘PENDING’ on the web trader. 
 
 - class TIME(value)
- DAY
- This is the “Day” option in the web trader. Order placed for one day only: it expires at the end of the day it was created. 
- PERMANENT
- This is the “GTC” option in the web trader. This order sticks until it has been executed. Be careful that occasionally Degiro cancels Permanent orders due to various events. 
 
 - class TYPE(value)
- LIMITED
- This is the “Limit” field value of “Order type” in the web trader. 
- MARKET
- This is the “Market” field value of “Order type” in the web trader. 
- STOP_LOSS
- This is the “Stop Loss” field value of “Order type” in the web trader. 
- STOP_LIMITED
- This is the “Stop Limited” field value of “Order type” in the web trader. 
- AMOUNT
- This is the “Amount” field value of “Order type” in the web trader. It’s used for investment funds. 
 
 
- class degiroasync.core.PAClient
- exception degiroasync.core.ResponseError
- Raised when bad response has been received from server. 
- class degiroasync.core.SessionCore(config: 'Optional[Config]' = None, client: 'Optional[PAClient]' = None, _max_requests_default: 'int' = 40, _period_seconds_default: 'int' = 1, _cookies: 'Optional[httpx.Cookies]' = None, _http_client: 'Optional[ThrottlingClient]' = None)
- update_throttling(max_requests: int = 20, period_seconds: float = 1)
- Update throttling parameters. No limit if max_requests <= 0. - Note: going over 40 requests per second seems to trigger API bans. - Parameters:
- max_requests – Maximum number of requests per period_seconds before throttling. If <= 0, no limit. 
- period_seconds – Period on which to count requests. 
 
 
 
- degiroasync.core.camelcase_dict_to_snake(dict_in: Dict[str, Any], /, recursive: bool = True) Dict[str, Any]
- Convert keys of dictionary with str keys from camelCase to snake_case. - This does not care for structures with depth: values dictionaries will not be updated to snake_case. - >>> d = {'fooBar': 2, 'camelCase': {'camelCase': 1}} >>> camelcase_dict_to_snake(d) {'foo_bar': 2, 'camel_case': {'camel_case': 1}} >>> camelcase_dict_to_snake(d, recursive=False) {'foo_bar': 2, 'camel_case': {'camelCase': 1}} 
- degiroasync.core.camelcase_to_snake(text: str) str
- Convert a camelCase text to snake_case. - This helper replace any capitalized character by its lowered version preceded by ‘_’. - This helper does not check that input text is camel case or not. - >>> s = 'iAmCamelCase' >>> camelcase_to_snake(s) 'i_am_camel_case' >>> # Ignore fully uppercase text. >>> camelcase_to_snake("ALL_CAPS") 'ALL_CAPS' 
- degiroasync.core.check_session_client(session: SessionCore) CustomJSONWrapper
- Raise an exception if session.client is not set 
- degiroasync.core.check_session_config(session: SessionCore) CustomJSONWrapper
- Raise an exception if session.config is not set 
- degiroasync.core.join_url(*sections)
- Helper to build urls, with slightly different behavior from urllib.parse.urljoin, see example below. - >>> join_url('https://foo.bar', '/rest/of/url') 'https://foo.bar/rest/of/url' >>> join_url('https://foo.bar/product', '/rest/of/url') 'https://foo.bar/product/rest/of/url' >>> join_url('https://foo.bar/product/', '/rest/of/url') 'https://foo.bar/product/rest/of/url' >>> # We need this helper because of below ... # urllib.parse.urljoin behavior that is not suitable ... # for our purpose. >>> import urllib.parse >>> urllib.parse.urljoin('https://foo.bar/product', '/rest//of/url') 'https://foo.bar/rest/of/url' 
- degiroasync.core.lru_cache_timed(func: Callable | None = None, /, maxsize: int = 128, typed: bool = False, seconds: float | None = None)
- Time-sensitive LRU cache that works with async functions. - >>> @lru_cache_timed(seconds=120) ... async def foo(): ... asyncio.sleep(1) ... return 1 ... >>> import time >>> start = time.time() >>> await foo() 1 >>> time.time() - start > 1 True >>> start = time.time() >>> await foo() 1 >>> time.time() - start < .1 True 
- degiroasync.core.set_params(obj: Any, attributes_list: Iterable[Dict[str, str]], ignore_error=False) Any
- This is a helper to translate Degiro-format params to a Python object. - Set params on obj. - params is expected to be an iterable of dict with ‘isAdded’, ‘name’, ‘value’. See below for an example. - ```
- [
- {‘isAdded’: True,
- ‘name’: ‘id’, ‘value’: ‘8614787’}, 
- {‘isAdded’: True,
- ‘name’: ‘positionType’, ‘value’: ‘PRODUCT’}, 
- {‘isAdded’: True,
- ‘name’: ‘size’, ‘value’: 100}, 
- {‘isAdded’: True,
- ‘name’: ‘price’, ‘value’: 73.0}, 
- {‘isAdded’: True,
- ‘name’: ‘value’, ‘value’: 7300.0}, 
- {‘isAdded’: True,
- ‘name’: ‘accruedInterest’}, 
- {‘isAdded’: True,
- ‘name’: ‘plBase’, ‘value’: {‘EUR’: -6717.901595272}}, 
- {‘isAdded’: True,
- ‘name’: ‘todayPlBase’, ‘value’: {‘EUR’: -7300.0}}, 
- {‘isAdded’: True,
- ‘name’: ‘portfolioValueCorrection’, ‘value’: 0}, 
- {‘isAdded’: True,
- ‘name’: ‘breakEvenPrice’, ‘value’: 68.01}, 
- {‘isAdded’: True,
- ‘name’: ‘averageFxRate’, ‘value’: 1}, 
- {‘isAdded’: True,
- ‘name’: ‘realizedProductPl’, ‘value’: 97.098302728}, 
- {‘isAdded’: True,
- ‘name’: ‘realizedFxPl’, ‘value’: 0}, 
- {‘isAdded’: True,
- ‘name’: ‘todayRealizedProductPl’, ‘value’: 0.0}, 
- {‘isAdded’: True,
- ‘name’: ‘todayRealizedFxPl’, ‘value’: 0} 
 
 - ]