Class: Em::Nordnet::Order
- Inherits:
-
Object
- Object
- Em::Nordnet::Order
- Defined in:
- lib/em-nordnet/order.rb
Constant Summary collapse
- BUY =
'BUY'.freeze
- SELL =
'SELL'.freeze
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#id ⇒ Object
Returns the value of attribute id.
-
#instrument ⇒ Object
Returns the value of attribute instrument.
-
#price ⇒ Object
Returns the value of attribute price.
-
#status ⇒ Object
Returns the value of attribute status.
-
#volume ⇒ Object
Returns the value of attribute volume.
Class Method Summary collapse
Instance Method Summary collapse
- #buy! ⇒ Object
-
#initialize(attributes = {}) ⇒ Order
constructor
A new instance of Order.
Constructor Details
#initialize(attributes = {}) ⇒ Order
Returns a new instance of Order.
26 27 28 29 30 31 32 33 |
# File 'lib/em-nordnet/order.rb', line 26 def initialize attributes={} self.id = attributes[:id] || attributes[:orderID] self.account = attributes[:account] self.instrument = attributes[:instrument] self.price = attributes[:price] self.volume = attributes[:volume] self.status = attributes[:status] end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
7 8 9 |
# File 'lib/em-nordnet/order.rb', line 7 def account @account end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/em-nordnet/order.rb', line 7 def id @id end |
#instrument ⇒ Object
Returns the value of attribute instrument.
7 8 9 |
# File 'lib/em-nordnet/order.rb', line 7 def instrument @instrument end |
#price ⇒ Object
Returns the value of attribute price.
7 8 9 |
# File 'lib/em-nordnet/order.rb', line 7 def price @price end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/em-nordnet/order.rb', line 7 def status @status end |
#volume ⇒ Object
Returns the value of attribute volume.
7 8 9 |
# File 'lib/em-nordnet/order.rb', line 7 def volume @volume end |
Class Method Details
.all(account_id) ⇒ Object
10 11 12 13 |
# File 'lib/em-nordnet/order.rb', line 10 def all account_id orders = Nordnet.api.orders(account_id) orders.map { |attributes| new attributes } end |
.buy(attributes = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/em-nordnet/order.rb', line 15 def buy attributes={} symbol, price, volume = attributes[:symbol], attributes[:price], attributes[:volume] instrument = Instrument.search(symbol).first account = attributes[:account] || Account.default order = Order.new account: account, instrument: instrument, price: price, volume: volume order.buy! end |