ig_markets 0.22 → 0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fda25b08bcbcfd1c57b25ba76965c792d3966af
4
- data.tar.gz: 63e99c58c1d6ae1fca403f063d88a0279b35aec3
3
+ metadata.gz: 207f951a5be987c96debc33292afecc695435241
4
+ data.tar.gz: ebd1837c2f2f99c7c65b9a3199d7a247cbe768d5
5
5
  SHA512:
6
- metadata.gz: d251e98be9191b08e0a684956ea73ae6c48815595b2e734ce9042210cb717686ae8d032ddbe4cce2a0d676ad6541f25ac901aeac9d5d7acd09d207e14d3d3045
7
- data.tar.gz: f160337bc572f79dc1f16d00a925d4af95507abeb1f38bce7084280c72d8f2723f59ad56a8295d6fd1c26ff68517e0f7d75c34e0bf474b7ae8d1cd33740d60dd
6
+ metadata.gz: 775d3e912b35c17cc57deed6dd6827beb52491e5ac204c4ae68c0e4a8602db9e1175e701936285951200c9edf4beb180f2823f646f1e3364d2f1d151561bfab1
7
+ data.tar.gz: 1e82cb866071f438b19fb75a60557eaefedf2eb35c64a3a72fc35c18251adc9e8ebc348f97712146a24bcf19f6399f7f14c46a30720b90e233a4cf6c01b81654
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # IG Markets Changelog
2
2
 
3
+ ### 0.23 — October 19, 2016
4
+
5
+ - Use `Integer` instead of `Fixnum` in preparation for Ruby 2.4
6
+ - Fixed documentation warnings found by Inch CI
7
+
3
8
  ### 0.22 — October 3, 2016
4
9
 
5
10
  - The `curses` gem is no longer a dependency because it can be difficult to install on Windows, it now has to be
@@ -23,14 +23,14 @@ module IGMarkets
23
23
  attribute :good_till_date
24
24
  attribute :guaranteed_stop, Boolean
25
25
  attribute :level, Float
26
- attribute :limit_distance, Fixnum
26
+ attribute :limit_distance, Integer
27
27
  attribute :limit_level, Float
28
28
  attribute :market_name
29
29
  attribute :size
30
- attribute :stop_distance, Fixnum
30
+ attribute :stop_distance, Integer
31
31
  attribute :stop_level, Float
32
32
  attribute :trailing_step, Float
33
- attribute :trailing_stop_distance, Fixnum
33
+ attribute :trailing_stop_distance, Integer
34
34
  end
35
35
 
36
36
  attribute :channel, Symbol, allowed_values: [:dealer, :mobile, :public_fix_api, :public_web_api, :system, :web]
@@ -3,13 +3,13 @@ module IGMarkets
3
3
  class Application < Model
4
4
  attribute :allow_equities, Boolean
5
5
  attribute :allow_quote_orders, Boolean
6
- attribute :allowance_account_historical_data, Fixnum
7
- attribute :allowance_account_overall, Fixnum
8
- attribute :allowance_account_trading, Fixnum
9
- attribute :allowance_application_overall, Fixnum
6
+ attribute :allowance_account_historical_data, Integer
7
+ attribute :allowance_account_overall, Integer
8
+ attribute :allowance_account_trading, Integer
9
+ attribute :allowance_application_overall, Integer
10
10
  attribute :api_key
11
11
  attribute :client_id
12
- attribute :concurrent_subscriptions_limit, Fixnum
12
+ attribute :concurrent_subscriptions_limit, Integer
13
13
  attribute :created_date, Time, format: '%Q'
14
14
  attribute :fast_markets_settlement_price_enabled, Boolean
15
15
  attribute :id
@@ -18,7 +18,7 @@ module IGMarkets
18
18
  attribute :expiry, Date, nil_if: %w(- DFB), format: ['%d-%b-%y', '%b-%y']
19
19
  attribute :guaranteed_stop, Boolean
20
20
  attribute :level, Float
21
- attribute :limit_distance, Fixnum
21
+ attribute :limit_distance, Integer
22
22
  attribute :limit_level, Float
23
23
  attribute :profit, Float
24
24
  attribute :profit_currency, String, regex: Regex::CURRENCY
@@ -44,7 +44,7 @@ module IGMarkets
44
44
  :trailing_stop_not_allowed, :unknown, :wrong_side_of_market]
45
45
  attribute :size, Float
46
46
  attribute :status, Symbol, allowed_values: [:amended, :closed, :deleted, :open, :partially_closed]
47
- attribute :stop_distance, Fixnum
47
+ attribute :stop_distance, Integer
48
48
  attribute :stop_level, Float
49
49
  attribute :trailing_stop, Boolean
50
50
  end
@@ -40,7 +40,7 @@ module IGMarkets
40
40
  # @option attributes [Boolean] :force_open Whether a force open is required. Defaults to `false`.
41
41
  # @option attributes [Boolean] :guaranteed_stop Whether a guaranteed stop is required. Defaults to `false`.
42
42
  # @option attributes [Float] :level Required if and only if `:order_type` is `:limit` or `:quote`.
43
- # @option attributes [Fixnum] :limit_distance The distance away in pips to place the limit. If this is set then
43
+ # @option attributes [Integer] :limit_distance The distance away in pips to place the limit. If this is set then
44
44
  # `:limit_level` must be `nil`. Optional.
45
45
  # @option attributes [Float] :limit_level The limit level. If this is set then `:limit_distance` must be `nil`.
46
46
  # Optional.
@@ -50,7 +50,7 @@ module IGMarkets
50
50
  # Defaults to `:market`.
51
51
  # @option attributes [String] :quote_id The Lightstreamer quote ID. Required when `:order_type` is `:quote`.
52
52
  # @option attributes [Float] :size The size of the position to create. Required.
53
- # @option attributes [Fixnum] :stop_distance The distance away in pips to place the stop. If this is set then
53
+ # @option attributes [Integer] :stop_distance The distance away in pips to place the stop. If this is set then
54
54
  # `:stop_level` must be `nil`. Optional.
55
55
  # @option attributes [Float] :stop_level The stop level. If this is set then `:stop_distance` must be `nil`.
56
56
  # Optional.
@@ -62,7 +62,7 @@ module IGMarkets
62
62
  # `:market` (the default) then `:time_in_force` will be automatically set to
63
63
  # `:execute_and_eliminate`.
64
64
  # @option attributes [Boolean] :trailing_stop Whether to use a trailing stop. Defaults to false. Optional.
65
- # @option attributes [Fixnum] :trailing_stop_increment The increment step in pips for the trailing stop. Required
65
+ # @option attributes [Integer] :trailing_stop_increment The increment step in pips for the trailing stop. Required
66
66
  # when `:trailing_stop` is `true`.
67
67
  #
68
68
  # @return [String] The resulting deal reference, use {DealingPlatform#deal_confirmation} to check the result of
@@ -86,16 +86,16 @@ module IGMarkets
86
86
  attribute :force_open, Boolean
87
87
  attribute :guaranteed_stop, Boolean
88
88
  attribute :level, Float
89
- attribute :limit_distance, Fixnum
89
+ attribute :limit_distance, Integer
90
90
  attribute :limit_level, Float
91
91
  attribute :order_type, Symbol, allowed_values: [:limit, :market, :quote]
92
92
  attribute :quote_id
93
93
  attribute :size, Float
94
- attribute :stop_distance, Fixnum
94
+ attribute :stop_distance, Integer
95
95
  attribute :stop_level, Float
96
96
  attribute :time_in_force, Symbol, allowed_values: [:execute_and_eliminate, :fill_or_kill]
97
97
  attribute :trailing_stop, Boolean
98
- attribute :trailing_stop_increment, Fixnum
98
+ attribute :trailing_stop_increment, Integer
99
99
 
100
100
  def initialize(attributes = {})
101
101
  super
@@ -137,10 +137,9 @@ module IGMarkets
137
137
  if trailing_stop
138
138
  raise ArgumentError, 'do not set stop_level when trailing_stop is true' if stop_level
139
139
  raise ArgumentError, 'set stop_distance when trailing_stop is true' unless stop_distance
140
- end
141
-
142
- if trailing_stop == trailing_stop_increment.nil?
143
- raise ArgumentError, 'set trailing_stop_increment if and only if trailing_stop is true'
140
+ raise ArgumentError, 'set trailing_stop_increment when trailing_stop is true' unless trailing_stop_increment
141
+ elsif trailing_stop_increment
142
+ raise ArgumentError, 'do not set trailing_stop_increment when trailing_stop is false'
144
143
  end
145
144
  end
146
145
 
@@ -152,9 +151,9 @@ module IGMarkets
152
151
 
153
152
  # Checks that attributes associated with the guaranteed stop are valid.
154
153
  def validate_guaranteed_stop_constraints
155
- if guaranteed_stop && !(stop_level.nil? ^ stop_distance.nil?)
156
- raise ArgumentError, 'set exactly one of stop_level or stop_distance when guaranteed_stop is true'
157
- end
154
+ return if !guaranteed_stop || (stop_level.nil? ^ stop_distance.nil?)
155
+
156
+ raise ArgumentError, 'set exactly one of stop_level or stop_distance when guaranteed_stop is true'
158
157
  end
159
158
  end
160
159
 
@@ -44,12 +44,12 @@ module IGMarkets
44
44
  # the working order will remain until it is cancelled.
45
45
  # @option attributes [Boolean] :guaranteed_stop Whether a guaranteed stop is required. Defaults to `false`.
46
46
  # @option attributes [Float] :level The level at which the order will be triggered. Required.
47
- # @option attributes [Fixnum] :limit_distance The distance away in pips to place the limit. If this is set then
47
+ # @option attributes [Integer] :limit_distance The distance away in pips to place the limit. If this is set then
48
48
  # the `:limit_level` option must be omitted. Optional.
49
49
  # @option attributes [Float] :limit_level The level at which to place the limit. If this is set then the
50
50
  # `:limit_distance` option must be omitted. Optional.
51
51
  # @option attributes [Float] :size The size of the working order. Required.
52
- # @option attributes [Fixnum] :stop_distance The distance away in pips to place the stop. If this is set then the
52
+ # @option attributes [Integer] :stop_distance The distance away in pips to place the stop. If this is set then the
53
53
  # `:stop_level` option must be omitted. Optional.
54
54
  # @option attributes [Float] :stop_level The level at which to place the stop. If this is set then the
55
55
  # `:stop_distance` option must be omitted. Optional.
@@ -79,10 +79,10 @@ module IGMarkets
79
79
  attribute :good_till_date, Time, format: '%Y/%m/%d %R:%S'
80
80
  attribute :guaranteed_stop, Boolean
81
81
  attribute :level, Float
82
- attribute :limit_distance, Fixnum
82
+ attribute :limit_distance, Integer
83
83
  attribute :limit_level, Float
84
84
  attribute :size, Float
85
- attribute :stop_distance, Fixnum
85
+ attribute :stop_distance, Integer
86
86
  attribute :stop_level, Float
87
87
  attribute :time_in_force, Symbol, allowed_values: [:good_till_cancelled, :good_till_date]
88
88
  attribute :type, Symbol, allowed_values: [:limit, :stop]
@@ -19,7 +19,7 @@ module IGMarkets
19
19
  # Returns a formatted string for the specified currency amount and currency. Two decimal places are used for all
20
20
  # currencies except the Japanese Yen.
21
21
  #
22
- # @param [Float, Fixnum] amount The currency amount to format.
22
+ # @param [Float, Integer] amount The currency amount to format.
23
23
  # @param [String] currency The currency.
24
24
  #
25
25
  # @return [String] The formatted currency amount, e.g. `"USD -130.40"`, `"AUD 539.10"`, `"JPY 3560"`.
@@ -35,7 +35,7 @@ module IGMarkets
35
35
 
36
36
  # Returns a formatted string for the specified number of seconds in the format `[<hours>:]<minutes>:<seconds>`.
37
37
  #
38
- # @param [Fixnum] value The number of seconds to format.
38
+ # @param [Integer] value The number of seconds to format.
39
39
  #
40
40
  # @return [String]
41
41
  def seconds(value)
@@ -5,21 +5,21 @@ module IGMarkets
5
5
  class Metadata < Model
6
6
  # Contains details on the remaining allowance for looking up historical prices. Used by {#allowance}.
7
7
  class Allowance < Model
8
- attribute :allowance_expiry, Fixnum
9
- attribute :remaining_allowance, Fixnum
10
- attribute :total_allowance, Fixnum
8
+ attribute :allowance_expiry, Integer
9
+ attribute :remaining_allowance, Integer
10
+ attribute :total_allowance, Integer
11
11
  end
12
12
 
13
13
  # Contains details on paging status for a historical price lookup. Used by {#page_data}.
14
14
  class PageData < Model
15
- attribute :page_number, Fixnum
16
- attribute :page_size, Fixnum
17
- attribute :total_pages, Fixnum
15
+ attribute :page_number, Integer
16
+ attribute :page_size, Integer
17
+ attribute :total_pages, Integer
18
18
  end
19
19
 
20
20
  attribute :allowance, Allowance
21
21
  attribute :page_data, PageData
22
- attribute :size, Fixnum
22
+ attribute :size, Integer
23
23
  end
24
24
 
25
25
  # Contains details on a single historical price snapshot. Used by {#prices}.
@@ -55,7 +55,7 @@ module IGMarkets
55
55
  # @option options [:minute, :minute_2, :minute_3, :minute_5, :minute_10, :minute_15, :minute_30, :hour, :hour_2,
56
56
  # :hour_3, :hour_4, :day, :week, :month] :resolution The resolution of the prices to return.
57
57
  # Required.
58
- # @option options [Fixnum] :number The number of historical prices to return. If this is specified then the `:from`
58
+ # @option options [Integer] :number The number of historical prices to return. If this is specified then the `:from`
59
59
  # and `:to` options must not be specified.
60
60
  # @option options [Time] :from The start of the period to return prices for.
61
61
  # @option options [Time] :to The end of the period to return prices for.
@@ -80,9 +80,9 @@ module IGMarkets
80
80
 
81
81
  raise ArgumentError, 'resolution is invalid' unless resolutions.include? options[:resolution]
82
82
 
83
- if options.keys != [:resolution, :from, :to] && options.keys != [:resolution, :number]
84
- raise ArgumentError, 'options must specify either :number or :from and :to'
85
- end
83
+ return if options.keys == [:resolution, :from, :to] || options.keys == [:resolution, :number]
84
+
85
+ raise ArgumentError, 'options must specify either :number or :from and :to'
86
86
  end
87
87
 
88
88
  # Returns the API response to a request for historical prices.
@@ -76,14 +76,10 @@ module IGMarkets
76
76
  end
77
77
 
78
78
  class << self
79
- # A hash containing details of all attributes that have been defined on this model.
80
- #
81
- # @return [Hash]
79
+ # @return [Hash] a hash containing details of all attributes that have been defined on this model.
82
80
  attr_accessor :defined_attributes
83
81
 
84
- # The names of the deprecated attributes on this model.
85
- #
86
- # @return [Array]
82
+ # @return [Array] the names of the deprecated attributes on this model.
87
83
  attr_accessor :deprecated_attributes
88
84
 
89
85
  # Returns the names of all currently defined attributes for this model.
@@ -145,7 +141,7 @@ module IGMarkets
145
141
  # Defines setter and getter instance methods and a sanitizer class method for a new attribute on this class.
146
142
  #
147
143
  # @param [Symbol] name The name of the new attribute.
148
- # @param [Boolean, String, Date, Time, Fixnum, Float, Symbol, Model] type The attribute's type.
144
+ # @param [Boolean, String, Date, Time, Integer, Float, Symbol, Model] type The attribute's type.
149
145
  # @param [Hash] options The configuration options for the new attribute.
150
146
  # @option options [Array] :allowed_values The set of values that this attribute is allowed to be set to. An
151
147
  # attempt to set this attribute to a value not in this list will raise `ArgumentError`. Optional.
@@ -153,7 +149,7 @@ module IGMarkets
153
149
  # @option options [Regexp] :regex When `type` is `String` only values matching this regex will be allowed.
154
150
  # Optional.
155
151
  # @option options [String] :format When `type` is `Date` or `Time` this specifies the format or formats for
156
- # parsing String and `Fixnum` instances assigned to this attribute.
152
+ # parsing String and `Integer` instances assigned to this attribute.
157
153
  #
158
154
  # @macro [attach] attribute
159
155
  # The $1 attribute.
@@ -5,7 +5,7 @@ module IGMarkets
5
5
  private
6
6
 
7
7
  def typecaster_for(type)
8
- if [Boolean, String, Fixnum, Float, Symbol, Date, Time].include? type
8
+ if [Boolean, String, Integer, Float, Symbol, Date, Time].include? type
9
9
  method "typecaster_#{type.to_s.gsub(/\AIGMarkets::/, '').downcase}"
10
10
  elsif type
11
11
  lambda do |value, _options, name|
@@ -35,7 +35,7 @@ module IGMarkets
35
35
  value.to_s
36
36
  end
37
37
 
38
- def typecaster_fixnum(value, _options, _name)
38
+ def typecaster_integer(value, _options, _name)
39
39
  return nil if value.nil?
40
40
 
41
41
  value.to_s.to_i
@@ -74,7 +74,7 @@ module IGMarkets
74
74
  end
75
75
 
76
76
  def typecaster_time(value, options, name)
77
- if value.is_a?(String) || value.is_a?(Fixnum)
77
+ if value.is_a?(String) || value.is_a?(Integer)
78
78
  parse_formatted_time_value value.to_s, options, name
79
79
  else
80
80
  value
@@ -14,7 +14,7 @@ module IGMarkets
14
14
  attribute :size, Float
15
15
  attribute :stop_level, Float
16
16
  attribute :trailing_step, Float
17
- attribute :trailing_stop_distance, Fixnum
17
+ attribute :trailing_stop_distance, Integer
18
18
 
19
19
  attribute :market, MarketOverview
20
20
 
@@ -106,8 +106,8 @@ module IGMarkets
106
106
  # @option new_attributes [Float] :limit_level The new limit level for this position.
107
107
  # @option new_attributes [Float] :stop_level The new stop level for this position.
108
108
  # @option new_attributes [Boolean] :trailing_stop Whether to use a trailing stop for this position.
109
- # @option new_attributes [Fixnum] :trailing_stop_distance The distance away in pips to place the trailing stop.
110
- # @option new_attributes [Fixnum] :trailing_stop_increment The step increment to use for the trailing stop.
109
+ # @option new_attributes [Integer] :trailing_stop_distance The distance away in pips to place the trailing stop.
110
+ # @option new_attributes [Integer] :trailing_stop_increment The step increment to use for the trailing stop.
111
111
  #
112
112
  # @return [String] The deal reference of the update operation. Use {DealingPlatform#deal_confirmation} to check
113
113
  # the result of the position update.
@@ -133,9 +133,9 @@ module IGMarkets
133
133
  raise ArgumentError, 'set quote_id if and only if order_type is :quote'
134
134
  end
135
135
 
136
- if [:limit, :quote].include?(attributes[:order_type]) == attributes[:level].nil?
137
- raise ArgumentError, 'set level if and only if order_type is :limit or :quote'
138
- end
136
+ return unless [:limit, :quote].include?(attributes[:order_type]) == attributes[:level].nil?
137
+
138
+ raise ArgumentError, 'set level if and only if order_type is :limit or :quote'
139
139
  end
140
140
 
141
141
  # Internal model used by {#close}.
@@ -176,8 +176,8 @@ module IGMarkets
176
176
  attribute :limit_level, Float
177
177
  attribute :stop_level, Float
178
178
  attribute :trailing_stop, Boolean
179
- attribute :trailing_stop_distance, Fixnum
180
- attribute :trailing_stop_increment, Fixnum
179
+ attribute :trailing_stop_distance, Integer
180
+ attribute :trailing_stop_increment, Integer
181
181
  end
182
182
 
183
183
  private_constant :PositionCloseAttributes, :PositionUpdateAttributes
@@ -3,36 +3,24 @@ module IGMarkets
3
3
  # In order to sign in, {#username}, {#password}, {#api_key} and {#platform} must be set. {#platform} must be
4
4
  # either `:demo` or `:live` depending on which platform is being targeted.
5
5
  class Session
6
- # The username to use to authenticate this session.
7
- #
8
- # @return [String]
6
+ # @return [String] the username to use to authenticate this session.
9
7
  attr_accessor :username
10
8
 
11
- # The password to use to authenticate this session.
12
- #
13
- # @return [String]
9
+ # @return [String] the password to use to authenticate this session.
14
10
  attr_accessor :password
15
11
 
16
- # The API key to use to authenticate this session.
17
- #
18
- # @return [String]
12
+ # @return [String] the API key to use to authenticate this session.
19
13
  attr_accessor :api_key
20
14
 
21
- # The platform variant to log into for this session.
22
- #
23
- # @return [:demo, :live]
15
+ # @return [:demo, :live] The platform variant to log into for this session.
24
16
  attr_accessor :platform
25
17
 
26
- # The client session security access token for the currently logged in session, or `nil` if there is no active
27
- # session.
28
- #
29
- # @return [String]
18
+ # @return [String] the client session security access token for the currently logged in session, or `nil` if there
19
+ # is no active session.
30
20
  attr_reader :client_security_token
31
21
 
32
- # The account session security access token for the currently logged in session, or `nil` if there is no active
33
- # session.
34
- #
35
- # @return [String]
22
+ # @return [String] the account session security access token for the currently logged in session, or `nil` if there
23
+ # is no active session.
36
24
  attr_reader :x_security_token
37
25
 
38
26
  # Signs in to IG Markets using the values of {#username}, {#password}, {#api_key} and {#platform}. If an error
@@ -72,7 +60,7 @@ module IGMarkets
72
60
  #
73
61
  # @param [String] url The URL to send the POST request to.
74
62
  # @param [Hash, nil] body The body to include with the POST request, this will be encoded as JSON.
75
- # @param [Fixnum] api_version The API version to target.
63
+ # @param [Integer] api_version The API version to target.
76
64
  #
77
65
  # @return [Hash] The response from the IG Markets API.
78
66
  def post(url, body, api_version = API_V1)
@@ -82,7 +70,7 @@ module IGMarkets
82
70
  # Sends a GET request to the IG Markets API. If an error occurs then an {IGMarketsError} will be raised.
83
71
  #
84
72
  # @param [String] url The URL to send the GET request to.
85
- # @param [Fixnum] api_version The API version to target.
73
+ # @param [Integer] api_version The API version to target.
86
74
  #
87
75
  # @return [Hash] The response from the IG Markets API.
88
76
  def get(url, api_version = API_V1)
@@ -93,7 +81,7 @@ module IGMarkets
93
81
  #
94
82
  # @param [String] url The URL to send the PUT request to.
95
83
  # @param [Hash, nil] body The body to include with the PUT request, this will be encoded as JSON.
96
- # @param [Fixnum] api_version The API version to target.
84
+ # @param [Integer] api_version The API version to target.
97
85
  #
98
86
  # @return [Hash] The response from the IG Markets API.
99
87
  def put(url, body = nil, api_version = API_V1)
@@ -104,7 +92,7 @@ module IGMarkets
104
92
  #
105
93
  # @param [String] url The URL to send the DELETE request to.
106
94
  # @param [Hash, nil] body The body to include with the DELETE request, this will be encoded as JSON.
107
- # @param [Fixnum] api_version The API version to target.
95
+ # @param [Integer] api_version The API version to target.
108
96
  #
109
97
  # @return [Hash] The response from the IG Markets API.
110
98
  def delete(url, body = nil, api_version = API_V1)
@@ -17,7 +17,7 @@ module IGMarkets
17
17
  # Returns the number of seconds till when this sprint market position expires. This will be a negative number if
18
18
  # this sprint market position has expired.
19
19
  #
20
- # @return [Fixnum]
20
+ # @return [Integer]
21
21
  def seconds_till_expiry
22
22
  (expiry_time - Time.now).to_i
23
23
  end
@@ -5,21 +5,16 @@ module IGMarkets
5
5
  # making repeated calls to the REST API to get current account, position or working order details, and also avoids
6
6
  # running into API traffic allowance limits.
7
7
  class AccountState
8
- # The current state of the accounts. The balances will be updated automatically as new streaming data arrives.
9
- #
10
- # @return [Array<Account>]
8
+ # @return [Array<Account>] the current state of the accounts. The balances will be updated automatically as new
9
+ # streaming data arrives.
11
10
  attr_accessor :accounts
12
11
 
13
- # The current positions for this account. This set of positions will be updated automatically as new streaming
14
- # data arrives.
15
- #
16
- # @return [Array<Position>]
12
+ # @return [Array<Position>] the current positions for this account. This set of positions will be updated
13
+ # automatically as new streaming data arrives.
17
14
  attr_accessor :positions
18
15
 
19
- # The current working orders for this account. This set of working orders will be updated automatically as new
20
- # streaming data arrives.
21
- #
22
- # @return [Array<WorkingOrder>]
16
+ # @return [Array<WorkingOrder>] the current working orders for this account. This set of working orders will be
17
+ # updated automatically as new streaming data arrives.
23
18
  attr_accessor :working_orders
24
19
 
25
20
  # Initializes this account state with the specified dealing platform.
@@ -8,7 +8,7 @@ module IGMarkets
8
8
  attribute :bid_low, Float
9
9
  attribute :bid_open, Float
10
10
  attribute :cons_end, Boolean
11
- attribute :cons_tick_count, Fixnum
11
+ attribute :cons_tick_count, Integer
12
12
  attribute :day_high, Float
13
13
  attribute :day_low, Float
14
14
  attribute :day_net_chg_mid, Float
@@ -51,16 +51,18 @@ module IGMarkets
51
51
  CONSOLIDATED_CHART_DATA_REGEX = /^CHART:(.*):(SECOND|1MINUTE|5MINUTE|HOUR)$/
52
52
 
53
53
  def on_raw_data(subscription, item_name, item_data, new_data)
54
- on_account_data subscription, item_name, item_data, new_data if item_name =~ ACCOUNT_DATA_REGEX
55
- on_market_data subscription, item_name, item_data, new_data if item_name =~ MARKET_DATA_REGEX
56
- on_trade_data subscription, item_name, item_data, new_data if item_name =~ TRADE_DATA_REGEX
57
- on_chart_tick_data subscription, item_name, item_data, new_data if item_name =~ CHART_TICK_DATA_REGEX
58
-
59
- if item_name =~ CONSOLIDATED_CHART_DATA_REGEX
60
- on_consolidated_chart_data subscription, item_name, item_data, new_data
54
+ {
55
+ ACCOUNT_DATA_REGEX => :on_account_data,
56
+ MARKET_DATA_REGEX => :on_market_data,
57
+ TRADE_DATA_REGEX => :on_trade_data,
58
+ CHART_TICK_DATA_REGEX => :on_chart_tick_data,
59
+ CONSOLIDATED_CHART_DATA_REGEX => :on_consolidated_chart_data
60
+ }.each do |regex, handler|
61
+ send handler, subscription, item_name, item_data, new_data if item_name =~ regex
61
62
  end
62
63
  end
63
64
 
65
+ # Handles streaming account data.
64
66
  def on_account_data(_subscription, item_name, item_data, new_data)
65
67
  item_data = @dealing_platform.instantiate_models AccountUpdate, item_data
66
68
  new_data = @dealing_platform.instantiate_models AccountUpdate, new_data
@@ -71,6 +73,7 @@ module IGMarkets
71
73
  run_callbacks new_data, item_data
72
74
  end
73
75
 
76
+ # Handles streaming market data.
74
77
  def on_market_data(_subscription, item_name, item_data, new_data)
75
78
  item_data = @dealing_platform.instantiate_models MarketUpdate, item_data
76
79
  new_data = @dealing_platform.instantiate_models MarketUpdate, new_data
@@ -81,6 +84,7 @@ module IGMarkets
81
84
  run_callbacks new_data, item_data
82
85
  end
83
86
 
87
+ # Handles streaming trade data.
84
88
  def on_trade_data(_subscription, item_name, _item_data, new_data)
85
89
  account_id = item_name.match(TRADE_DATA_REGEX).captures.first
86
90
 
@@ -94,6 +98,7 @@ module IGMarkets
94
98
  end
95
99
  end
96
100
 
101
+ # Handles streaming chart tick data.
97
102
  def on_chart_tick_data(_subscription, item_name, _item_data, new_data)
98
103
  new_data = @dealing_platform.instantiate_models ChartTickUpdate, new_data
99
104
 
@@ -102,6 +107,7 @@ module IGMarkets
102
107
  run_callbacks new_data
103
108
  end
104
109
 
110
+ # Handles streaming consolidated chart data.
105
111
  def on_consolidated_chart_data(_subscription, item_name, item_data, new_data)
106
112
  item_data = @dealing_platform.instantiate_models ConsolidatedChartDataUpdate, item_data
107
113
  new_data = @dealing_platform.instantiate_models ConsolidatedChartDataUpdate, new_data
@@ -13,10 +13,10 @@ module IGMarkets
13
13
  attribute :expiry, Date, nil_if: %w(- DFB), format: ['%d-%b-%y', '%b-%y']
14
14
  attribute :guaranteed_stop, Boolean
15
15
  attribute :level, Float
16
- attribute :limit_distance, Fixnum
16
+ attribute :limit_distance, Integer
17
17
  attribute :size, Float
18
18
  attribute :status, Symbol, allowed_values: [:deleted, :open, :updated]
19
- attribute :stop_distance, Fixnum
19
+ attribute :stop_distance, Integer
20
20
  attribute :timestamp, Time, format: '%FT%T.%L'
21
21
  end
22
22
  end
@@ -1,4 +1,4 @@
1
1
  module IGMarkets
2
2
  # The version of this gem.
3
- VERSION = '0.22'.freeze
3
+ VERSION = '0.23'.freeze
4
4
  end
@@ -10,11 +10,11 @@ module IGMarkets
10
10
  attribute :epic, String, regex: Regex::EPIC
11
11
  attribute :good_till_date, Time, format: '%Y/%m/%d %R'
12
12
  attribute :guaranteed_stop, Boolean
13
- attribute :limit_distance, Fixnum
13
+ attribute :limit_distance, Integer
14
14
  attribute :order_level, Float
15
15
  attribute :order_size, Float
16
16
  attribute :order_type, Symbol, allowed_values: [:limit, :stop]
17
- attribute :stop_distance, Fixnum
17
+ attribute :stop_distance, Integer
18
18
  attribute :time_in_force, Symbol, allowed_values: [:good_till_cancelled, :good_till_date]
19
19
 
20
20
  attribute :market, MarketOverview
@@ -41,9 +41,9 @@ module IGMarkets
41
41
  # {DealingPlatform::WorkingOrderMethods#create} for a description of the attributes.
42
42
  # @option new_attributes [Time] :good_till_date
43
43
  # @option new_attributes [Float] :level
44
- # @option new_attributes [Fixnum] :limit_distance
44
+ # @option new_attributes [Integer] :limit_distance
45
45
  # @option new_attributes [Float] :limit_level
46
- # @option new_attributes [Fixnum] :stop_distance
46
+ # @option new_attributes [Integer] :stop_distance
47
47
  # @option new_attributes [Float] :stop_level
48
48
  # @option new_attributes [:limit, :stop] :type
49
49
  #
@@ -65,9 +65,9 @@ module IGMarkets
65
65
  class WorkingOrderUpdateAttributes < Model
66
66
  attribute :good_till_date, Time, format: '%Y/%m/%d %R:%S'
67
67
  attribute :level, Float
68
- attribute :limit_distance, Fixnum
68
+ attribute :limit_distance, Integer
69
69
  attribute :limit_level, Float
70
- attribute :stop_distance, Fixnum
70
+ attribute :stop_distance, Integer
71
71
  attribute :stop_level, Float
72
72
  attribute :time_in_force, Symbol, allowed_values: [:good_till_cancelled, :good_till_date]
73
73
  attribute :type, Symbol, allowed_values: [:limit, :stop]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ig_markets
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.22'
4
+ version: '0.23'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Viney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-03 00:00:00.000000000 Z
11
+ date: 2016-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: lightstreamer
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.12'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.12'
55
55
  - !ruby/object:Gem::Dependency
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '0.42'
201
+ version: '0.44'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '0.42'
208
+ version: '0.44'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: yard
211
211
  requirement: !ruby/object:Gem::Requirement