Class: IGMarkets::WorkingOrder

Inherits:
Model
  • Object
show all
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

#attributes

Instance Method Summary collapse

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_dateTime

The created_date attribute.

Returns:

  • (Time)


5
# File 'lib/ig_markets/working_order.rb', line 5

attribute :created_date, Time, format: '%Y/%m/%d %T:%L'

#created_date_utcTime

The created_date_utc attribute.

Returns:

  • (Time)


6
# File 'lib/ig_markets/working_order.rb', line 6

attribute :created_date_utc, Time, format: '%FT%T', time_zone: '+0000'

#currency_codeString

The currency_code attribute.

Returns:

  • (String)


7
# File 'lib/ig_markets/working_order.rb', line 7

attribute :currency_code, String, regex: Regex::CURRENCY

#deal_idObject

The deal_id attribute.

Returns:



8
# File 'lib/ig_markets/working_order.rb', line 8

attribute :deal_id

#deleteString

Deletes this working order.

Returns:



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

#directionSymbol

The direction attribute.

Returns:

  • (Symbol)


9
# File 'lib/ig_markets/working_order.rb', line 9

attribute :direction, Symbol, allowed_values: [:buy, :sell]

#dmaBoolean

The dma attribute.

Returns:



10
# File 'lib/ig_markets/working_order.rb', line 10

attribute :dma, Boolean

#epicString

The epic attribute.

Returns:

  • (String)


11
# File 'lib/ig_markets/working_order.rb', line 11

attribute :epic, String, regex: Regex::EPIC

#good_till_dateTime

The good_till_date attribute.

Returns:

  • (Time)


12
# File 'lib/ig_markets/working_order.rb', line 12

attribute :good_till_date, Time, format: '%Y/%m/%d %R', time_zone: '+0000'

#good_till_date_isoTime

The good_till_date_iso attribute.

Returns:

  • (Time)


13
# File 'lib/ig_markets/working_order.rb', line 13

attribute :good_till_date_iso, Time, format: '%FT%R', time_zone: '+0000'

#guaranteed_stopBoolean

The guaranteed_stop attribute.

Returns:



14
# File 'lib/ig_markets/working_order.rb', line 14

attribute :guaranteed_stop, Boolean

#limit_distanceFixnum

The limit_distance attribute.

Returns:

  • (Fixnum)


15
# File 'lib/ig_markets/working_order.rb', line 15

attribute :limit_distance, Fixnum

#marketMarketOverview

The market attribute.

Returns:



22
# File 'lib/ig_markets/working_order.rb', line 22

attribute :market, MarketOverview

#order_levelFloat

The order_level attribute.

Returns:

  • (Float)


16
# File 'lib/ig_markets/working_order.rb', line 16

attribute :order_level, Float

#order_sizeFloat

The order_size attribute.

Returns:

  • (Float)


17
# File 'lib/ig_markets/working_order.rb', line 17

attribute :order_size, Float

#order_typeSymbol

The order_type attribute.

Returns:

  • (Symbol)


18
# File 'lib/ig_markets/working_order.rb', line 18

attribute :order_type, Symbol, allowed_values: [:limit, :stop]

#stop_distanceFixnum

The stop_distance attribute.

Returns:

  • (Fixnum)


19
# File 'lib/ig_markets/working_order.rb', line 19

attribute :stop_distance, Fixnum

#time_in_forceSymbol

The time_in_force attribute.

Returns:

  • (Symbol)


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.

Parameters:

Options Hash (new_attributes):

  • :good_till_date (Time)
  • :level (Float)
  • :limit_distance (Fixnum)
  • :stop_distance (Fixnum)
  • :time_in_force (:good_till_cancelled, :good_till_date)
  • :type (:limit, :stop)

Returns:



46
47
48
49
50
51
52
53
54
# File 'lib/ig_markets/working_order.rb', line 46

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

  payload = PayloadFormatter.format WorkingOrderUpdateAttributes.new new_attributes

  @dealing_platform.session.put("workingorders/otc/#{deal_id}", payload, API_V1).fetch(:deal_reference)
end