Git Product home page Git Product logo

degiro's Introduction

Update 🦥

As you have probably noticed, this repo is not maintained anymore.

For a worthy alternative, please have a look at degiro-connector

Unofficial DeGIRO Python API

Very basic unofficial Python API for DeGiro. This API is only able to get details about your portfolio. It cannot be used for automatic trading. For a way more extensive Node.js API have a look at pladarias work.

⚠️ DeGiro could change their API at any moment, if something is not working, please open an issue.

Security

Your password is stored plain text in a JSON file. Take adequate measures !, e.g. chmod it to 600. The API also won't work for users who have 2FA enabled.

Example usage

from degiro import degiro

la = degiro()
la.login('config.json')
la.getConfig()
pfs = la.getPortfolioSummary()
portfolio = la.getPortfolio()
total = pfs['equity']

# Prints a pretty table of your equities and their allocation.
print('{:<20}\tsize\tvalue\tsubtot\t\talloc'.format('Product'))
for row in portfolio['PRODUCT'].values():
    subtot = row['size']*row['price']
    alloc = (subtot/total)*100 # Asset allocation (%)
    print('{:<20}\t{:5.1f}\t{:6.2f}\t{:7.2f}\t\t{:2.1f}%'.format(row['name'], row['size'], row['price'], subtot, alloc))
print('Total: {:.2f}'.format(total))

degiro's People

Contributors

bramton avatar felixbenning avatar lbaligand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

degiro's Issues

product instead of id

Hi
would it be possible to provide the product (having a understandable name) rather than the strage id values?

Regards, Armin

Unused local variable header in login()

At line 21, you have the instruction :

header={'content-type': 'application/json'}

But this variable is never used.

You then have the instruction:

r = self.sess.post(url, data=json.dumps(payload))

Shouldn't it be :

r = self.sess.post(url, headers=header, data=json.dumps(payload))

Or something like that ?

Create Order

Hello bramton,

Thank you for starting and sharing this module, very nice of you!
I'd like to help you to extend it if you are open to it.

Mainly, I'd like to have the option to create orders similarly to the node.js version.
I would also create the necessary files for a pip module: http://python-packaging.readthedocs.io/en/latest/minimal.html
This would require moving the files around a bit. Would you be open to maintain the module in the official repo? It would be much easier for the users to use the module.
I noticed that the function names are not PEP compatible: https://www.python.org/dev/peps/pep-0008/#function-and-variable-names ideally, they should be renamed.
My plan is to do these changes in the following days/weeks, if you are open to it we can collaborate.

V

Degiro api test will error in Eclipse IDE on Mac

Hello Bramton, i'm interested in getting your degiro python example working. However when running the code in Eclipse on a Mac i get the following error.

Traceback (most recent call last):
File "/Users/me/eclipse-workspace/degiro1/src/test_degiro.py", line 4, in
la.login('config.json')
File "/Users/me/eclipse-workspace/degiro1/src/degiro.py", line 23, in login
self.sessid = r.headers['Set-Cookie']
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/structures.py", line 54, in getitem
return self._store[key.lower()][1]
KeyError: 'set-cookie'

i tried searching online but no google results on the keyerror: 'set-cookie'.

do you know what should be done to fix the issue?

thanks for your help,
best regards,
Manolito

Negative portfolio value gives error

I have a portfolio with a negative position value. It appears the code can't handle it :
JSONDecodeError: Expecting value

My accounts with positive portfolio value work flawless.
(you can get a total negative portfolio value with option positions - it's not a loss making account)

LICENSE?

What is the license of this code?

Install on Anaconda

Hello there,

I am new to python. How can I install the module under Anaconda? Is there some kind of tutorials that explains it?

Greetings

Transaction history

It appears that the requests sent in order to retrieve the transaction history is
https://trader.degiro.nl/reporting/secure/v4/transactions?fromDate=01%2F01%2F2018&toDate=18%2F11%2F2019&groupTransactionsByOrder=false&intAccount=[Redacted]&sessionId=[Redacted]

Maybe this request could sometimes be included. It also appears to retrieve only productids and not names. So it might be nice to add the ticker in order to match it with data from other sources.

Also: apparently degiro still uses v4 requests sometimes.

Login Error 503; header adjusted.

Hi, first of all thanks for this useful code, I use it for daily reporting of my portfolio.
However, the Api calls no longer worked for me since 6-12-2022; got an error 503 when logging in; possibly some adjustments at DeGiro.
After some digging and comparing with other projects, it now works again for me by adjusting the header in the calls. The header I'm using now is: header = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', ' content-type': 'application/json', 'Accept':'application/json'}
Partly copied from another project (Lanrutcon/DegiroAPI). I'm definitely not an expert and don't know details or cause, but it works for me again.
I thought it would be useful to report here.
Good luck.

login error

Hi, thanks for sharing this API!
I'm a total tech newbie and have no experience with integrating API's, but I figured I wanted to try this one out.
So after running the code, I get stuck at login. It says status code: 405.
The code stops running at the set cookie line.

What does this mean and how do I fix it?

How do intercept /update calls and the likes ?

Hi,

I hope you don't mind I use this issue to ask information.

When I check my browser network console, I don't see calls such as https://trader.degiro.nl/trading/secure/v5/update/. How do you know about them ?

Thanks

Issue while running the script

Hey Bram,

I reinstalled a computer and now wanted to add my "log degiro portfolio"-cronjob again.
However, after installing python and requests, I get the following when running:

<Response [200]>
Account id: whatever
Get data
Status code: 401
Traceback (most recent call last):
File "test.py", line 7, in
pfs = la.getPortfolioSummary()
File "/home/osmc/python/pyscripts/degiro.py", line 88, in getPortfolioSummary
pf = self.getPortfolio()
File "/home/osmc/python/pyscripts/degiro.py", line 102, in getPortfolio
self.getData()
File "/home/osmc/python/pyscripts/degiro.py", line 68, in getData
self.data = r.json()
File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.5/json/init.py", line 319, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


Any pointers? Cheers :)

Enabling module import

So I tried to figure out how to actually import a module from github instead of simply copying the files into my project
https://stackoverflow.com/questions/19943022/import-a-python-library-from-github

And this stackoverflow suggestions fails, apparently because there is no setup.py script. I am not 100% sure what a setup.py script is. But I think it basically describes the dependencies of the python module and allows pip to deal with it.

This might also be useful:
https://setuptools.readthedocs.io/en/latest/setuptools.html

I want to get other things done first, but if I finish with these other things in my project I could also have a look at this.

After successfully logging in, Could not get client info.

File ~/miniconda3/lib/python3.10/site-packages/degiroapi/init.py:95, in DeGiro.__request(url, cookie, payload, headers, data, post_params, request_type, error_message)
93 return "No data"
94 else:
---> 95 raise Exception(f'{error_message} Response: {response.text}')

Exception: Could not get client info. Response:

SyntaxError: invalid syntax (Python 2.7.12)

Not working:

root@home:/tmp# python a.py
Traceback (most recent call last):
File "a.py", line 1, in
from degiro import degiro
File "/tmp/degiro.py", line 12
def login(self, conf_path=None, with2fa:bool=False):
^
SyntaxError: invalid syntax

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.