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_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.
-
#guaranteed_stop ⇒ Boolean
The guaranteed_stop attribute.
-
#limit_distance ⇒ Integer
The limit_distance attribute.
-
#limited_risk_premium ⇒ LimitedRiskPremium
The limited_risk_premium 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.
-
#reload ⇒ Object
Reloads this working order’s attributes by re-querying the IG Markets API.
-
#stop_distance ⇒ Integer
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, attribute_type, attribute_value_allowed?, defined_attribute_names, deprecated_attribute, #initialize, #initialize_copy, #inspect, #to_h, valid_attribute?
Constructor Details
This class inherits a constructor from IGMarkets::Model
Instance Method Details
#created_date_utc ⇒ Time
The created_date_utc attribute.
5 |
# File 'lib/ig_markets/working_order.rb', line 5 attribute :created_date_utc, Time, format: '%FT%T' |
#currency_code ⇒ String
The currency_code attribute.
6 |
# File 'lib/ig_markets/working_order.rb', line 6 attribute :currency_code, String, regex: Regex::CURRENCY |
#deal_id ⇒ Object
The deal_id attribute.
7 |
# File 'lib/ig_markets/working_order.rb', line 7 attribute :deal_id |
#delete ⇒ String
Deletes this working order.
34 35 36 |
# File 'lib/ig_markets/working_order.rb', line 34 def delete @dealing_platform.session.delete("workingorders/otc/#{deal_id}", nil, API_V2).fetch(:deal_reference) end |
#direction ⇒ Symbol
The direction attribute.
8 |
# File 'lib/ig_markets/working_order.rb', line 8 attribute :direction, Symbol, allowed_values: %i[buy sell] |
#dma ⇒ Boolean
The dma attribute.
9 |
# File 'lib/ig_markets/working_order.rb', line 9 attribute :dma, Boolean |
#epic ⇒ String
The epic attribute.
10 |
# File 'lib/ig_markets/working_order.rb', line 10 attribute :epic, String, regex: Regex::EPIC |
#good_till_date ⇒ Time
The good_till_date attribute.
11 |
# File 'lib/ig_markets/working_order.rb', line 11 attribute :good_till_date, Time, format: '%Y/%m/%d %R' |
#guaranteed_stop ⇒ Boolean
The guaranteed_stop attribute.
12 |
# File 'lib/ig_markets/working_order.rb', line 12 attribute :guaranteed_stop, Boolean |
#limit_distance ⇒ Integer
The limit_distance attribute.
13 |
# File 'lib/ig_markets/working_order.rb', line 13 attribute :limit_distance, Integer |
#limited_risk_premium ⇒ LimitedRiskPremium
The limited_risk_premium attribute.
14 |
# File 'lib/ig_markets/working_order.rb', line 14 attribute :limited_risk_premium, LimitedRiskPremium |
#market ⇒ MarketOverview
The market attribute.
21 |
# File 'lib/ig_markets/working_order.rb', line 21 attribute :market, MarketOverview |
#order_level ⇒ Float
The order_level attribute.
15 |
# File 'lib/ig_markets/working_order.rb', line 15 attribute :order_level, Float |
#order_size ⇒ Float
The order_size attribute.
16 |
# File 'lib/ig_markets/working_order.rb', line 16 attribute :order_size, Float |
#order_type ⇒ Symbol
The order_type attribute.
17 |
# File 'lib/ig_markets/working_order.rb', line 17 attribute :order_type, Symbol, allowed_values: %i[limit stop] |
#reload ⇒ Object
Reloads this working order’s attributes by re-querying the IG Markets API.
26 27 28 |
# File 'lib/ig_markets/working_order.rb', line 26 def reload self.attributes = @dealing_platform.working_orders[deal_id].attributes end |
#stop_distance ⇒ Integer
The stop_distance attribute.
18 |
# File 'lib/ig_markets/working_order.rb', line 18 attribute :stop_distance, Integer |
#time_in_force ⇒ Symbol
The time_in_force attribute.
19 |
# File 'lib/ig_markets/working_order.rb', line 19 attribute :time_in_force, Symbol, allowed_values: %i[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 their current values.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ig_markets/working_order.rb', line 53 def update(new_attributes) existing_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 } model = WorkingOrderUpdateAttributes.new existing_attributes, new_attributes model.validate body = RequestBodyFormatter.format model @dealing_platform.session.put("workingorders/otc/#{deal_id}", body, API_V2).fetch(:deal_reference) end |