degiro-api
Version:
Unofficial DeGiro API for Javascript. Buy and sell in the stock market. See your portfolio and much more
864 lines (792 loc) • 44.8 kB
HTML
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>degiro-api</title>
<meta name="description" content="Documentation for degiro-api">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.json" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">degiro-api</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
<input type="checkbox" id="tsd-filter-only-exported" />
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="globals.html">Globals</a>
</li>
</ul>
<h1>degiro-api</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<a href="#degiro-trading-broker-api" id="degiro-trading-broker-api" style="color: inherit; text-decoration: none;">
<h1>DeGiro Trading Broker API</h1>
</a>
<p>This is an unofficial TypeScript API client (Backend & Frontend) for DeGiro's trading platform. Using this module you can easily automate your orders (buy and sell) and get information about orders, funds or products.</p>
<p>All responses and objects are typed to develop faster and secure.</p>
<p><img src="https://raw.githubusercontent.com/icastillejogomez/degiro-api/master/.assets/degiro.png" alt="DeGiro Logo"></p>
<p><img src="https://badgen.net/github/stars/icastillejogomez/degiro-api" alt="stars">
<img src="https://badgen.net/github/open-issues/icastillejogomez/degiro-api" alt="stars">
<img src="https://badgen.net/github/license/icastillejogomez/degiro-api" alt="stars"></p>
<br />
<p><a href="https://www.buymeacoffee.com/nachoogoomez" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a></p>
<a href="#table-of-content" id="table-of-content" style="color: inherit; text-decoration: none;">
<h2>Table of content</h2>
</a>
<!--ts-->
<ul>
<li><a href="#degiro-trading-broker-api">DeGiro Trading Broker API</a></li>
<li><a href="#table-of-contents">Table of contents</a></li>
<li><a href="#Installation">Installation</a></li>
<li><a href="#how-to-use">How to use</a><ul>
<li><a href="#create-an-instance-of-degiro">Create an instance of DeGiro</a></li>
<li><a href="#local-files">Active Debug mode</a></li>
<li><a href="#remote-files">Documentation</a></li>
<li><a href="#multiple-files">Running tests set</a></li>
<li><a href="#combo">Get JSESSIONID and reuse sessions</a></li>
<li><a href="#auto-insert-and-update-toc">Check if we are authenticated</a></li>
</ul>
</li>
<li><a href="#tests">API</a><ul>
<li><a href="#foo">Session</a><ul>
<li><a href="#foo">login</a></li>
<li><a href="#foo">logout</a></li>
<li><a href="#foo">isLogin</a></li>
<li><a href="#foo">getJSESSIONID</a></li>
</ul>
</li>
<li><a href="#foo">Account</a><ul>
<li><a href="#foo">getAccountConfig</a></li>
<li><a href="#foo">getAccountData</a></li>
<li><a href="#foo">getAccountState</a></li>
<li><a href="#foo">getAccountReports</a></li>
<li><a href="#foo">getAccountInfo</a></li>
</ul>
</li>
<li><a href="#foo">Search products</a></li>
<li><a href="#foo">Cash Funds</a></li>
<li><a href="#foo">Porfolio</a></li>
<li><a href="#foo">Stocks</a><ul>
<li><a href="#foo">getFavouriteProducts</a></li>
<li><a href="#foo">getPopularStocks</a></li>
</ul>
</li>
<li><a href="#foo">Orders</a><ul>
<li><a href="#foo">getOrders</a></li>
<li><a href="#foo">getHistoricalOrders</a></li>
<li><a href="#foo">createOrder</a></li>
<li><a href="#foo">executeOrder</a></li>
<li><a href="#foo">deleteOrder</a></li>
</ul>
</li>
<li><a href="#foo">Miscellaneous</a><ul>
<li><a href="#foo">getProductsByIds</a></li>
<li><a href="#foo">getNews</a></li>
<li><a href="#foo">getWebi18nMessages</a></li>
<li><a href="#foo">getWebSettings</a></li>
<li><a href="#foo">getWebUserSettings</a></li>
<li><a href="#foo">getConfigDictionary</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#degiro-command-line-interface">Degiro Command Line Interface</a></li>
<li><a href="#dependency">License</a></li>
<li><a href="#to-do-list">TO DO List</a><!--te-->
</li>
</ul>
<a href="#installation" id="installation" style="color: inherit; text-decoration: none;">
<h2>Installation</h2>
</a>
<pre><code class="language-sh"><span class="hljs-comment"># using npm</span>
npm install --save degiro-api
<span class="hljs-comment"># using yarn</span>
yarn add degiro-api</code></pre>
<a href="#how-to-use" id="how-to-use" style="color: inherit; text-decoration: none;">
<h2>How to use</h2>
</a>
<a href="#create-an-instance-of-degiro" id="create-an-instance-of-degiro" style="color: inherit; text-decoration: none;">
<h3>Create an instance of DeGiro</h3>
</a>
<p>Basic log into DeGiro Platform. All endpoint needs a session key before those can be call them. You can pass credentials to DeGiro constructor or export in your terminal prompt sesion as <code>DEGIRO_USER</code> and <code>DEGIRO_PWD</code></p>
<pre><code class="language-js"><span class="hljs-keyword">const</span> DeGiro = <span class="hljs-built_in">require</span>(<span class="hljs-string">'degiro-api'</span>)
<span class="hljs-keyword">const</span> degiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'username'</span>,
<span class="hljs-attr">pwd</span>: <span class="hljs-string">'*****'</span>
})
degiro.login()
.then(<span class="hljs-function">(<span class="hljs-params">accountData</span>) =></span> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Log in success\n'</span>, accountData))
.catch(<span class="hljs-built_in">console</span>.error)
<span class="hljs-comment">// or creating with the static create method</span>
<span class="hljs-keyword">const</span> degiro = DeGiro.create({ <span class="hljs-attr">username</span>: <span class="hljs-string">'*****'</span>, <span class="hljs-attr">pwd</span>: <span class="hljs-string">'*****'</span> })
<span class="hljs-keyword">const</span> accountData = <span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-comment">// or create with env credentials</span>
<span class="hljs-keyword">const</span> degiro = <span class="hljs-keyword">new</span> DeGiro() <span class="hljs-comment">// <-- Use DEGIRO_USER & DEGIRO_PWD</span>
<span class="hljs-keyword">const</span> accountData = <span class="hljs-keyword">await</span> degiro.login()</code></pre>
<a href="#active-debug-mode" id="active-debug-mode" style="color: inherit; text-decoration: none;">
<h3>Active Debug mode</h3>
</a>
<pre><code class="language-js">$ <span class="hljs-keyword">export</span> DEGIRO_DEBUG=<span class="hljs-number">1</span>
$ yarn start</code></pre>
<a href="#documentation" id="documentation" style="color: inherit; text-decoration: none;">
<h3>Documentation</h3>
</a>
<p>Run the next command and open index.html file inside doc folder.</p>
<pre><code class="language-sh">$ yarn doc
yarn run v1.22.4
$ typedoc --out docs src
Using TypeScript 3.9.2 from ....../degiro-api/node_modules/typescript/lib
Rendering [========================================] 100%
Documentation generated at ....../degiro-api/docs
✨ Done <span class="hljs-keyword">in</span> 3.94s.</code></pre>
<a href="#running-tests-set" id="running-tests-set" style="color: inherit; text-decoration: none;">
<h3>Running tests set</h3>
</a>
<p>Before run the test set you must set DEGIRO_USER & DEGIRO_PWD env export variables to attach an account to the test sets.</p>
<pre><code class="language-js">$ yarn install && yarn test
yarn run v1<span class="hljs-number">.22</span><span class="hljs-number">.4</span>
$ mocha -r ts-node/register tests<span class="hljs-comment">/**/*.spec.ts
Environment variables
✓ DEGIRO_USER env var should exists
✓ DEGIRO_PWD env var should exists
Create DeGiro instance
✓ should create an instance of DeGiro class from env vars
✓ should create an instance of DeGiro class from constructor params
DeGiro login process
✓ should successfully log in with environment credentials (619ms)
✓ should return a valid account config from server (738ms)
✓ should return a valid account data from server (727ms)
✓ getJSESSIONID should return a valid jsessionId
✓ should login with previous jsessionId
DeGiro logout process
✓ should successfully log out after sign in (685ms)
10 passing (3s)
✨ Done in 5.21s.</span></code></pre>
<a href="#get-jsessionid-and-reuse-sessions" id="get-jsessionid-and-reuse-sessions" style="color: inherit; text-decoration: none;">
<h3>Get JSESSIONID and reuse sessions</h3>
</a>
<p>The JSessionId is the session browser cookie that DeGiro use to authenticate requests. You could prevent masive login/logout requests reusing a valid jsessionid from previous DeGiro instance. The way to do that is:</p>
<p><code>getJSESSIONID(): string</code></p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> degiro = <span class="hljs-keyword">new</span> DeGiro({}) <span class="hljs-comment">// <-- Using ENV variables</span>
<span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-comment">// Get the jsessionId (LOOK, is not a promise)</span>
<span class="hljs-keyword">const</span> jsessionId = degiro.getJSESSIONID()
})()</code></pre>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-comment">// Create an instance from a previous session</span>
<span class="hljs-keyword">const</span> degiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'<your_username_here>'</span>,
<span class="hljs-attr">pwd</span>: <span class="hljs-string">'*******'</span>,
<span class="hljs-attr">jsessionId</span>: previousJSESSIONID
})
<span class="hljs-comment">// Hydrate</span>
<span class="hljs-comment">// Re-use sessions need to re-hydrate the account config data and could use as a session expiration checker</span>
<span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-comment">// Do your stuff here...</span>
})()</code></pre>
<a href="#check-if-we-are-authenticated" id="check-if-we-are-authenticated" style="color: inherit; text-decoration: none;">
<h3>Check if we are authenticated</h3>
</a>
<p><code>isLogin(options): boolean</code></p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-comment">// Create an instance from a previous session</span>
<span class="hljs-keyword">const</span> degiro = <span class="hljs-keyword">new</span> DeGiro({}) <span class="hljs-comment">// <-- Using ENV variables</span>
<span class="hljs-keyword">if</span> (!degiro.isLogin()) {
<span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-keyword">if</span> (degiro.isLogin()) {
<span class="hljs-comment">// AWESOME!! We're in</span>
}
}
})()</code></pre>
<p>The problem with this method is that it only checks if you have the account configuration data set. The only way to verify that the session is still active is make a request.
You can force isLogin method passing it a <code>secure</code> field set to true. This way the method will return a promise and below it will call a DeGiro API endpoint (usually getAccountConfig)</p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-comment">// Create an instance from a previous session</span>
<span class="hljs-keyword">const</span> degiro = <span class="hljs-keyword">new</span> DeGiro({}) <span class="hljs-comment">// <-- Using ENV variables</span>
<span class="hljs-comment">// Force to make a request and check if session is still alive</span>
<span class="hljs-keyword">if</span>(! <span class="hljs-keyword">await</span> degiro.isLogin({ <span class="hljs-attr">secure</span>: <span class="hljs-literal">true</span> })) {
<span class="hljs-keyword">await</span> degiro.login()
}
})()</code></pre>
<a href="#get-account-details-explicitly" id="get-account-details-explicitly" style="color: inherit; text-decoration: none;">
<h3>Get account details explicitly</h3>
</a>
<p>Get account info using <code>await</code>:</p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> degiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'username'</span>,
<span class="hljs-attr">pwd</span>: <span class="hljs-string">'*****'</span>
})
<span class="hljs-keyword">await</span> degiro.login() <span class="hljs-comment">// Login also returns accountData</span>
<span class="hljs-keyword">const</span> accountData = <span class="hljs-keyword">await</span> degiro.getAccountData()
<span class="hljs-comment">// console.log(accountData)</span>
})()</code></pre>
<a href="#get-portfolio" id="get-portfolio" style="color: inherit; text-decoration: none;">
<h3>Get portfolio</h3>
</a>
<p><code>getPortfolio(config: GetPorfolioConfigType): Promise<any[]></code></p>
<p><code>getPortfolio</code> config parameter could have:</p>
<ul>
<li><p><strong>type</strong>: set the types or positions you want to fetch. Could be:</p>
<ul>
<li>ALL: Gets the response without filter it</li>
<li>ALL_POSITIONS: Gets only positions in products. Exclude positions like 'CASH', etc.</li>
<li>OPEN: Gets only opened positions. </li>
<li>CLOSED: Gets only the closed positions in your portfolio.</li>
</ul>
</li>
<li><p><strong>getProductDetails</strong>: if is set to true the positions results will have a <code>productData</code> field with all the product details.</p>
</li>
</ul>
<p>Get all <strong>open</strong> positions:</p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro, { DeGiroEnums, DeGiroTypes } <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
<span class="hljs-keyword">const</span> { PORTFOLIO_POSITIONS_TYPE_ENUM } = DeGiroEnums
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> degiro: DeGiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'your_username_here'</span>,
<span class="hljs-attr">pwd</span>: <span class="hljs-string">'**********'</span>,
})
<span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-keyword">const</span> portfolio = <span class="hljs-keyword">await</span> degiro.getPortfolio({
<span class="hljs-attr">type</span>: PORTFOLIO_POSITIONS_TYPE_ENUM.ALL,
<span class="hljs-attr">getProductDetails</span>: <span class="hljs-literal">true</span>,
})
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(portfolio, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>))
})()</code></pre>
<p>Also you can fetch your portfolio data this way:</p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro, { DeGiroEnums, DeGiroTypes } <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
<span class="hljs-keyword">const</span> { PORTFOLIO_POSITIONS_TYPE_ENUM } = DeGiroEnums
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> degiro: DeGiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'your_username_here'</span>,
<span class="hljs-attr">pwd</span>: <span class="hljs-string">'**********'</span>,
})
<span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-keyword">const</span> portfolio = <span class="hljs-keyword">await</span> degiro.getPortfolio({ <span class="hljs-attr">type</span>: PORTFOLIO_POSITIONS_TYPE_ENUM.ALL })
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(portfolio, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>))
})()</code></pre>
<p>And getting product details too</p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro, { DeGiroEnums, DeGiroTypes } <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
<span class="hljs-keyword">const</span> { PORTFOLIO_POSITIONS_TYPE_ENUM } = DeGiroEnums
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> degiro: DeGiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'your_username_here'</span>,
<span class="hljs-attr">pwd</span>: <span class="hljs-string">'**********'</span>,
})
<span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-keyword">const</span> portfolio = <span class="hljs-keyword">await</span> degiro.getPortfolio({
<span class="hljs-attr">type</span>: PORTFOLIO_POSITIONS_TYPE_ENUM.ALL,
<span class="hljs-attr">getProductDetails</span>: <span class="hljs-literal">true</span>,
})
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(portfolio, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>))
})()</code></pre>
<a href="#search-product-stock-and-much-more-in-broker" id="search-product-stock-and-much-more-in-broker" style="color: inherit; text-decoration: none;">
<h3>Search product, stock and much more in broker</h3>
</a>
<p><code>degiro.searchProduct(options): Promise<SearchProductResultType[]></code></p>
<ul>
<li><strong>options</strong>: <ul>
<li><strong>text</strong>: <em>required</em> string,</li>
<li><strong>type</strong>: <em>optional</em> DeGiroProducTypes</li>
<li><strong>limit</strong>: <em>optional</em> number default=10,</li>
<li><strong>offset</strong>: <em>optional</em> number default=0,</li>
</ul>
</li>
</ul>
<p><code>DeGiroProducTypes</code></p>
<ul>
<li><em>shares</em>: 1</li>
<li><em>bonds</em>: 2</li>
<li><em>futures</em>: 7</li>
<li><em>options</em>: 8</li>
<li><em>investmendFunds</em>: 13</li>
<li><em>leveragedProducts</em>: 14</li>
<li><em>etfs</em>: 131</li>
<li><em>cfds</em>: 535</li>
<li><em>warrants</em>: 536</li>
</ul>
<p>Search the text "AAPL" without any limitation</p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> degiro: DeGiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'your_username_here'</span>,
<span class="hljs-attr">pwd</span>: <span class="hljs-string">'***********'</span>,
})
<span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> degiro.searchProduct({ <span class="hljs-attr">text</span>: <span class="hljs-string">'AAPL'</span> })
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(result, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>))
})()</code></pre>
<p>Search TSLA stock</p>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro, { DeGiroEnums, DeGiroTypes } <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
<span class="hljs-keyword">const</span> { DeGiroProducTypes } = DeGiroEnums
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> degiro: DeGiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'your_username_here'</span>,
<span class="hljs-attr">pwd</span>: <span class="hljs-string">'***********'</span>,
})
<span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> degiro.searchProduct({
<span class="hljs-attr">text</span>: <span class="hljs-string">'TSLA'</span>,
<span class="hljs-attr">type</span>: DeGiroProducTypes.shares,
<span class="hljs-attr">limit</span>: <span class="hljs-number">1</span>,
})
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify(result, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>))
})()</code></pre>
<a href="#degiro-orders" id="degiro-orders" style="color: inherit; text-decoration: none;">
<h2>DeGiro Orders</h2>
</a>
<a href="#create-a-new-order" id="create-a-new-order" style="color: inherit; text-decoration: none;">
<h3>Create a new order</h3>
</a>
<p><code>degiro.createOrder(order: OrderType): Promise<CreateOrderResultType></code></p>
<ul>
<li><strong>OrderType</strong><ul>
<li><strong>buySell</strong>: DeGiroActions,</li>
<li><strong>orderType</strong>: DeGiroMarketOrderTypes,</li>
<li><strong>price</strong>: <em>optional</em> Number,</li>
<li><strong>productId</strong>: string,</li>
<li><strong>size</strong>: number,</li>
<li><strong>stopPrice</strong>: <em>optional</em> number,</li>
<li><strong>timeType</strong>: DeGiroTimeTypes,</li>
</ul>
</li>
</ul>
<ul>
<li><strong>DeGiroActions</strong><ul>
<li><strong>BUY</strong>: 'BUY',</li>
<li><strong>SELL</strong>: 'SELL',</li>
</ul>
</li>
</ul>
<ul>
<li><p><strong>DeGiroMarketOrderTypes</strong></p>
<ul>
<li><strong>LIMITED</strong>: 0,</li>
<li><strong>MARKET</strong>: 2,</li>
<li><strong>STOP_LOSS</strong>: 3,</li>
<li><strong>STOP_LOSS_LIMIT</strong>: 1,</li>
</ul>
</li>
<li><p><strong>DeGiroTimeTypes</strong></p>
<ul>
<li><strong>DAY</strong>: 1,</li>
<li><strong>PERMANENT</strong>: 3,</li>
</ul>
</li>
<li><p><strong>CreateOrderResultType</strong></p>
<ul>
<li><strong>confirmationId</strong>: String,</li>
<li><strong>freeSpaceNew</strong>: Number,</li>
<li><strong>transactionFees</strong>: [TransactionFeeType],</li>
</ul>
</li>
</ul>
<ul>
<li><strong>TransactionFeeType</strong><ul>
<li><strong>amount</strong>: Number,</li>
<li><strong>currency</strong>: String,</li>
<li><strong>id</strong>: Number,</li>
</ul>
</li>
</ul>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro, { DeGiroEnums, DeGiroTypes } <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
<span class="hljs-keyword">const</span> { DeGiroActions, DeGiroMarketOrderTypes, DeGiroTimeTypes } = DeGiroEnums
<span class="hljs-keyword">const</span> { OrderType } = DeGiroTypes
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> degiro: DeGiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'your_username_here'</span>,
<span class="hljs-attr">pwd</span>: <span class="hljs-string">'************'</span>
})
<span class="hljs-keyword">await</span> degiro.login()
<span class="hljs-keyword">const</span> order: OrderType = {
<span class="hljs-attr">buySell</span>: DeGiroActions.BUY,
<span class="hljs-attr">orderType</span>: DeGiroMarketOrderTypes.LIMITED,
<span class="hljs-attr">productId</span>: <span class="hljs-string">'331868'</span>, <span class="hljs-comment">// $AAPL - Apple Inc</span>
<span class="hljs-attr">size</span>: <span class="hljs-number">1</span>,
<span class="hljs-attr">timeType</span>: DeGiroTimeTypes.DAY,
<span class="hljs-attr">price</span>: <span class="hljs-number">272</span>, <span class="hljs-comment">// limit price [Degiro could reject this value]</span>
<span class="hljs-comment">// stopPrice: 2,</span>
}
<span class="hljs-keyword">const</span> { confirmationId, freeSpaceNew, transactionFees } = <span class="hljs-keyword">await</span> degiro.createOrder(order)
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">JSON</span>.stringify({ confirmationId, freeSpaceNew, transactionFees }, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>))
})()</code></pre>
<a href="#execute-an-order" id="execute-an-order" style="color: inherit; text-decoration: none;">
<h3>Execute an order</h3>
</a>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro, { DeGiroEnums, DeGiroTypes } <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
<span class="hljs-keyword">const</span> { DeGiroActions, DeGiroMarketOrderTypes, DeGiroTimeTypes } = DeGiroEnums
<span class="hljs-keyword">const</span> { OrderType } = DeGiroTypes
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">try</span> {
<span class="hljs-keyword">const</span> degiro: DeGiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'nachoogoomezomg'</span>,
<span class="hljs-attr">pwd</span>: <span class="xml"><span class="hljs-tag"><<span class="hljs-name">string</span>></span>process.env.DEGIRO_PWD,
})
await degiro.login()
const order: OrderType = {
buySell: DeGiroActions.BUY,
orderType: DeGiroMarketOrderTypes.LIMITED,
productId: '331868', // $AAPL - Apple Inc
size: 1,
timeType: DeGiroTimeTypes.DAY,
price: 270, // limit price
// stopPrice: 2,
}
const { confirmationId, freeSpaceNew, transactionFees } = await degiro.createOrder(order)
const orderId = await degiro.executeOrder(order, confirmationId)
console.log(`Order executed with id: ${orderId}`)
} catch (error) {
console.error(error)
}
})()</span></code></pre>
<a href="#remove-an-order" id="remove-an-order" style="color: inherit; text-decoration: none;">
<h3>Remove an order</h3>
</a>
<pre><code class="language-js"><span class="hljs-keyword">import</span> DeGiro, { DeGiroEnums, DeGiroTypes } <span class="hljs-keyword">from</span> <span class="hljs-string">'degiro-api'</span>
<span class="hljs-keyword">const</span> { DeGiroActions, DeGiroMarketOrderTypes, DeGiroTimeTypes } = DeGiroEnums
<span class="hljs-keyword">const</span> { OrderType } = DeGiroTypes
(<span class="hljs-keyword">async</span> () => {
<span class="hljs-keyword">const</span> degiro: DeGiro = <span class="hljs-keyword">new</span> DeGiro({
<span class="hljs-attr">username</span>: <span class="hljs-string">'nachoogoomezomg'</span>,
<span class="hljs-attr">pwd</span>: <span class="xml"><span class="hljs-tag"><<span class="hljs-name">string</span>></span>process.env.DEGIRO_PWD,
})
await degiro.login()
const order: OrderType = {
buySell: DeGiroActions.BUY,
orderType: DeGiroMarketOrderTypes.LIMITED,
productId: '331868', // $AAPL - Apple Inc
size: 1,
timeType: DeGiroTimeTypes.DAY,
price: 272, // limit price
// stopPrice: 2,
}
const { confirmationId, freeSpaceNew, transactionFees } = await degiro.createOrder(order)
const orderId = await degiro.executeOrder(order, confirmationId)
console.log(`Order executed with id: ${orderId}`)
// Wait few seconds to avoid "Rate limit for the given request exceeded" error
const TIMEOUT_SECONDS = 2 * 1000
const deleteOrderFunction = async () => {
try {
await degiro.deleteOrder(orderId)
console.log('Order removed')
} catch (error) {
console.error(error)
}
}
setTimeout(deleteOrderFunction, TIMEOUT_SECONDS)
})()</span></code></pre>
<a href="#degiro-command-line-interface" id="degiro-command-line-interface" style="color: inherit; text-decoration: none;">
<h2>Degiro Command Line Interface</h2>
</a>
<p><a href="https://github.com/icastillejogomez/degiro-cli">degiro-cli</a> is an usefull command line interface that help us dealing with DeGiro platform through the terminal. You can see your portfolio status, create and execute orders and much more (may in the future)</p>
<pre><code class="language-sh">$ degiro
Usage: DeGiro Command Line Interface [options] [<span class="hljs-built_in">command</span>]
DeGiro CLI provide you access to DeGiro Broker across the terminal
Options:
-V, --version output the version number
-h, --<span class="hljs-built_in">help</span> display <span class="hljs-built_in">help</span> <span class="hljs-keyword">for</span> <span class="hljs-built_in">command</span>
Commands:
login validate credentials with DeGiro platform
search Search products <span class="hljs-keyword">in</span> DeGiro
portfolio show account portfolio <span class="hljs-keyword">in</span> real-time
<span class="hljs-built_in">help</span> [<span class="hljs-built_in">command</span>] display <span class="hljs-built_in">help</span> <span class="hljs-keyword">for</span> <span class="hljs-built_in">command</span></code></pre>
<a href="#license" id="license" style="color: inherit; text-decoration: none;">
<h2>License</h2>
</a>
<p>MIT</p>
<a href="#to-do-list" id="to-do-list" style="color: inherit; text-decoration: none;">
<h2>TO DO List</h2>
</a>
<ol>
<li>Two factor</li>
<li>Get prices</li>
</ol>
</div>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="globals ">
<a href="globals.html"><em>Globals</em></a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_degiro_.html">"<wbr>DeGiro"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_createorderrequest_.html">"api/create<wbr>Order<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_deleteorderrequest_.html">"api/delete<wbr>Order<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_executeorderrequest_.html">"api/execute<wbr>Order<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getaccountconfig_.html">"api/get<wbr>Account<wbr>Config"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getaccountdata_.html">"api/get<wbr>Account<wbr>Data"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getaccountinforequest_.html">"api/get<wbr>Account<wbr>Info<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getaccountreportsrequest_.html">"api/get<wbr>Account<wbr>Reports<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getaccountstaterequest_.html">"api/get<wbr>Account<wbr>State<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getcashfundstrequest_.html">"api/get<wbr>Cash<wbr>Fundst<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getconfigdictionaryrequest_.html">"api/get<wbr>Config<wbr>Dictionary<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getnewsrequest_.html">"api/get<wbr>News<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getordersrequest_.html">"api/get<wbr>Orders<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getportfoliorequest_.html">"api/get<wbr>Portfolio<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getproductsbyidsrequest_.html">"api/get<wbr>Products<wbr>ByIds<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getwebsettingsrequest_.html">"api/get<wbr>Web<wbr>Settings<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getwebusersettingsrequest_.html">"api/get<wbr>Web<wbr>User<wbr>Settings<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_getwebi18nmessagesrequest_.html">"api/get<wbr>Webi18n<wbr>Messages<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_index_.html">"api/index"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_login_.html">"api/login"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_logout_.html">"api/logout"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_api_searchproductrequest_.html">"api/search<wbr>Product<wbr>Request"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_enums_degiroenums_.html">"enums/<wbr>DeGiro<wbr>Enums"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_enums_index_.html">"enums/index"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_interfaces_degiroclassinterface_.html">"interfaces/<wbr>DeGiro<wbr>Class<wbr>Interface"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_interfaces_index_.html">"interfaces/index"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_main_.html">"main"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_accountconfigtype_.html">"types/<wbr>Account<wbr>Config<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_accountdatatype_.html">"types/<wbr>Account<wbr>Data<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_accountinfotype_.html">"types/<wbr>Account<wbr>Info<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_accountreportstype_.html">"types/<wbr>Account<wbr>Reports<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_cashfoundtype_.html">"types/<wbr>Cash<wbr>Found<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_configdictionarytype_.html">"types/<wbr>Config<wbr>Dictionary<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_createorderresulttype_.html">"types/<wbr>Create<wbr>Order<wbr>Result<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_degirosettuptype_.html">"types/<wbr>DeGiro<wbr>Settup<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_favouriteproducttype_.html">"types/<wbr>Favourite<wbr>Product<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_getaccountstateoptionstype_.html">"types/<wbr>Get<wbr>Account<wbr>State<wbr>Options<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_gethistoricalordersoptionstype_.html">"types/<wbr>Get<wbr>Historical<wbr>Orders<wbr>Options<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_getnewsoptionstype_.html">"types/<wbr>Get<wbr>News<wbr>Options<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_getordersconfigtype_.html">"types/<wbr>Get<wbr>Orders<wbr>Config<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_getordersresulttype_.html">"types/<wbr>Get<wbr>Orders<wbr>Result<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_getporfolioconfigtype_.html">"types/<wbr>Get<wbr>Porfolio<wbr>Config<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_historicalorderstype_.html">"types/<wbr>Historical<wbr>Orders<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_isloginoptionstype_.html">"types/<wbr>IsLogin<wbr>Options<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_loginrequestbodytype_.html">"types/<wbr>Login<wbr>Request<wbr>Body<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_loginrequestparamstype_.html">"types/<wbr>Login<wbr>Request<wbr>Params<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_loginresponsetype_.html">"types/<wbr>Login<wbr>Response<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_newstype_.html">"types/<wbr>News<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_ordertype_.html">"types/<wbr>Order<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_portfoliopositiontype_.html">"types/<wbr>Portfolio<wbr>Position<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_searchproductoptionstype_.html">"types/<wbr>Search<wbr>Product<wbr>Options<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_searchproductresulttype_.html">"types/<wbr>Search<wbr>Product<wbr>Result<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_stocktype_.html">"types/<wbr>Stock<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_transactionfeetype_.html">"types/<wbr>Transaction<wbr>Fee<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_websettingstype_.html">"types/<wbr>Web<wbr>Settings<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_webusersettingtype_.html">"types/<wbr>Web<wbr>User<wbr>Setting<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_i18nmessagestype_.html">"types/i18n<wbr>Messages<wbr>Type"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_types_index_.html">"types/index"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_utils_debug_.html">"utils/debug"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_utils_generatereporturifromid_.html">"utils/generate<wbr>ReportURIFromID"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_utils_index_.html">"utils/index"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_utils_processgetcashfundsresultlistobject_.html">"utils/process<wbr>Get<wbr>Cash<wbr>Funds<wbr>Result<wbr>List<wbr>Object"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_utils_processgetordersresultlistobject_.html">"utils/process<wbr>Get<wbr>Orders<wbr>Result<wbr>List<wbr>Object"</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_utils_processportfolio_.html">"utils/process<wbr>Portfolio"</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="assets/js/search.js"><' + '/script>');</script>
</body>
</html>