chavithra / degiro-connector Goto Github PK
View Code? Open in Web Editor NEWThis is yet another library to access Degiro's API.
License: BSD 3-Clause "New" or "Revised" License
This is yet another library to access Degiro's API.
License: BSD 3-Clause "New" or "Revised" License
Hello,
I can't check a stoploss order, an internal server error is returned:
order = Order(
action=Order.Action.SELL,
order_type=Order.OrderType.STOP_LOSS,
stop_price=110.0,
product_id=4457,
size=1,
time_type=Order.TimeType.GOOD_TILL_CANCELED,
)
CRITICAL:trading.basic:500
CRITICAL:trading.basic:{"errors":[{"text":"Internal server error"}]}
The same datas as a json send to the check order url yields no error and allows to confirm the order.
sellOrder = {
'buySell': 1, # buy = 0, sell = 1
'orderType': 3, # stoploss order
'productId': 4457, # SAP id
'size': 1, # number of shares to buy/sell
'timeType': 1, # day = 1, permanent = 3
'stopPrice': 110.0, # stop loss
}
I have a custody account... BUY orders are OK
Could you please provide a working example for each order type ?
Congratulations for the awesome job you've done so far.
Regards
Benjamin
Hi there,
Thank you for your work. I am having the following issue:
order=Order(id=order_id,action=Order.Action.BUY,order_type=Order.OrderType.LIMIT,price=price,product_id=order_id,size=size,time_type=Order.TimeType.GOOD_TILL_DAY)
I get:
*** TypeError: '966ffcae-48c6-49fc-84c8-bfcbcbde0132' has type str, but expected one of: int, long
However id is the order which is a string. What should I do?
hi
I am trying to get some examples to work but to get them working is not as straightforward as I hoped.
to start simple I wanted to list all stocks in netherlands with productsearch. I managed to look up the id for netherlands (978) with trading_api.get_config()
I copied the following code from product_search.py
request_stock = ProductSearch.RequestStocks(
stock_country_id=978,
offset=0,
limit=100,
require_total=True,
sort_columns="name",
sort_types="asc",
)
stock_list = trading_api.product_search(request=request_stock, raw=False)
however print(stock_list.products)
always prints an empty list.
I tried to lookup a stock with its ticker n("AD" for "Koninklijke Ahold Delhaize NV" on AEX with code copied from product_lookup.py
# SETUP REQUEST
request_lookup = ProductSearch.RequestLookup(
search_text="AD",
limit=2,
offset=0,
product_type_id=1,
)
# FETCH DATA
products_lookup = trading_api.product_search(request=request_lookup, raw=False)
products_lookup_dict = message_to_dict(message=products_lookup)
print(products_lookup_dict)
again I only get an empty list in products
I am really missing some form of documentation so I can see what all parameters are doing to fix my code.
could somebody provide some guidance? Thanks in advance!
I am trying to get products info for that i am getting {'errors': [{'text': 'No corresponding resource found'}]} even though ids are actually valid
I was considering around for zero commissions and but the platform they have is too slow in placing orders. I came across this api but I'm not a programmer and I wanted to ask you but is it possible to create a GUI interface for order entry? in practice it consists of the book where the quantities and the price are entered and the window where the orders entered appear. The platform I use is written in java I attach a photo to make you understand what I mean. Thank you
For example the Trading API might return a negative response while creating or updating orders, see for example the error response in #50 (comment)
{"errors": [{"text": "Le prix renseigné (300.0500) ne respecte pas la tick size (écart minimal entre les décimales). Le prix doit être un multiple de (0.1000)."}]}
However, this is only observed in the CRITICAL Logging.
The functions check_order()
, confirm_order()
and update_order()
will return just None
in case of an error.
It's important to know what the cause of the error is. Is it for example an error with the order (such as the example above), which is refused by DeGiro?
Or is it caused by a server error (HTTP Status codes) or even no internet connection (HTTP Connection error)?
This data seems already present in the underlying code of the Connector, as can be seen in the Logging messages.
Would it be possible to use this in the response of the functions?
For example the standard output of these functions can be a dict with 3 parameters. Here the response of a successful request:
{
"http_status" : 200
"result" : True
"error" : None
}
where result
can also contain a dict, for example with the current response from check_order()
In case of a DeGiro error, it will look like:
{
"http_status" : 200
"result" : False
"error" : 'Le prix renseigné (300.0500) ne respecte pas la tick size (écart minimal entre les décimales). Le prix doit être un multiple de (0.1000).'
}
In case of a Network error, it will look like:
{
"http_status" : 500
"result" : False
"error" : 'The server has an internal error.'
}
This information is useful for our script, to decide what fault action to take. E.g.
Please let me know if this is possible.
First of all many thanks, this is really great work Chavithra!
I have a few questions. Would it be possible to the the size of the bid and ask? We can get the bidPrice and askPrice, but for how many shares is this (or contracts, in the derivates market)?
And second, is it possible to get a snapshot of the dept of the orderbook?
First: this is an awesome project, kudo's to you and everybody contributing. I'm trying to get started and most things are working. But when I fire example scripts found on this repository like
order.py
or
favourites_list.py
Connecting goes fine, but after that I'm getting [CRITICAL] results like this saying '404' and 'None'. Seems like the URL being loaded doesn't exist. I've been playing around for a bit, but I can't fix this. Did deGiro changed their URL's maybe?
root@servert:/degiro-connector/api# ./show_favourites.py
DEBUG:degiro_connector.trading.api:setup_one_action : check_order
DEBUG:degiro_connector.trading.api:setup_one_action : confirm_order
DEBUG:degiro_connector.trading.api:setup_one_action : connect
DEBUG:degiro_connector.trading.api:setup_one_action : delete_order
DEBUG:degiro_connector.trading.api:setup_one_action : get_account_info
DEBUG:degiro_connector.trading.api:setup_one_action : get_account_overview
DEBUG:degiro_connector.trading.api:setup_one_action : get_agenda
DEBUG:degiro_connector.trading.api:setup_one_action : get_cash_account_report
DEBUG:degiro_connector.trading.api:setup_one_action : get_client_details
DEBUG:degiro_connector.trading.api:setup_one_action : get_company_profile
DEBUG:degiro_connector.trading.api:setup_one_action : get_company_ratios
DEBUG:degiro_connector.trading.api:setup_one_action : get_config
DEBUG:degiro_connector.trading.api:setup_one_action : get_favourites_list
DEBUG:degiro_connector.trading.api:setup_one_action : get_financial_statements
DEBUG:degiro_connector.trading.api:setup_one_action : get_latest_news
DEBUG:degiro_connector.trading.api:setup_one_action : get_news_by_company
DEBUG:degiro_connector.trading.api:setup_one_action : get_orders_history
DEBUG:degiro_connector.trading.api:setup_one_action : get_products_config
DEBUG:degiro_connector.trading.api:setup_one_action : get_products_info
DEBUG:degiro_connector.trading.api:setup_one_action : get_top_news_preview
DEBUG:degiro_connector.trading.api:setup_one_action : get_transactions_history
DEBUG:degiro_connector.trading.api:setup_one_action : get_update
DEBUG:degiro_connector.trading.api:setup_one_action : logout
DEBUG:degiro_connector.trading.api:setup_one_action : product_search
DEBUG:degiro_connector.trading.api:setup_one_action : update_order
DEBUG:degiro_connector.core.models.model_session:session:getter: MainThread
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): trader.degiro.nl:443
DEBUG:urllib3.connectionpool:https://trader.degiro.nl:443 "POST /login/secure/login HTTP/1.1" 200 None
INFO:degiro_connector.trading.actions.action_connect:get_session_id:response_dict: {'isPassCodeEnabled': True, 'locale': 'nl_NL', 'redirectUrl': 'https://trader.degiro.nl/trader/', 'sessionId': '***.prod_b_126_3', 'status': 0, 'statusText': 'success'}
DEBUG:degiro_connector.core.models.model_session:session:getter: MainThread
DEBUG:urllib3.connectionpool:https://trader.degiro.nl:443 "GET /pa/secure/favourites/lists?intAccount=0&sessionId=***.prod_b_126_3 HTTP/1.1" 404 None
CRITICAL:degiro_connector.trading.actions.action_get_favourites_list:404
CRITICAL:degiro_connector.trading.actions.action_get_favourites_list:{"errors":[{"text":"No corresponding resource found"}]}
Traceback (most recent call last):
File "./show_favourites.py", line 43, in <module>
for list in favourites_list.values:
AttributeError: 'NoneType' object has no attribute 'values'
Is this type comparison right (I cannot test since I never had the a_rel being returned), list[str,str] (=vwd_id, metric) vs. str?
elif message["m"] == "a_rel":
delete_list = []
for reference in references:
**if references[reference] == message["v"][0]:**
delete_list.append(reference)
for reference in delete_list:
del references[reference]
hi @Chavithra I am trying to fetch prices with chart like so:
# PREPARE REQUEST
request = Chart.Request()
request.culture = "en-US"
request.requestid = "1"
request.resolution = Chart.Interval.PT1M
request.period = Chart.Interval.P1M
for stock_vwd in stocks:
request.series.append("price:vwdkey:"+stock_vwd)
request.tz = "Europe/Paris"
# FETCH DATA
chart = quotecast_api.get_chart(
request=request,
raw=False,
)
ChartHelper.format_chart(chart=chart, copy=False)
df = {}
for serie in data.series:
df_s = ChartHelper.serie_to_df(serie=serie)
df_s["timestamp"] = pd.to_datetime(df_s["timestamp"], unit="s")
df_s.set_index('timestamp', inplace=True)
df[vwd_to_ticker[serie.id.split(':')[-1]]] = df_s['price']
here vwd_to_ticker is a dictionary which maps the vwdid to the ticker.
but when I look at the resulting data after putting it in a dataframe I noticed some strange things. First of all the number of samples per stock differs. When I join them together I get spots of 1 interval (I tried both hour and minute resolution) where data is missing for one of the two stocks.
The data also stops an hour before realtime
More strangely I can not match the data I am seeing to the UI. The UI seems to show me a different price then what I am getting back. Is this charting data the closing price per interval?
Is this a timezone issue? Am I wrong in parsing the timestamp the way I do it?
Thanks in advance for your help if possible!
Hello! 👋
Both in the README (https://github.com/Chavithra/degiro-connector#214-how-to-get-chart-data-) and in one of the example files (https://github.com/Chavithra/degiro-connector/blob/main/examples/quotecast/chart_format.py#L40), there's a request override
being used, but it's not clear to me when and why I should use that.
Also in my own attempts, if I do:
request = Chart.Request()
request.culture = self.culture
request.period = Chart.Interval.P1D
request.requestid = "1"
request.resolution = Chart.Interval.P1Y
request.series.append("ohlc:issueid:360148977")
request.tz = self.timezone
# request.override["resolution"] = "P1D"
# request.override["period"] = "P1Y"
# FETCH DATA
chart = quotecast_api.get_chart(request=request, raw=True)
I get no data in the response, but if I remove the comments on the overrides, then it works. Why are the overrides needed?
I'm able to create and confirm an order based on your documentation.
When trading on the DeGiro website, once an order is executed, a popup is shown briefly.
Is there a way to subscribe to this event via the connector?
Or should we poll actively to see the changes.
For example to retrieve pending orders, and when the id
is not in, assume it's executed.
Or via OrdersHistory or TransactionsHistory?
Hello,
thank you very much for your great work.
I'm trying to use ChartHelper.serie_to_df on windows and i'm getting this error:
File "c:\Mauro\Python\yfinance\chart_format_ori.py", line 58, in
chart0_df = ChartHelper.serie_to_df(serie=chart.series[0])
File "C:\Mauro\Python\yfinance\yfin\lib\site-packages\degiro_connector\quotecast\actions\action_get_chart.py", line 197, in serie_to_df
return pd.DataFrame(serie.data, columns=columns)
File "C:\Mauro\Python\yfinance\yfin\lib\site-packages\pandas\core\frame.py", line 730, in init
raise ValueError("DataFrame constructor not properly called!")
ValueError: DataFrame constructor not properly called!
I run the same code on a linux machine and i got no errors.
Can you guys help me.
Thank's
MS
hello,
i'm just trying this code to get an overview of my portfolio
import json
import logging
import degiro_connector.quotecast.helpers.pb_handler as pb_handler
import pandas as pd
from IPython.display import display
from degiro_connector.trading.api import API as TradingAPI
from degiro_connector.trading.pb.trading_pb2 import (Credentials, Update)
# SETUP LOGGING LEVEL
logging.basicConfig(level=logging.INFO)
# SETUP CONFIG DICT
with open('config/config.json') as config_file:
config_dict = json.load(config_file)
# SETUP CREDENTIALS
username = config_dict['username']
password = config_dict['password']
totp_secret_key = config_dict['totp_secret_key']
credentials = Credentials(
int_account=None,
username=username,
password=password,
totp_secret_key=totp_secret_key
)
# SETUP TRADING API
trading_api = TradingAPI(credentials=credentials)
# CONNECT
trading_api.connect()
# ACCESS SESSION_ID
session_id = trading_api.connection_storage.session_id
# print('You are now connected, with the session id :', session_id)
# SETUP REQUEST
request_list = Update.RequestList()
request_list.values.extend([
Update.Request(option=Update.Option.PORTFOLIO, last_updated=0),
])
update = trading_api.get_update(request_list=request_list)
update_dict = pb_handler.message_to_dict(message=update)
total_portfolio_df = pd.DataFraany hints?me(update_dict['total_portfolio']['values'])
but looks like update_dict
does not contain total_portfolio
File "main.py", line 48, in <module>
total_portfolio_df = pd.DataFrame(update_dict['total_portfolio']['values'])
KeyError: 'total_portfolio'
any hints?
Hi Chavithra,
great work you did here with this api!
I have one problem though. the update_order seems not to work.
I am trying to update an existing stop-limit order (I got the orderId of this order previously)
python code:
order = Order(
id=orderId,
action=Order.Action.BUY,
order_type=Order.OrderType.STOP_LIMIT,
price=15.30,
stop_price=15.20,
product_id=18431361,
size=1,
time_type=Order.TimeType.GOOD_TILL_CANCELED,
)
# UPDATE ORDER
succcess = trading_api.update_order(order=order)
When I capture the http request I see that the body of the request looks like this:
{
"buySell": 0,
"orderType": 1,
"price": 0,
"productId": 18431361,
"size": 1,
"timeType": 3
}
For some reason buySell and price get set to 0 -> couldn't figure out why myself, hence this issue.
Best Regards! and keep up this amazing work!
I see there is currently no way to fetch historical data. Would this be possible to implement?
I would also like to help out with development. If you have a to-do list, it would be great to share it. Thanks!
Hi! 👋
This project requires pandas <= 1.1.5
: https://github.com/Chavithra/degiro-connector/blob/main/pyproject.toml#L26
Is there any particular version of why it needs to be <= 1.1.5? That version is almost 1 year old, and it would be great to bump the requirement to allow newer versions (1.3.x) if there are no known issues.
I want to let you know how much I love this project, thank you for your amazing work in here. Probably the most useful degiro wrapper in python ever! Also, the work you have done in the examples is very neat.
Thanks you!
First off thank you very much for this very well made package.
When trying to fetch chart data using quotecast for longer periods like P1M or P3M etc I would like the resolution to be 1 day.
Looking at degiro itself it seems like a resolution code of P1D, P7D and P1M is being used in the requests, for instance:
resolution=P1D
culture=nl-NL
period=P3M
series=issueid%3A613007
series=price%3Aissueid%3A613007
format=json
callback=vwd.hchart.seriesRequestManager.sync_response
userToken=???
tz=Europe%2FAmsterdam
Looking at the pb2 enum it seems like we only have intraday resolutions and we're missing the P1D
, P7D
and P1M
resolutions.
Thanks again for the great work you're doing!
Cheers,
Michel
Today I found out that I cannot search ETFs anymore, I get the following error:
Traceback (most recent call last):
File "<stdin>", line 22, in <module>
ValueError: Protocol message RequestETFs has no "popularOnly" field.
The relevant request part is the following:
# [...]
# setup trading api
trading_api = TradingAPI(credentials=credentials)
# connect to trading api
trading_api.connect()
# setup request
request = ProductSearch.RequestETFs(
popularOnly=False,
inputAggregateTypes='',
inputAggregateValues='',
searchText=sys.argv[1],
offset=0,
limit=1000,
requireTotal=True,
sortColumns='name',
sortTypes='asc',
)
# fetch data
etf_list = trading_api.product_search(request=request,raw=True)
# print output
print(json.dumps(etf_list))
If I remove the "popularOnly" parameter it complains about "inputAggregateTypes" and so on. If I remove every parameter it returns an unsorted list as expected.
I tried to run example, but all fail due to:
Traceback (most recent call last):
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 184, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/Users/birdie/PycharmProjects/degiro-connector/examples/quotecast/realtime_poller.py", line 23, in <module>
quotecast_api.connect()
File "/Users/birdie/PycharmProjects/degiro-connector/degiro_connector/core/abstracts/abstract_action.py", line 72, in __call__
return self.call(*args, **kwargs)
File "/Users/birdie/PycharmProjects/degiro-connector/degiro_connector/quotecast/actions/action_connect.py", line 66, in call
session = self.session_storage.session
File "/Users/birdie/PycharmProjects/degiro-connector/degiro_connector/core/models/model_session.py", line 85, in session
self.__local_storage.session = self.build_session(
File "/Users/birdie/PycharmProjects/degiro-connector/degiro_connector/core/models/model_session.py", line 68, in build_session
session.mount("https://", TLSAdapter())
File "/Users/birdie/Library/Python/3.8/lib/python/site-packages/requests/adapters.py", line 129, in __init__
self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)
File "/Users/birdie/PycharmProjects/degiro-connector/degiro_connector/core/models/model_session.py", line 22, in init_poolmanager
ctx.set_ciphers("DEFAULT@SECLEVEL=1")
ssl.SSLError: ('No cipher can be selected.',)
Using OsX (BigSur)
Hello,
I have 2FA enabled so I used your example to connect to degiro. However I get the following error using python 3.6.13:
DEBUG:trading.models.session_storage:session:getter: MainThread
DEBUG:trading.models.session_storage:session:getter: MainThread
Traceback (most recent call last):
File "main.py", line 30, in <module>
trading_api.connect()
File "/Users/user/.asdf/installs/python/3.6.13/lib/python3.6/site-packages/trading/api.py", line 59, in connect
connection_storage.session_id = basic.get_session_id()
File "/Users/user/.asdf/installs/python/3.6.13/lib/python3.6/site-packages/trading/basic.py", line 73, in get_session_id
logger=logger
File "/Users/user/.asdf/installs/python/3.6.13/lib/python3.6/site-packages/trading/utilities.py", line 126, in get_session_id
one_time_password = str(otp.get_totp(totp_secret_key))
File "/Users/user/.asdf/installs/python/3.6.13/lib/python3.6/site-packages/onetimepass/__init__.py", line 169, in get_totp
token_length=token_length,
File "/Users/user/.asdf/installs/python/3.6.13/lib/python3.6/site-packages/onetimepass/__init__.py", line 113, in get_hotp
key = base64.b32decode(secret, casefold=casefold)
File "/Users/user/.asdf/installs/python/3.6.13/lib/python3.6/base64.py", line 205, in b32decode
raise binascii.Error('Incorrect padding')
binascii.Error: Incorrect padding
hi!
I wanted to try out your library but I am a bit overwhelmed how to use it correctly. I would like to get some charting ID from a stock, for example for the AEX. I cant seem to find in the examples how to get the product id that belongs to a stock from a company defined by an isin. Could you provide an example for that? Thanks!
Hi,
is there a way how to get stock details (same as i could get via RequestLookup or RequestStocks) when i have just stocks id (for example (AMD id is 5462588).
Basically i have portfolio, i get it via
request_list = Update.RequestList()
request_list.values.extend(
[
Update.Request(
option=Update.Option.PORTFOLIO,
last_updated=0,
),
]
)
print (request_list)
update = trading_api.get_update(request_list=request_list, raw=False)
and i need to get vwid and other stock details to pass to quotecast.
documentation says
3. How to get a "vwd_id" ?
One way to get the "vwd_id" of a product : fetch details about that product using the "lookup" (search by name) feature of this library.
are there any other ways (i can't search by names since portfolio request doesn't provide any names).
Thanks
When the order confirmation fails (can be due to eg. tick size being wrong, connection with exchange down, maintenance window etc) the order confirmation fails scilently and returns none.
Changing the code below in action_confirm_order.py will instead return the error message in a dictionary (making it possible for example to get the correct tick size, if that's the cause of the error)
<original>
try:
response_raw = session.send(prepped, verify=False)
response_raw.raise_for_status()
response_dict = response_raw.json()
except Exception as e:
logger.fatal(response_raw)
logger.fatal(e)
return None
</original>
<modified>
try:
response_raw = session.send(prepped, verify=False)
response_dict = response_raw.json()
response_raw.raise_for_status()
except Exception as e:
logger.fatal(response_raw)
logger.fatal(e)
return response_dict
</modified>
Hi!
With request = Quotecast.Request() I get AttributeError: Request
Any suggestions?
Hi,
I can successfully log in and get config table via trading_api.get_config(). Returned data seems to be ok.
Since that nothing works as expected. For example:
favourites_list = trading_api.get_favourites_list()
results in:
DEBUG:urllib3.connectionpool:https://trader.degiro.nl:443 "GET /pa/secure/favourites/lists?intAccount=1536831&sessionId=384815D9922F04E8EB92614449202A7B.prod_b_113_2 HTTP/1.1" 404 None
CRITICAL:trading.basic:404
CRITICAL:trading.basic:{"errors":[{"text":"No corresponding resource found"}]}
CRITICAL:trading.basic:'data'
False
next:
request_list = Update.RequestList()
request_list.values.extend(
[
Update.Request(
option=Update.Option.TOTALPORTFOLIO,
last_updated=0,
),
]
)
print (request_list)
update = trading_api.get_update(request_list=request_list, raw=False)
update_dict = pb_handler.message_to_dict(message=update)
results in:
DEBUG:urllib3.connectionpool:https://trader.degiro.nl:443 "GET /trading/secure/v5/update/1535031;jsessionid=AEE095C89F409EE4569DCA2829EF16B1.prod_b_113_2?totalPortfolio=0&intAccount=1535031&sessionId=AEE095C89F409EE4569DCA2829EF16B1.prod_b_113_2 HTTP/1.1" 403 None
{'response_datetime': '2021-01-25T13:41:56.123899Z'}
Any ideas, thanks?
Is there an easy way to convert an ISIN to a Degiro product_id?
Hi, thanks for sharing your nice work.
This method ProductSearch.RequestStocks() returns 404.
This is the request url:
https://trader.degiro.nl/product_search/secure/v5/stocks?intAccount=0&sessionId=*****prod_b_127
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?
The stocks
endpoint in product_search
has an indexId
parameter that is optional. If I call the ProductSearch.RequestStocks
function without it:
request_stock = ProductSearch.RequestStocks(
isInUSGreenList=False,
stockCountryId=846,
offset=0,
limit=10,
requireTotal=True,
sortColumns='name',
sortTypes='asc',
)
A default value of 0
is asigned to it in the request:
/product_search/secure/v5/stocks?stockCountryId=846&limit=10&requireTotal=True&sortColumns=name&sortTypes=asc&isInUSGreenList=False&indexId=0&searchText=&offset=0&intAccount=xxx&sessionId=xxx
And the API returns this error:
{"errors":[{"text":"No corresponding model found"}]}
I'm new to Python and never used Google Protocol Buffers (which is what it seems you are using) so may be I'm doing something wrong. I tried modifying the trading/pb/trading_pb2.py
file _PRODUCTSEARCH_REQUESTSTOCKS
descriptor to no avail.
I've also seen that the pb files are generated from a file called trading/pb/trading.proto
that is not there. Should I need it if I wanted to change the descriptors?
Hi guys, beautiful work!! thank you very much for making it open.
Would it be actually possible to access the news api? or is there any limitation?
Best regards,
Ivan
The README does contain a example how to get chart data.
But doesn't mention what types of series data there are.
Or for that matter what the number 360148977
means. ( Probably the product ID )
Or how to decode the integer timestamps. (
I took a guess how it works. Take the 'times' timestamp convert it to a integer and use it as a offset.
from datetime import datetime
date = chart['series'][1]['times'][:-5] # contains '2020-03-13T00:00:00/PT1S'
offset = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S")
data_point = chart['series'][1]['data'] # contains: [32400, 6.9] 1st is the timestamp, 2nd the data, which is the price in this case.
timestamp = data_point[0]
corrected_timestamp = offset.timestamp() + timestamp * 1 # you multiply the timestamp with the resolution converted to seconds.
# In case you used PT15S multiply by 15, PT5M is 5 min converted to seconds is 300, so multiply the timestamp by 300 .
datetime.fromtimestamp(corrected_timestamp)
Hello,
I didn't manage to get the error message when an order can not be confirmed.
Error message contains important information like :
Thank you very much
Ben
First of all, great job! As Degiro supports Trailing Stop Loss and I do not find in the documentation, do you support this as well?
hi @Chavithra per your request issue instead of discord.
I am trying out the library and am confused by the following. I would like to get a list of all tradable stocks from USA by exchange.
I am trying the following loop:
# get all USA stocks in green list
index = 0
products = []
while True:
print(index)
r = ProductSearch.RequestStocks(
stock_country_id=846, #USA
index_id=index,
offset=0,
is_in_us_green_list=True,
limit=100,
require_total=True,
sort_columns="name",
sort_types="asc",
)
res = message_to_dict(trading_api.product_search(request=r, raw=False))
if len(res['products']) == 0:
break
else:
index += 1
products += res['products']
print(len(res['products']))
however this does not give me all stocks that I can see from the UI.
I am confused by the index_id and offset parameters. I tried both and for both had a confusing result that it didnt give me a lot of the stocks that I saw on the UI. Could you perhaps give details what the difference between those two is and how I can fix my code? Thanks in advance!
Hi!
Thanks for the great work with the Degiro API wrapper.
I was just wondering if there is a way to operate with tickers (e.g. 'TSLA' for Testa or 'AAPL' for Apple). Mostly in trading we operate with the tickers and e.g. if I want to fetch history data from Yahoo Finance API or extract a list of potential stocks to trade from Finviz API I have to use tickers. Tickers are also unique (at least on country level) and very practical to operate with. Probably you know all this already :). Anyway, it would be very useful to have a function to extract the stock Degiro id for a stock for a specific ticker.
I don't know if I have missed something but I could not find a simple way to do this.
When looking for options of Shell (GB00B03MLX29) with exchange Id 1, it returns nothing but the metrics (seconds/nanos).
This is the link: https://trader.degiro.nl/trader/#/products/81642/options?exchange=1&strikeType=-1&underlying=GB00B03MLX29&optionType=-1&month=-1&year=-1&sortColumns=expirationDate%2Cstrike&sortTypes=asc%2Casc
request = ProductSearch.RequestOptions(
inputAggregateTypes='',
inputAggregateValues='',
optionExchangeId=1,
underlyingIsin='GB00B03MLX29',
searchText='',
offset=0,
limit=100,
requireTotal=True,
sortColumns='name',
sortTypes='asc',
)
# FETCH DATA
option_list = trading_api.product_search(request=request)
The create order docu shows that the response on check_order()
has 6 parameters.
I did see all of them in the past, but recently it only returns:
confirmation_id
response_datetime
This behaviour is observed on both NASDAQ and Euronext Amsterdam.
I tried sending orders, and everything worked fine. Stocks, ETF's, buying and selling, great.
But there's one product which fails for me. The order isn't refused, it just gives no confirmation. It gives this debug text:
CRITICAL:degiro_connector.trading.actions.action_check_order:<Response [404]>
CRITICAL:degiro_connector.trading.actions.action_check_order:404 Client Error: Not Found for url: https://trader.degiro.nl/trading/secure/v5/checkOrder;jsessionid=51F9CB97CE11034CB87584687127AD90.prod_b_127_2?intAccount=[_hiddenintnr_]&sessionId=51F9CB97CE11034CB87584687127AD90.prod_b_127_2
order is:
price: 134.0
product_id: 600015811
size: 25.0
time_type: GOOD_TILL_CANCELED
I've tried with adjusting the price and the size, but nothing worked.
This is the error message:
AttributeError Traceback (most recent call last)
/var/folders/nx/0zjw32n90612p_zrm4ln3rxw0000gn/T/ipykernel_30912/3981454778.py in
52 print (checking_response)
53 # EXTRACT CONFIRMATION_ID
---> 54 confirmation_id = checking_response.confirmation_id
55
56 # EXTRACT OTHER DATA
AttributeError: 'NoneType' object has no attribute 'confirmation_id'
I tried to use a work around. I entered an order in this product manually in the app. That works as usual. Then I tried to change the order with the Order Update. But unfortunately, no luck. Received the same CRITICAL debug text.
Probably a stupid question... but how do I find my user token to login? Thanks.
package version: 2.0.11
file: action_confirm_order.py
line: 148
seems already fixed in main, but there's no update with the new changes on pypi
Hey guys, I am wondering what the probability of detection is when you use realtime_poller in a loop? There are cases that DG detects certain automatic operations and gives warnings. Does anyone know if there is protection in the code of the package; random seconds api calls or something like that? Furthermore, love this package guys!
Thanks for this great API-module.
Is it possible to find out on which exchange a stock is listed? Because when I have a stock (id, name or symbol via product search) I would like to know if the stock is available on the NYSE or the NASDAQ Stock Exchange.
Thank you for an answer :)
Hi
request.subscriptions['AAPL.BATS,E'].extend([
'LastDate',
'LastTime',
'LastPrice',
'LastVolume',
'LastPrice',
'AskPrice',
'BidPrice',
])
Do you know what ",E" stands for and how would a subscription look like for a realtime stock Bayer Xetra market item (realtime data purchased within the account)?
Many thanks!
Within the portfolio I can retrieve the close price from stocks ('closePrice' in the portfolio df).
But from the quotecast part, I can't find the ClosePrice data. But I have the feeling it must be there, somehow? If I add ClosePrice to the quotecast, it gives no error. But also returns no data.
Hi! I'm an accountant building dashboards in Power BI and was able to use the connector to fetch data from DeGiro into Power BI. Great work (especially considering I don't know any Python) !
I'm using different DeGiro accounts to get data from, but somehow for one account I keep getting a' KeyError: "intAccount" when trying the fetch the client_details table. When I use the same lines with different credentials it works just fine. Any idea what might cause this issue?
Some additional info: I use the expample "client_details_table.py" to get the details. It runs fine for all accounts but one. When I only extract "Client_details_pretty" for the faulty account it works just fine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.