Class: DeGiro::CreateOrder
- Inherits:
-
Object
- Object
- DeGiro::CreateOrder
- Defined in:
- lib/degiro/create_order.rb
Constant Summary collapse
- BUY_SELL =
{ buy: 'BUY', sell: 'SELL' }.freeze
- ORDER_TYPES =
{ limited: 0, stop_limited: 1, market: 2, stop_loss: 3 }.freeze
- TIME_TYPES =
{ day: 1, permanent: 3 }.freeze
Instance Method Summary collapse
- #create_limit_buy_order(product_id:, size:, price:) ⇒ Object
- #create_limit_sell_order(product_id:, size:, price:) ⇒ Object
- #create_market_buy_order(product_id:, size:) ⇒ Object
- #create_market_sell_order(product_id:, size:) ⇒ Object
-
#initialize(connection) ⇒ CreateOrder
constructor
A new instance of CreateOrder.
Constructor Details
#initialize(connection) ⇒ CreateOrder
Returns a new instance of CreateOrder.
9 10 11 |
# File 'lib/degiro/create_order.rb', line 9 def initialize(connection) @connection = connection end |
Instance Method Details
#create_limit_buy_order(product_id:, size:, price:) ⇒ Object
25 26 27 28 29 |
# File 'lib/degiro/create_order.rb', line 25 def create_limit_buy_order(product_id:, size:, price:) order = limit_order(BUY_SELL[:buy], product_id, size, price) confirmation_id = JSON.parse(check_order(order).body)['data']['confirmationId'] confirm_order(order, confirmation_id) end |
#create_limit_sell_order(product_id:, size:, price:) ⇒ Object
31 32 33 34 35 |
# File 'lib/degiro/create_order.rb', line 31 def create_limit_sell_order(product_id:, size:, price:) order = limit_order(BUY_SELL[:sell], product_id, size, price) confirmation_id = JSON.parse(check_order(order).body)['data']['confirmationId'] confirm_order(order, confirmation_id) end |
#create_market_buy_order(product_id:, size:) ⇒ Object
13 14 15 16 17 |
# File 'lib/degiro/create_order.rb', line 13 def create_market_buy_order(product_id:, size:) order = market_order(BUY_SELL[:buy], product_id, size) confirmation_id = JSON.parse(check_order(order).body)['data']['confirmationId'] confirm_order(order, confirmation_id) end |
#create_market_sell_order(product_id:, size:) ⇒ Object
19 20 21 22 23 |
# File 'lib/degiro/create_order.rb', line 19 def create_market_sell_order(product_id:, size:) order = market_order(BUY_SELL[:sell], product_id, size) confirmation_id = JSON.parse(check_order(order).body)['data']['confirmationId'] confirm_order(order, confirmation_id) end |