degiro_client 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/degiro_client.rb +2 -0
- data/lib/{degiro → degiro_client}/client.rb +3 -0
- data/lib/{degiro → degiro_client}/connection.rb +10 -2
- data/lib/{degiro → degiro_client}/create_order.rb +12 -9
- data/lib/degiro_client/delete_order.rb +24 -0
- data/lib/{degiro → degiro_client}/errors.rb +0 -0
- data/lib/{degiro → degiro_client}/find_product_by_id.rb +0 -0
- data/lib/{degiro → degiro_client}/find_products.rb +0 -0
- data/lib/{degiro → degiro_client}/get_cash_funds.rb +0 -0
- data/lib/{degiro → degiro_client}/get_orders.rb +0 -0
- data/lib/{degiro → degiro_client}/get_portfolio.rb +0 -0
- data/lib/{degiro → degiro_client}/get_transactions.rb +1 -1
- data/lib/{degiro → degiro_client}/urls_map.rb +0 -0
- data/lib/{degiro → degiro_client}/user_data.rb +0 -0
- data/lib/degiro_client/version.rb +3 -0
- metadata +33 -17
- data/lib/degiro.rb +0 -1
- data/lib/degiro/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89680b852755e037aff1d51e84abbc4bee529c240904c4a3359d60a225a581f7
|
4
|
+
data.tar.gz: 50754758a586d5816eb45b0037989d77e8fdea620a14f8293c21ec24d9267e90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccc8137c988a69429de2069354c76c3887eefe5489759603582ee6606f697582e441c8442f8107f471ade685074d2bce40b24439e535e35100bf564b3cc58899
|
7
|
+
data.tar.gz: 2b84e410fc3a476aefaf023d6a74d45f6dd3911a871281963ffa2cd891e98e1f8924ccdc6d66cedee50ce81416cae03c8ae9ba52cd419b1da6485f07f5eccc95
|
@@ -2,6 +2,7 @@ require 'forwardable'
|
|
2
2
|
|
3
3
|
require_relative 'connection.rb'
|
4
4
|
require_relative 'create_order.rb'
|
5
|
+
require_relative 'delete_order.rb'
|
5
6
|
require_relative 'find_product_by_id.rb'
|
6
7
|
require_relative 'find_products.rb'
|
7
8
|
require_relative 'get_cash_funds.rb'
|
@@ -14,6 +15,7 @@ module DeGiro
|
|
14
15
|
extend Forwardable
|
15
16
|
|
16
17
|
def_delegators :@create_order, :create_buy_order, :create_sell_order
|
18
|
+
def_delegators :@delete_order, :delete_order
|
17
19
|
def_delegators :@find_product_by_id, :find_product_by_id
|
18
20
|
def_delegators :@find_products, :find_products
|
19
21
|
def_delegators :@get_cash_funds, :get_cash_funds
|
@@ -25,6 +27,7 @@ module DeGiro
|
|
25
27
|
connection = Connection.new(login, password)
|
26
28
|
|
27
29
|
@create_order = CreateOrder.new(connection)
|
30
|
+
@delete_order = DeleteOrder.new(connection)
|
28
31
|
@find_product_by_id = FindProductById.new(connection)
|
29
32
|
@find_products = FindProducts.new(connection)
|
30
33
|
@get_cash_funds = GetCashFunds.new(connection)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'faraday'
|
3
|
+
require 'faraday/detailed_logger'
|
3
4
|
require 'faraday-cookie_jar'
|
5
|
+
require 'logger'
|
4
6
|
|
5
7
|
require_relative 'urls_map.rb'
|
6
8
|
require_relative 'user_data.rb'
|
@@ -10,15 +12,20 @@ module DeGiro
|
|
10
12
|
class Connection
|
11
13
|
extend Forwardable
|
12
14
|
|
13
|
-
def_delegators :@conn, :get, :post
|
15
|
+
def_delegators :@conn, :get, :post, :delete
|
14
16
|
attr_reader :urls_map, :user_data, :session_id
|
15
17
|
|
16
18
|
BASE_TRADER_URL = 'https://trader.degiro.nl'.freeze
|
17
19
|
|
18
20
|
def initialize(login, password)
|
21
|
+
|
22
|
+
my_logger = Logger.new("degiro_client.log")
|
23
|
+
my_logger.level = Logger::DEBUG
|
24
|
+
|
19
25
|
@conn = Faraday.new(url: BASE_TRADER_URL) do |builder|
|
20
26
|
builder.use :cookie_jar
|
21
27
|
builder.use Faraday::Response::RaiseError
|
28
|
+
builder.response :detailed_logger, my_logger
|
22
29
|
builder.adapter Faraday.default_adapter
|
23
30
|
end
|
24
31
|
|
@@ -37,7 +44,8 @@ module DeGiro
|
|
37
44
|
raise MissingSessionIdError, 'Could not find valid session id' if @session_id == '' || @session_id.nil?
|
38
45
|
|
39
46
|
@urls_map = UrlsMap.new(JSON.parse(@conn.get('/login/secure/config').body))
|
40
|
-
|
47
|
+
url = "#{@urls_map['pa_url']}/client?sessionId=#{@session_id}"
|
48
|
+
@user_data = UserData.new(JSON.parse(@conn.get(url).body)["data"])
|
41
49
|
end
|
42
50
|
end
|
43
51
|
end
|
@@ -2,7 +2,7 @@ require 'json'
|
|
2
2
|
|
3
3
|
module DeGiro
|
4
4
|
class CreateOrder
|
5
|
-
BUY_SELL = { buy:
|
5
|
+
BUY_SELL = { buy: "BUY", sell: "SELL" }.freeze
|
6
6
|
ORDER_TYPES = { limited: 0, stop_limited: 1, market_order: 2, stop_loss: 3 }.freeze
|
7
7
|
TIME_TYPES = { day: 1, permanent: 3 }.freeze
|
8
8
|
|
@@ -11,24 +11,27 @@ module DeGiro
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def create_buy_order(product_id:, size:, price:)
|
14
|
-
|
15
|
-
confirmation_id = JSON.parse(check_order(order).body)['confirmationId']
|
16
|
-
confirm_order(order, confirmation_id)
|
14
|
+
create_order_with_confirmation(BUY_SELL[:buy], product_id, size, price)
|
17
15
|
end
|
18
16
|
|
19
17
|
def create_sell_order(product_id:, size:, price:)
|
20
|
-
|
21
|
-
confirmation_id = JSON.parse(check_order(order).body)['confirmationId']
|
22
|
-
confirm_order(order, confirmation_id)
|
18
|
+
create_order_with_confirmation(BUY_SELL[:sell], product_id, size, price)
|
23
19
|
end
|
24
20
|
|
25
21
|
private
|
26
22
|
|
23
|
+
def create_order_with_confirmation(buy_sell, product_id, size, price)
|
24
|
+
order = order(buy_sell, product_id, size, price)
|
25
|
+
response = check_order(order)
|
26
|
+
confirmation_id = JSON.parse(response.body)['data']['confirmationId']
|
27
|
+
confirm_order(order, confirmation_id)
|
28
|
+
end
|
29
|
+
|
27
30
|
def order(type, product_id, size, price)
|
28
31
|
{
|
29
|
-
|
32
|
+
buySell: type,
|
30
33
|
orderType: ORDER_TYPES[:limited],
|
31
|
-
productId: product_id,
|
34
|
+
productId: product_id.to_i,
|
32
35
|
size: size,
|
33
36
|
timeType: TIME_TYPES[:permanent],
|
34
37
|
price: price
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module DeGiro
|
4
|
+
class DeleteOrder
|
5
|
+
|
6
|
+
def initialize(connection)
|
7
|
+
@connection = connection
|
8
|
+
end
|
9
|
+
|
10
|
+
def delete_order(id)
|
11
|
+
@connection.delete(url(id))
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def url(confirmation_id)
|
17
|
+
"#{@connection.urls_map['trading_url']}/v5/order/#{confirmation_id}" \
|
18
|
+
";jsessionid=#{@connection.session_id}" \
|
19
|
+
"?intAccount=#{@connection.user_data['int_account']}" \
|
20
|
+
"&sessionId=#{@connection.session_id}"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -7,7 +7,7 @@ module DeGiro
|
|
7
7
|
@connection = connection
|
8
8
|
end
|
9
9
|
|
10
|
-
def get_transactions(from: (Date.today - (365 * 5)).strftime('%d/%m/%Y'), to: Date.today.strftime('%d/%m/%Y'))
|
10
|
+
def get_transactions(from: (Date.zone.today - (365 * 5)).strftime('%d/%m/%Y'), to: Date.zone.today.strftime('%d/%m/%Y'))
|
11
11
|
params = URI.encode_www_form(fromDate: from, toDate: to)
|
12
12
|
parse_transactions(JSON.parse(@connection.get(url(params)).body))
|
13
13
|
end
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: degiro_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grzegorz Błaszczyk
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-08-
|
12
|
+
date: 2019-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 0.0.6
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: faraday-detailed_logger
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.1.3
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.1.3
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: pry
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +81,8 @@ dependencies:
|
|
67
81
|
- - "~>"
|
68
82
|
- !ruby/object:Gem::Version
|
69
83
|
version: 0.51.0
|
70
|
-
description: Ruby Client for the unofficial DeGiro API
|
84
|
+
description: Ruby Client for the unofficial DeGiro API - working version with all
|
85
|
+
basic methods
|
71
86
|
email:
|
72
87
|
- grzegorz.blaszczyk@gmail.com
|
73
88
|
- tomvaneyck@gmail.com
|
@@ -75,20 +90,21 @@ executables: []
|
|
75
90
|
extensions: []
|
76
91
|
extra_rdoc_files: []
|
77
92
|
files:
|
78
|
-
- lib/
|
79
|
-
- lib/
|
80
|
-
- lib/
|
81
|
-
- lib/
|
82
|
-
- lib/
|
83
|
-
- lib/
|
84
|
-
- lib/
|
85
|
-
- lib/
|
86
|
-
- lib/
|
87
|
-
- lib/
|
88
|
-
- lib/
|
89
|
-
- lib/
|
90
|
-
- lib/
|
91
|
-
- lib/
|
93
|
+
- lib/degiro_client.rb
|
94
|
+
- lib/degiro_client/client.rb
|
95
|
+
- lib/degiro_client/connection.rb
|
96
|
+
- lib/degiro_client/create_order.rb
|
97
|
+
- lib/degiro_client/delete_order.rb
|
98
|
+
- lib/degiro_client/errors.rb
|
99
|
+
- lib/degiro_client/find_product_by_id.rb
|
100
|
+
- lib/degiro_client/find_products.rb
|
101
|
+
- lib/degiro_client/get_cash_funds.rb
|
102
|
+
- lib/degiro_client/get_orders.rb
|
103
|
+
- lib/degiro_client/get_portfolio.rb
|
104
|
+
- lib/degiro_client/get_transactions.rb
|
105
|
+
- lib/degiro_client/urls_map.rb
|
106
|
+
- lib/degiro_client/user_data.rb
|
107
|
+
- lib/degiro_client/version.rb
|
92
108
|
homepage: https://github.com/grzegorzblaszczyk/degiro
|
93
109
|
licenses:
|
94
110
|
- MIT
|
data/lib/degiro.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require_relative 'degiro/client.rb'
|
data/lib/degiro/version.rb
DELETED