Class: IGMarkets::WorkingOrder
- Defined in:
- lib/ig_markets/working_order.rb
Overview
Contains details on a working order. Returned by DealingPlatform::WorkingOrderMethods#all and DealingPlatform::WorkingOrderMethods#[].
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#created_date ⇒ Time
The created_date attribute.
-
#created_date_utc ⇒ Time
The created_date_utc attribute.
-
#currency_code ⇒ String
The currency_code attribute.
-
#deal_id ⇒ Object
The deal_id attribute.
-
#delete ⇒ String
Deletes this working order.
-
#direction ⇒ Symbol
The direction attribute.
-
#dma ⇒ Boolean
The dma attribute.
-
#epic ⇒ String
The epic attribute.
-
#good_till_date ⇒ Time
The good_till_date attribute.
-
#good_till_date_iso ⇒ Time
The good_till_date_iso attribute.
-
#guaranteed_stop ⇒ Boolean
The guaranteed_stop attribute.
-
#limit_distance ⇒ Fixnum
The limit_distance attribute.
-
#market ⇒ MarketOverview
The market attribute.
-
#order_level ⇒ Float
The order_level attribute.
-
#order_size ⇒ Float
The order_size attribute.
-
#order_type ⇒ Symbol
The order_type attribute.
-
#stop_distance ⇒ Fixnum
The stop_distance attribute.
-
#time_in_force ⇒ Symbol
The time_in_force attribute.
-
#update(new_attributes) ⇒ String
Updates this working order.
Methods inherited from Model
#==, allowed_values, attribute, defined_attribute_names, from, #initialize, #inspect
Constructor Details
This class inherits a constructor from IGMarkets::Model
Instance Method Details
#created_date ⇒ Time
The created_date attribute.
5 |
# File 'lib/ig_markets/working_order.rb', line 5 attribute :created_date, Time, format: '%Y/%m/%d %T:%L' |
#created_date_utc ⇒ Time
The created_date_utc attribute.
6 |
# File 'lib/ig_markets/working_order.rb', line 6 attribute :created_date_utc, Time, format: '%FT%T' |
#currency_code ⇒ String
The currency_code attribute.
7 |
# File 'lib/ig_markets/working_order.rb', line 7 attribute :currency_code, String, regex: Regex::CURRENCY |
#deal_id ⇒ Object
The deal_id attribute.
8 |
# File 'lib/ig_markets/working_order.rb', line 8 attribute :deal_id |
#delete ⇒ String
Deletes this working order.
28 29 30 |
# File 'lib/ig_markets/working_order.rb', line 28 def delete @dealing_platform.session.delete("workingorders/otc/#{deal_id}", {}, API_V1).fetch(:deal_reference) end |
#direction ⇒ Symbol
The direction attribute.
9 |
# File 'lib/ig_markets/working_order.rb', line 9 attribute :direction, Symbol, allowed_values: [:buy, :sell] |
#dma ⇒ Boolean
The dma attribute.
10 |
# File 'lib/ig_markets/working_order.rb', line 10 attribute :dma, Boolean |
#epic ⇒ String
The epic attribute.
11 |
# File 'lib/ig_markets/working_order.rb', line 11 attribute :epic, String, regex: Regex::EPIC |
#good_till_date ⇒ Time
The good_till_date attribute.
12 |
# File 'lib/ig_markets/working_order.rb', line 12 attribute :good_till_date, Time, format: '%Y/%m/%d %R' |
#good_till_date_iso ⇒ Time
The good_till_date_iso attribute.
13 |
# File 'lib/ig_markets/working_order.rb', line 13 attribute :good_till_date_iso, Time, format: '%FT%R' |
#guaranteed_stop ⇒ Boolean
The guaranteed_stop attribute.
14 |
# File 'lib/ig_markets/working_order.rb', line 14 attribute :guaranteed_stop, Boolean |
#limit_distance ⇒ Fixnum
The limit_distance attribute.
15 |
# File 'lib/ig_markets/working_order.rb', line 15 attribute :limit_distance, Fixnum |
#market ⇒ MarketOverview
The market attribute.
22 |
# File 'lib/ig_markets/working_order.rb', line 22 attribute :market, MarketOverview |
#order_level ⇒ Float
The order_level attribute.
16 |
# File 'lib/ig_markets/working_order.rb', line 16 attribute :order_level, Float |
#order_size ⇒ Float
The order_size attribute.
17 |
# File 'lib/ig_markets/working_order.rb', line 17 attribute :order_size, Float |
#order_type ⇒ Symbol
The order_type attribute.
18 |
# File 'lib/ig_markets/working_order.rb', line 18 attribute :order_type, Symbol, allowed_values: [:limit, :stop] |
#stop_distance ⇒ Fixnum
The stop_distance attribute.
19 |
# File 'lib/ig_markets/working_order.rb', line 19 attribute :stop_distance, Fixnum |
#time_in_force ⇒ Symbol
The time_in_force attribute.
20 |
# File 'lib/ig_markets/working_order.rb', line 20 attribute :time_in_force, Symbol, allowed_values: [:good_till_cancelled, :good_till_date] |
#update(new_attributes) ⇒ String
Updates this working order. No attributes are mandatory, and any attributes not specified will be kept at the current value.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ig_markets/working_order.rb', line 45 def update(new_attributes) new_attributes = { good_till_date: good_till_date, level: order_level, limit_distance: limit_distance, stop_distance: stop_distance, time_in_force: time_in_force, type: order_type }.merge new_attributes new_attributes[:time_in_force] = new_attributes[:good_till_date] ? :good_till_date : :good_till_cancelled payload = PayloadFormatter.format WorkingOrderUpdateAttributes.new new_attributes @dealing_platform.session.put("workingorders/otc/#{deal_id}", payload, API_V1).fetch(:deal_reference) end |