lolokraus / DegiroAPI

An unofficial API for the trading platform Degiro, with the ability to get real time data and historical data
MIT License
215 stars 86 forks source link

Add exchange rates as convenience methods #15

Open melvinroest opened 3 years ago

melvinroest commented 3 years ago

https://trader.degiro.nl/trader/#/products/705366/overview is the EUR/USD exchange rate. You can find this quite easily via the main menu.

I made a convenience method as follows:

def get_euro_dollar():
    return degiro.real_time_price(705366, degiroapi.Interval.Type.One_Day)[0]['data']['lastPrice']

Is it an idea to add something like this to the codebase for multiple currencies?

blunderedbishop commented 3 years ago

I can try to do this. What would you like to see added besides the real time quote?

Most of the time you can use the search_products method searching for the desired rate (e.g. 'EUR/GBP') to get the info you want. Sometimes it appears as a second result (e.g. 'EUR/USD'), so in this case use set the limit parameter to 2. Beware that the price that is returned through the search_products method is the last day's closing price, not the real time one.