An unofficial python API for trading on the DeGiro platform, with the ability to get real time data and historical data.

Overview

DegiroAPI

An unofficial API for the trading platform Degiro written in Python with the ability to get real time data and historical data for products.

DEPRECATED!

The package degiro-connector contains the same and much more functionality. It is also maintained well. Hence, the decision to deprecate this repository.

Credits

This project is a fork from DegiroAPI by lolokrauz. It was not actively maintained anymore, hence the creation of this repository.

Added changes

Over the original repository the following things were added:

  • Pre-commit hooks.
  • Style and type checking.
  • Dependencies handled by the setup instead of the user.
  • Typing information all over the code.
  • Removed logic from __init__.
  • Renaming of function, parameters and variables to adhere to pythons snake_case.

Getting Started

Installing

pip install degiroapi

Logging in

frmo degiroapi.degiro import DeGiro
degiro = DeGiro()
degiro.login("username", "password")

Logging out

degiro.logout()

Available Functions

  • login
  • logout
  • get_data
  • search_products
  • product_info
  • transactions
  • orders
  • delete_order
  • real_time_price
  • get_stock_list
  • buy_order
  • sell_order

get_data

Printing your current cash funds:

from degiroapi.data_type import DataType
cashfunds = degiro.get_data(DataType.CASHFUNDS)
for data in cashfunds:
    print(data)

Printing your current portfolio, argument True to filter out products with a size of 0, False or no Argument to show all:

from degiroapi.data_type import DataType
portfolio = degiro.get_data(DataType.PORTFOLIO, True)
for data in portfolio:
    print(data)

search_products

Searching for a product:

products = degiro.search_products('Pfizer')
print(Product(products[0]).id)

product_info

Printing info for a specified product ID:

info = degiro.product_info(331823)
print(info["id"], info["name"], info["currency"], info["closePrice"])

transactions

Printing your transactions in a given time interval:

from datetime import datetime, timedelta

transactions = degiro.transactions(datetime(2019, 1, 1), datetime.now())
print(pretty_json(transactions))

orders

Printing your order history(the maximum timespan is 90 days) With argument True, this function only returns open orders

from datetime import datetime, timedelta

orders = degiro.orders(datetime.now() - timedelta(days=90), datetime.now())
print(pretty_json(orders))

orders = degiro.orders(datetime.now() - timedelta(days=90), datetime.now(), True)
print(pretty_json(orders))

delete_order

Deleting an open order with the orderId

orders = degiro.orders(datetime.now() - timedelta(days=1), datetime.now(), True)
degiro.delete_order(orders[0]['orderId'])
degiro.delete_order("f278d56f-eaa0-4dc7-b067-45c6b4b3d74f")

real_time_price

Get the real time price and the historical data of a stock:

from degiro.interval_type import IntervalType

products = degiro.search_products('nrz')
# Interval can be set to One_Day, One_Week, One_Month, Three_Months, Six_Months, One_Year, Three_Years, Five_Years, Max
realprice = degiro.real_time_price(Product(products[0]).id, IntervalType.One_Day)

# getting the real time price
print(realprice[0]['data']['lastPrice'])
print(pretty_json(realprice[0]['data']))

# getting historical data
print(realprice[1]['data'])

get_stock_list

Get the symbols of the S&P500 stocks:

sp5symbols = []
products = degiro.get_stock_list(14, 846)
for product in products:
    sp5symbols.append(Product(product).symbol)

Get the symbols of the german30 stocks:

daxsymbols = []
products = degiro.get_stock_list(6, 906)
for product in products:
    daxsymbols.append(Product(product).symbol)

buy_order

Placing a buy order is dependent on the order Type:

Limit order

You have to set a limit order price to which the order gets executed. arguments: order type, product id, execution time type (either 1 for "valid on a daily basis", or 3 for unlimited, size, limit(the limit price)

from degiroapi.order_type import OrderType
degiro.buy_order(OrderType.LIMIT, Product(products[0]).id, 3, 1, 30)

StopLimit order

Sets a limit order when the stoploss price is reached (not bought for more than the limit at the stop loss price): arguments: order type, product id, execution time type (either 1 for "valid on a daily basis", or 3 for "unlimited"), size, limit(the limit price), stop_loss(stop loss price)

from degiroapi.order_type import OrderType
degiro.buy_order(OrderType.STOPLIMIT, Product(products[0]).id, 3, 1, 38, 38)

Market order

Bought at the market price: arguments: order type, product id, execution time type (either 1 for "valid on a daily basis", or 3 for "unlimited"), size

from degiroapi.order_type import OrderType
degiro.buy_order(OrderType.MARKET, Product(products[0]).id, 3, 1)

StopLoss order

The stop loss price has to be higher than the current price, when current price reaches the stoploss price the order is placed: arguments: order type, product id, execution time type (either 1 for "valid on a daily basis", or 3 for "unlimited"), size

from degiroapi.order_type import OrderType
degiro.buy_order(OrderType.STOPLOSS, Product(products[0]).id, 3, 1, None, 38)

sell_order

Placing a sell order is dependent on the order Type: Equivalent to the buy orders:

from degiroapi.order_type import OrderType
degiro.sell_order(OrderType.LIMIT, Product(products[0]).id, 3, 1, 40)
from degiroapi.order_type import OrderType
degiro.sell_order(OrderType.STOPLIMIT, Product(products[0]).id, 3, 1, 37, 38)
from degiroapi.order_type import OrderType
degiro.sell_order(OrderType.MARKET, Product(products[0]).id, 3, 1)
from degiroapi.order_type import OrderType
degiro.sell_order(OrderType.STOPLOSS, Product(products[0]).id, 3, 1, None, 38)

Usage

For documented examples see examples.py

Contributing

How great this project will turn out to be, totally depends on you. If you think you have a great addition, please create a PR :). If you are unfamilar with pull requests, please take a look here.

Requirements

In order for your commit to be accepted, please install pre-commit. This will run a couple of tools to make sure the formatting of the code is good and there are no obvious mistakes.

Installing pre-commit

pre-commit install

Now everytime you will commit, it will automatically run the pre-commit hooks. If you are using Pycharm, the errors appear in git(left bottom) -> console.

You might also like...
OnTime is a small python that you set a time and on that time, app will send you notification and also play an alarm.

OnTime Always be OnTime! What is OnTime? OnTime is a small python that you set a time and on that time, app will send you notification and also play a

Stocks Trading News Alert Using Python

Stocks-Trading-News-Alert-Using-Python Ever Thought of Buying Shares of your Dream Company, When their stock price got down? But It is not possible to

Simple Python API for the Ergo Platform Explorer
Simple Python API for the Ergo Platform Explorer

Ergo is a "Resilient Platform for Contractual Money." It is designed to be a platform for applications with the main focus to provide an efficient, se

Graphene Metanode is a locally hosted node for one account and several trading pairs, which uses minimal RAM resources.

Graphene Metanode is a locally hosted node for one account and several trading pairs, which uses minimal RAM resources. It provides the necessary user stream data and order book data for trading in a format one would expect from a centralized exchange API.

A pairs trade is a market neutral trading strategy enabling traders to profit from virtually any market conditions.

A pairs trade is a market neutral trading strategy enabling traders to profit from virtually any market conditions. This strategy is categorized as a statistical arbitrage and convergence trading strategy.

Senator Stock Trading Tester

Senator Stock Trading Tester Program to compare stock performance of Senator's transactions vs when the sale is disclosed. Using to find if tracking S

Unofficial Python Library to communicate with SESAME 3 series products from CANDY HOUSE, Inc.

pysesame3 Unofficial Python Library to communicate with SESAME 3 series products from CANDY HOUSE, Inc. This project aims to control SESAME 3 series d

Unofficial Python implementation of the DNMF overlapping community detection algorithm

DNMF Unofficial Python implementation of the Discrete Non-negative Matrix Factorization (DNMF) overlapping community detection algorithm Paper Ye, Fan

Unofficial Valorant documentation and tools for third party developers

Valorant Third Party Toolkit This repository contains unofficial Valorant documentation and tools for third party developers. Our goal is to centraliz

Comments
  • Could not login since this week. Does everybody experience this problem?

    Could not login since this week. Does everybody experience this problem?

    You are not supposed to be here Reference: 01c39b5b6e8855f9a109602b826b8a89 Remote IP: 164.90.200.176 Identifier: 69f25a1512df4531acb32e9e6e22f3cd=python_bot Date: 11/Dec/2022:18:54:46 +0100

    opened by uptodata 0
  • Could not login

    Could not login

    While executing degiro.login():

    Exception: Could not login. Response: ...

    You are not supposed to be here

    Reference: 56a89c89a5fbe8faf38d15fbd1283c11

    Remote IP: 88.149.xxx.xxx

    Identifier: 69f25a1512df4531acb32e9e6e22f3cd=python_bot

    Date: 10/Dec/2022:12:45:47 +0100

    opened by TriposDev 0
  • real_time_price ValueError: invalid literal for int() with base 10

    real_time_price ValueError: invalid literal for int() with base 10

    The command 'real_time_price' most of the times complete the gathering of data, but sometimes comes out the this error:

    Traceback (most recent call last):

    File "C:\Users\840653\Anaconda3\lib\site-packages\degiroapi_init_.py", line 224, in real_time_price int(tmp)

    ValueError: invalid literal for int() with base 10: 'US6806652052.TRADE,E'

    If I run it again, it works and then fails with a different product id.

    opened by paulomiguelfferreira 1
  • Releases(0.1.0)
    • 0.1.0(Sep 14, 2021)

    • v0.0.5(Sep 12, 2021)

    • v0.0.4(Sep 12, 2021)

    • v0.0.3(Sep 12, 2021)

    • v0.0.2(Sep 12, 2021)

    • v0.0.1(Sep 12, 2021)

      This is a project that was based on https://github.com/lolokraus/DegiroAPI. It still contains 90% the same code.

      Changelog:

      • Add requests as dependency in setup.py. This prevents the need for users to install it themselves.
      • Add typing information.
      • Add some pre-commit hooks.
      • Add logging in with 2FA (thanks @pforero)
      • Add modify_order (thanks @adamchabin)
      • Add get account overview (thanks @pforero)
      • Add common exchange rates (thanks @blunderedbishop)
      • Add list of dividends that will be paid (thanks @Jakub-CZ)
      • Add session usage (thanks @eugep)
      • Add support for missing close price in product (thanks @Jakub-CZ)
      • Formatted readme (thanks @ahmedhamedaly)
      • Add support for multiple vwd keys (thanks @hjortlund)
      Source code(tar.gz)
      Source code(zip)
    Owner
    Jorrick Sleijster
    Data Engineer @Adyen
    Jorrick Sleijster
    Basic code and description for GoBigger challenge 2021.

    GoBigger Challenge 2021 en / 中文 Challenge Description 2021.11.13 We are holding a competition —— Go-Bigger: Multi-Agent Decision Intelligence Challeng

    OpenDILab 183 Dec 29, 2022
    Python Cheat Sheet

    Introduction Pysheeet was created with intention of collecting python code snippets for reducing coding hours and making life easier and faster. Any c

    CHANG-NING TSAI 7.5k Dec 30, 2022
    Force you (or your user) annotate Python function type hints.

    Must-typing Force you (or your user) annotate function type hints. Notice: It's more like a joke, use it carefully. If you call must_typing in your mo

    Konge 13 Feb 19, 2022
    An universal linux port of deezer, supporting both Flatpak and AppImage

    Deezer for linux This repo is an UNOFFICIAL linux port of the official windows-only Deezer app. Being based on the windows app, it allows downloading

    Aurélien Hamy 154 Jan 06, 2023
    Subscribe, listen and (in the future) download your favorite podcasts, quickly and easily.

    Minimal Podcasts Player https://github.com/son-link/minimal-podcasts-player Subscribe, listen and (in the future) download your favorite podcasts, qui

    Alfonso Saavedra 14 Nov 11, 2022
    An optional component handler for hikari, inspired by discord.py's views.

    hikari-miru An optional component handler for hikari, inspired by discord.py's views.

    43 Dec 26, 2022
    Generates Windows 95 and 95 OEM keys using the modulus 7 check algorithm

    w95keygen-python windowskeygen.py - Generates Windows 95 and 95 OEM keys using the modulus 7 check algorithm Just download and drop in the directory y

    Joshua Alto 1 Dec 06, 2021
    SHF TEST BACKEND

    ➰ SHF TEST BACKEND ➿ 🐙 Goals Dada una matriz de números enteros. Obtenga el elemento máximo en la matriz que produce la suma más pequeña al agregar t

    Wilmer Rodríguez S 1 Dec 19, 2021
    Transform your boring distro into a hacking powerhouse.

    Pentizer Transform your boring distro into a hacking powerhouse. Pentizer is a personal project that imports Kali and Parrot repositories in any Debia

    Michail Tsimpliarakis 2 Nov 05, 2021
    It is Keqin Wang first project in CMU, trying to use DRL(PPO) to control a 5-dof manipulator to draw line in space.

    5dof-robot-writing this project aim to use PPO control a 5 dof manipulator to draw lines in 3d space. Introduction to the files the pybullet environme

    Keqin Wang 4 Aug 22, 2022
    Blender 3.1 Alpha (and later) PLY importer that correctly loads point clouds (and all PLY models as point clouds)

    import-ply-as-verts Blender 3.1 Alpha (and later) PLY importer that correctly loads point clouds (and all PLY models as point clouds) Latest News Mand

    Michael Prostka 82 Dec 20, 2022
    👀 nothing to see here

    Woofy Woofy is blue dog companion token of YFI (Wifey) It utilizes a special Woof bonding curve which allows two-way conversion between the tokens. Th

    Yearn Finance 36 Mar 14, 2022
    奇遇淘客服务器端

    奇遇淘客 APP 服务器端 警告 正在使用 v0.2.0 版本的用户,请尽快升级到 v0.2.1。 v0.2.0 版本的 Docker 镜像中包含了有问题的 aiohttp。 奇遇淘客代码库 奇遇淘客 iOS APP 奇遇淘客 Android APP 奇遇淘客文档 服务器端文档 Docker 使用

    奇遇科技 92 Nov 09, 2022
    My Solutions to 120 commonly asked data science interview questions.

    Data_Science_Interview_Questions Introduction 👋 Here are the answers to 120 Data Science Interview Questions The above answer some is modified based

    Milaan Parmar / Милан пармар / _米兰 帕尔马 181 Dec 31, 2022
    Scripts used in the RayStation medical radiation dosimetry treatment planning system

    Med Phys Scripts These are scripts that I, the medical physics assistant at Cookeville Regional Medical Center, wrote for use in our radiation therapy

    Kaley White 2 Oct 19, 2022
    Parser for the GeoSuite[tm] PRV export format

    Parser for the GeoSuite[tm] PRV export format This library provides functionality to parse geotechnical investigation data in .prv files generated by

    EMerald Geomodelling 1 Dec 17, 2021
    A compilation of useful scripts to automate common tasks

    Scripts-To-Automate-This A compilation of useful scripts for common tasks Name What it does Type Add file extensions Adds ".png" to a list of file nam

    0 Nov 05, 2021
    BloodCheck enables Red and Blue Teams to manage multiple Neo4j databases and run Cypher queries against a BloodHound dataset.

    BloodCheck BloodCheck enables Red and Blue Teams to manage multiple Neo4j databases and run Cypher queries against a BloodHound dataset. Installation

    Mr B0b 16 Nov 05, 2021
    Python script for the radio in the Junior float.

    hoco radio 2021 Python script for the radio in the Junior float. Populate the ./music directory with 2 or more .wav files and run radio2.py. On the Ra

    Kevin Yu 2 Jan 18, 2022
    Node editor view image node

    A Blender addon to quickly view images from image nodes in Blender's image viewer.

    5 Nov 27, 2022