Giter Club home page Giter Club logo

degiro-api's Introduction

Hi there ๐Ÿ‘‹

degiro-api's People

Contributors

danielvandenberg95 avatar dennissnijder avatar dependabot[bot] avatar icastillejogomez avatar magnific0 avatar stef-halmans 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  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  avatar  avatar

degiro-api's Issues

[Idea/Question] Support "updating" order

Of course delete + create would do the trick. But would it be possible to update an existing order ?
Also, what means execute vs create order in your main readme examples ?

Real time degiro data

Hey hey,
This isn't an issue but a question.
First of all thanks for the great api!

I was wondering if there are any plans to include the real time price updates in this api.
I want to get realtime updates for my positions, including options on the Amsterdam exchange, which a lot of data providers don't have.

I was looking to implement this myself, but I don't even see a websocket or anything the degiro app is fetching data from.
There is no open websocket, no service worker data, nothing.

Do you have any idea how to reverse engineer this?

Docs question: can you elaborate a bit more about sessions and OTP?

Hi,

I love this project!
Can you elaborate a bit more about the sessionID? Is it just a token that I should store in nodejs memory or whatever for every person that wants to authenticate? So:

  • Session id is user bound?
  • Why do you get this session ID from env variable (this will never be an env variable right? Because it is session based)

Questions about OTP:

  • The OTP normally is valid for a few seconds. How do you deal with that when relogin? I dont want to have the user to enter the info every time.

Feature: prices

I need to be able to get prices, so I figured I'd make an issue with my findings. I'm hoping to be able to submit a PR in a couple days, but if not I'll have all the information I've found documented here.

The URL DEGIRO requests it's data from (on page load) is https://charting.vwdservices.com/hchart/v1/deGiro/data.js?requestid=1&resolution=PT1M&culture=nl-NL&period=P1D&series=issueid%3A198401&series=price%3Aissueid%3A198401&format=json&callback=vwd.hchart.seriesRequestManager.sync_response&userToken=${usertoken}&tz=Europe%2FAmsterdam.

I redacted the user token for now, as I'm not sure if this one is personal or if it's the "user token" for DEGIO at vwdservices. It's a 7-digit number, ending with 821. If someone else runs into this issue, could you let me know if it's the same for you? Then we know it's common to everyone and not variable.

This is a get-request, so all required information is in this URL. I'm assuming there is no cookies involved, as the data is loaded from a 3rd party service.

The two "series" arguments are issueid:${product.vwdId} and price:issueid:${product.vwdId}. Although I'm not certain both are required for our (initial) use-case, I'd recommend leaving both in to make the request indistinguishable from what DEGIRO does.

What's interesting though, is that for this request, it doesn't seem like you have to be logged in. This means easier unit testing, also in CI.

To-Do:

  • Figure out where "user token" comes from, and if you need to be logged in for this. If someone can help me with this that'd be great! Just hit F12, load a product page, and find the request under network. If your user token also ends with 821, we know it can be hard-coded in.

My suggestions for implementing this:

  • Add enums for "resolution" and for "period".
  • Add a function "getPrices(resolution, period, vwdId, culture, timezone)" which performs the GET request. Optionally also need to pass the "user token".
  • Add a test that uses a hard-coded vwdId to retrieve the price data.

Notes:
Callback should be omitted, as that will wrap the result in a function call (to be used with eval). Omitting it returns the raw JSON response.

Looking for maintainers to help me keeping update this project

Hello everyone,

I need to know if is still there any interest in this library in order to refactor it from the base and be able all of use to use it over the years. When I started this a few years ago, I didn't do the base as I should have making the code difficult to maintain. Now, we have the opportunity to refactor the library to provide a better development experience.

If you are open to help me with it please let me know in this issue to coordinate the short-term and mid-term roadmap.

SyntaxError: Cannot use import statement outside a module

I tried this but i'm stumbled with this error

`$ node get-portfolio.js
C:\Garage\Scripting\node\degiro-api_module\get-portfolio.js:1
import DeGiro, { DeGiroEnums, DeGiroTypes } from 'degiro-api'
^^^^^^

SyntaxError: Cannot use import statement outside a module
?[90m at wrapSafe (internal/modules/cjs/loader.js:1072:16)?[39m
`
I installed it as described in your page and i see that it is installed in my setup

$ npm -g ls C:\Users\arso271062\AppData\Roaming\npm -- [email protected]
+-- [email protected]
-- [email protected]

my get-portfolio.js contains the source from your site:
`import DeGiro, { DeGiroEnums, DeGiroTypes } from 'degiro-api'
const { PORTFOLIO_POSITIONS_TYPE_ENUM } = DeGiroEnums

(async () => {

const degiro: DeGiro = new DeGiro({
username: 'my username',
pwd: 'password',
})

await degiro.login()

const portfolio = await degiro.getPortfolio({ type: PORTFOLIO_POSITIONS_TYPE_ENUM.ALL })
console.log(JSON.stringify(portfolio, null, 2))
})()`

Please help me what i'm wrong. I'm from Perl bash background and the node enviroment is quite new for me. perhaps I'm using it wrong. I have the git bash for windows environment.

How to get maximum order size

For some securities there is a maximum order size allowed by degiro, it returns an error via check checkOrder like so:

The maximum quantity for market orders on this product is 68. To place an order with a higher quantity, please use the limit order.

Of course I could use a limit order but this is quite annoying, is there a way to figure out the maximum order size somehow?

Problems using import

Hi,

I just got started with DeGiro and this package... and I'm having some problems when using import:

If I try this code:

import DeGiro from "degiro-api";

const username = 'myUsername';
const password = 'myPassword';

const degiro = new DeGiro({ username, password });

I just got the following error:

TypeError: DeGiro is not a constructor

If I opt to use the create function, like this:

const degiro = DeGiro.create({username, password});

I got this error:

TypeError: DeGiro.create is not a function

I've tried the same code using Node 16.x and 18.x, any idea of what can be the problem?

Thanks for your work!

Take profit : how ?

Hello,

If I want to close one of my orders (and so take profit), what should I do in the order param ?
Should I make a Sell Order with "Stop Loss" without indicate the order id ?
And, if I want to sell 50% of my position ?

I don't want a "short order"....

Thanks

How to retrieve current size/value of CASH data in PORTFOLIO

First of all: Thanks @icastillejogomez for the API, very useful!

--

Hi all

when retrieving the CASH account data as rows in the PORTFOLIO dataframe like


request_list.values.extend(
    [
        Update.Request(option=Update.Option.PORTFOLIO, last_updated=0),
    ]
)

the API seems to return the Cash Account Data from the last cash transfer to the FLATEX account, not the actual value of the Cash Account (i.e. US Dollar, "size" parameter), neither in the baseCurrency nor in the FXCurrency (i.e. EUR, "value" parameter).

The Cash Account (size) could have changed in the meantime because of buy/sell activities, the baseCurrency Value (value) because of changes in the exchange rate. Now, i was wondering if there is a way to retrieve the actual values for both, size and value, or at least the changes since the last transfer to the FLATEX account - i was searching the API doc but was not able to find related information. Maybe someone could give me a hint?

Thanks a lot!

Uncaught Exception: badCredentials

I'm trying to use the api (thank you) and I'm always getting an uncaught exception.

const degiro = new DeGiro.default.create({
username: args[0],
pwd: args[1],
oneTimePassword: args[2]
})
const accountData = await degiro.login()

I've verified the arguments multiple times. Is there something I'm doing wrong?

Output with debug on:

node:internal/process/esm_loader:34 internalBinding('errors').triggerUncaughtException( ^ badCredentials (Use node --trace-uncaught ...` to show where the exception was thrown)

Node.js v21.2.0
Making request to https://trader.degiro.nl/login/secure/login with options:
{
"method": "POST",
"body": "{"isPassCodeReset":false,"isRedirectToMobile":false,"password":"XXXXX","username":"XXXXX","oneTimePassword":"XXXXX","queryParams":{"reason":"session_expired"}}",
"headers": {
"Content-Type": "application/json"
},
"credentials": "include",
"referer": "https://trader.degiro.nl/trader/"
}
Sending OTP`

Stopped working around mid-March 2024

After working smoothly for a long time, it stopped working...
some Cloudflare-like protection blocking my requests

https://trader.degiro.nl/myracloud-blocked/?

401 error on login

Ill get a VM24392:1 GET https://trader.degiro.nl/login/secure/config 401 error on login().

`const degiro = new DeGiro({
username: this.username,
pwd: this.pwd,
oneTimePassword: this.oneTimePassword,
});

try {
await degiro.login();
const jsessionId = degiro.getJSESSIONID();
console.log(jsessionId);
} catch (error) {
console.log(error);
}`

Have to re-enter credentials even when jsessionid is available.

I'd like to not prompt my users for username/password if there's still a jsessionid available. However, there's currently an explicit check to verify that an username and password are given.

Is there a reason this check exists (as I'm assuming degiro would check this server-side too), or is it double?

Should the check be removed, stay in place (for a reason unknown to me) and have documentation added, or can the check be wrapped in a if (!this.jsessionId)?

Values from Account Summary

How do I get these 6 values from the top left UI?

  1. balance
  2. available to trade
  3. portfolio
  4. money overview
  5. day P/L
  6. Total P/L

Captura de ecrรฃ de 2022-01-13 19-03-17

order.error.default when selling open position

Hi,

Everything always used to work fine, but for some reason all of a sudden whenever i try to sell a asset (ADYEN) in this case., i always get the error: order.error.default as a return when creating the order.
I currently have 1 position open on adyen (size=1), and try to do SELL 1.

    const order = {
      buySell: DeGiroActions.SELL,
      orderType: DeGiroMarketOrderTypes.MARKET, // LIMITED, MARKET, STOP_LOSS_LIMIT, STOP_LOSS
      productId: symbolId,
      size: 1,
      timeType: DeGiroTimeTypes.PERMANENT,
    };

Can't create orders

Hi, I've been messing with the API and everything works except creating orders, heres the code I have

		try {
			let order = {
				buySell: DeGiroActions.BUY,
				orderType: DeGiroMarketOrderTypes.LIMITED,
				productId: productId,
				size: quantity,
				timeType: DeGiroTimeTypes.DAY,
			};

			let { confirmationId, freeSpaceNew, transactionFees } = await this.degiro.createOrder(order);
			console.log(confirmationId, freeSpaceNew, transactionFees);

			// DEBUG: DONT EXECUTE FOR NOW
			//await this.degiro.executeOrder(order, confirmationId);

			return [true, null];
		} catch (err: any) {
			return [false, err.message];
		}

I verified and each of the members of order is correct. Most of the time I don't get any errors but nothing happens, sometimes I get 500: Internal Server Error. If I missed anything please do tell, thanks in advance.

Illegal invocation error when trying to login

Hi,

I just installed your package and am trying to figure out how it works. I've just started with the basic, trying to login but I'm already stuck there :)

import DeGiro from 'degiro-api'

const degiro = new DeGiro({
  username: 'username',
  pwd: 'xxxxx'
})

degiro.login()
  .then((accountData) => console.log('Log in success\n', accountData))
  .catch(console.error)

gives me the following error in chrome console

TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
    at Object.default (<anonymous>:1:876)
    at eval (login.js?0ff3:36)
    at new Promise (<anonymous>)
    at Object.loginRequest (login.js?0ff3:15)
    at eval (DeGiro.js?1701:59)
    at new Promise (<anonymous>)
    at DeGiro.login (DeGiro.js?1701:58)
    at VueComponent.created (App.vue?234e:19)
    at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
    at callHook (vue.runtime.esm.js?2b0e:4219)

Any idea what I could be doing wrong here?

Kind regards

Upload new version

Hey there, thanks for your work. Could you please publish a version covering the latest state. The current version does not include getTransactions for instance.

Values from Account Summary (Closed issue; can not find the answer).

Hi icastillejogomez (and soltex1),
Please see the closed issue: "Values from Account Summary" from soltex1
I have the same question as asked in this closed issue.
Can you share the answer or solution to this question?
Or can you indicate where the answer can be found?
I have no idea where to look.
Thank you in advance.

Credentials are only taken from env vars

Hi,

I tried to make this code work:

const DeGiro = require('degiro-api').default

const username = 'myUsername';
const password = 'myPassword';

const degiro = new DeGiro({ username, password });

(async() => {
  console.log(`Logging in as ${process.env.DEGIRO_USER}...`);
  const data = await degiro.login();

  const jsessionId = degiro.getJSESSIONID();
  console.log(`Logged. Session ID: ${jsessionId}`);
  console.log(data);
})()

and got and error telling me that login needed credentials:

Error: DeGiro api needs an password to access

I got the same error when using the create function.

The only way I've made it work is by using env vars DEGIRO_USER and DEGIRO_PWD.

Any idea about how to make it work with constructor params?

Thanks!

Lint errors

#39

Seems like the library has not been complying to it's own lint rules for a while now. All the errors outputted by the linter are valid.

Non-compliant files are:

  • src/api/getTransactionsRequest.ts
  • src/types/GetTransactionsOptionsType.ts
  • src/types/TransactionType.ts
  • src/types/index.ts

These files should be fixed, so the linter can help us decide if PRs are up to code standard more easily.

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.