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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3fdf274ef1ecfe828dbd3bce645f48902385ecc3
4
- data.tar.gz: a9bcf0d7f10142414210e1959cbb122e8e5622fb
2
+ SHA256:
3
+ metadata.gz: 0eb7bd4ae0b88684e4cd8daa8281e4dbc0600b46fecb014fa5a179bda7613b0a
4
+ data.tar.gz: 1dd27d12ea53f6fe7d160555ef8f2c32e5b528b8c829e6751df1a5afa9cb4eb1
5
5
  SHA512:
6
- metadata.gz: 670df722f90df0bf0dc21220ebfaae01dfbcd5ff040a0bf110b97f8362655406e4ecb80302e3077c1ac306d67fc0257e839402b5ecff0eaf2d4f62882494a272
7
- data.tar.gz: 9c90dbb6cc8e70f7616a68e15a8d1f7f370f1de79bfc83d3f8c3f4b885f3159a4fd69e9d9be186997016b968a522f802236a24719c0b5c493c9d114956173e9d
6
+ metadata.gz: a24ff3c6e66b448b2509c98ca1760b28fb8460beed53ebed4af68694f27bbb8a5898f6dd8f28f4e7751204596fa098fde728d4ebf8a4bce7093fffcfcb6207f6
7
+ data.tar.gz: aacd072df6aa6d4139107186494da4e31a58203b5eed3e38ca9533d8403d76ee00648097548290a76799dc93df422daf13a3e2c701ce1ad5cb88ce9b3afdb6ef
@@ -13,7 +13,10 @@ module DeGiro
13
13
  class Client
14
14
  extend Forwardable
15
15
 
16
- def_delegators :@create_order, :create_buy_order, :create_sell_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
@@ -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
@@ -2,31 +2,53 @@ require 'json'
2
2
 
3
3
  module DeGiro
4
4
  class CreateOrder
5
- BUY_SELL = { buy: 0, sell: 1 }.freeze
6
- ORDER_TYPES = { limited: 0, stop_limited: 1, market_order: 2, stop_loss: 3 }.freeze
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 create_buy_order(product_id:, size:, price:)
14
- order = order(BUY_SELL[:buy], product_id, size, price)
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 create_sell_order(product_id:, size:, price:)
20
- order = order(BUY_SELL[:sell], product_id, size, price)
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 order(type, product_id, size, price)
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
- buysell: type,
51
+ buySell: type,
30
52
  orderType: ORDER_TYPES[:limited],
31
53
  productId: product_id,
32
54
  size: size,
@@ -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 }
@@ -1,3 +1,3 @@
1
1
  module DeGiro
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
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.1
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: 2017-11-28 00:00:00.000000000 Z
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
- rubyforge_project:
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