degiro 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/degiro/client.rb +4 -1
- data/lib/degiro/connection.rb +1 -1
- data/lib/degiro/create_order.rb +32 -10
- data/lib/degiro/get_portfolio.rb +1 -2
- data/lib/degiro/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0eb7bd4ae0b88684e4cd8daa8281e4dbc0600b46fecb014fa5a179bda7613b0a
|
4
|
+
data.tar.gz: 1dd27d12ea53f6fe7d160555ef8f2c32e5b528b8c829e6751df1a5afa9cb4eb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a24ff3c6e66b448b2509c98ca1760b28fb8460beed53ebed4af68694f27bbb8a5898f6dd8f28f4e7751204596fa098fde728d4ebf8a4bce7093fffcfcb6207f6
|
7
|
+
data.tar.gz: aacd072df6aa6d4139107186494da4e31a58203b5eed3e38ca9533d8403d76ee00648097548290a76799dc93df422daf13a3e2c701ce1ad5cb88ce9b3afdb6ef
|
data/lib/degiro/client.rb
CHANGED
@@ -13,7 +13,10 @@ module DeGiro
|
|
13
13
|
class Client
|
14
14
|
extend Forwardable
|
15
15
|
|
16
|
-
def_delegators :@create_order, :
|
16
|
+
def_delegators :@create_order, :create_market_buy_order
|
17
|
+
def_delegators :@create_order, :create_market_sell_order
|
18
|
+
def_delegators :@create_order, :create_limit_buy_order
|
19
|
+
def_delegators :@create_order, :create_limit_sell_order
|
17
20
|
def_delegators :@find_product_by_id, :find_product_by_id
|
18
21
|
def_delegators :@find_products, :find_products
|
19
22
|
def_delegators :@get_cash_funds, :get_cash_funds
|
data/lib/degiro/connection.rb
CHANGED
@@ -37,7 +37,7 @@ module DeGiro
|
|
37
37
|
raise MissingSessionIdError, 'Could not find valid session id' if @session_id == '' || @session_id.nil?
|
38
38
|
|
39
39
|
@urls_map = UrlsMap.new(JSON.parse(@conn.get('/login/secure/config').body))
|
40
|
-
@user_data = UserData.new(JSON.parse(@conn.get("#{@urls_map['pa_url']}/client?sessionId=#{@session_id}").body))
|
40
|
+
@user_data = UserData.new(JSON.parse(@conn.get("#{@urls_map['pa_url']}/client?sessionId=#{@session_id}").body)['data'])
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
data/lib/degiro/create_order.rb
CHANGED
@@ -2,31 +2,53 @@ require 'json'
|
|
2
2
|
|
3
3
|
module DeGiro
|
4
4
|
class CreateOrder
|
5
|
-
BUY_SELL = { buy:
|
6
|
-
ORDER_TYPES = { limited: 0, stop_limited: 1,
|
5
|
+
BUY_SELL = { buy: 'BUY', sell: 'SELL' }.freeze
|
6
|
+
ORDER_TYPES = { limited: 0, stop_limited: 1, market: 2, stop_loss: 3 }.freeze
|
7
7
|
TIME_TYPES = { day: 1, permanent: 3 }.freeze
|
8
8
|
|
9
9
|
def initialize(connection)
|
10
10
|
@connection = connection
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
order =
|
15
|
-
confirmation_id = JSON.parse(check_order(order).body)['confirmationId']
|
13
|
+
def create_market_buy_order(product_id:, size:)
|
14
|
+
order = market_order(BUY_SELL[:buy], product_id, size)
|
15
|
+
confirmation_id = JSON.parse(check_order(order).body)['data']['confirmationId']
|
16
16
|
confirm_order(order, confirmation_id)
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
order =
|
21
|
-
confirmation_id = JSON.parse(check_order(order).body)['confirmationId']
|
19
|
+
def create_market_sell_order(product_id:, size:)
|
20
|
+
order = market_order(BUY_SELL[:sell], product_id, size)
|
21
|
+
confirmation_id = JSON.parse(check_order(order).body)['data']['confirmationId']
|
22
|
+
confirm_order(order, confirmation_id)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_limit_buy_order(product_id:, size:, price:)
|
26
|
+
order = limit_order(BUY_SELL[:buy], product_id, size, price)
|
27
|
+
confirmation_id = JSON.parse(check_order(order).body)['data']['confirmationId']
|
28
|
+
confirm_order(order, confirmation_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_limit_sell_order(product_id:, size:, price:)
|
32
|
+
order = limit_order(BUY_SELL[:sell], product_id, size, price)
|
33
|
+
confirmation_id = JSON.parse(check_order(order).body)['data']['confirmationId']
|
22
34
|
confirm_order(order, confirmation_id)
|
23
35
|
end
|
24
36
|
|
25
37
|
private
|
26
38
|
|
27
|
-
def
|
39
|
+
def market_order(type, product_id, size)
|
40
|
+
{
|
41
|
+
buySell: type,
|
42
|
+
orderType: ORDER_TYPES[:market],
|
43
|
+
productId: product_id,
|
44
|
+
size: size,
|
45
|
+
timeType: TIME_TYPES[:permanent]
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def limit_order(type, product_id, size, price)
|
28
50
|
{
|
29
|
-
|
51
|
+
buySell: type,
|
30
52
|
orderType: ORDER_TYPES[:limited],
|
31
53
|
productId: product_id,
|
32
54
|
size: size,
|
data/lib/degiro/get_portfolio.rb
CHANGED
@@ -18,8 +18,7 @@ module DeGiro
|
|
18
18
|
{
|
19
19
|
size: order['value'].find { |field| field['name'] == 'size' }['value'],
|
20
20
|
value: order['value'].find { |field| field['name'] == 'price' }['value'],
|
21
|
-
product_id: order['value'].find { |field| field['name'] == 'id' }['value'].to_s
|
22
|
-
product: order['value'].find { |field| field['name'] == 'product' }['value']
|
21
|
+
product_id: order['value'].find { |field| field['name'] == 'id' }['value'].to_s
|
23
22
|
}
|
24
23
|
end
|
25
24
|
portfolio.select { |entry| entry[:size] > 0 }
|
data/lib/degiro/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: degiro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Van Eyck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -92,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
|
96
|
-
rubygems_version: 2.6.11
|
95
|
+
rubygems_version: 3.0.1
|
97
96
|
signing_key:
|
98
97
|
specification_version: 4
|
99
98
|
summary: Ruby Client for the unofficial DeGiro API
|