ig_markets 0.20 → 0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0873a06d085af3287d3497f41a7157710216995
4
- data.tar.gz: 4606f5cc0084f0092ab1f53361ae3c2ff11f4804
3
+ metadata.gz: f39c3b7d7b0f7a66c1de890bc6fc9514c97d009f
4
+ data.tar.gz: 53029d58d12ef0b11863339bd84a5833f3165bee
5
5
  SHA512:
6
- metadata.gz: db11c11960641e5f468b5765e3e790bce4540c3e2f6e468e29ba0b80fda70e7bd3aab20cdcae5e37f3c86fd2a26a59afc39dde7d22ece0ab8abf9524c254acea
7
- data.tar.gz: 6d27114ba6ba7811f767a022643f176bc77ad69d669c8e81b2637c82b321a611cb355bcf4b91bd3e8b0ca30fc4899705b4bb5d8902807b58e4bac96c654b9632
6
+ metadata.gz: dbf8fc12c117a245f89d44d0731c446f9363403763edae0023ac6416f16bad20bb566a12b593b80f8425a6b9b92c48219c5155aff4aee8c0d9cf34e5f0c834c0
7
+ data.tar.gz: 89abaf288cc72eb6d96039765c09f3eb34912290c6faa3124ec874117c6285755b343586b3f3f389c632a4864306cd2c290ee8af56fb77cfed8e1917efd061ce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # IG Markets Changelog
2
2
 
3
+ ### 0.21 — September 29, 2016
4
+
5
+ - Replaced `IGMarkets::Streaming::AccountState#data_to_process?` with
6
+ `IGMarkets::Streaming::AccountState#data_queue_empty?`
7
+ - Fixed circular references in the `IGMarkets::DealingPlatform` subclasses
8
+ - All documented IG Markets API errors now have a matching `IGMarkets::IGMarketsError` subclass, and any unrecognized
9
+ error codes returned by the API cause a warning to be written to `stderr`
10
+
3
11
  ### 0.20 — August 20, 2016
4
12
 
5
13
  - Added `IGMarkets::DealingPlatform#streaming` which along with new classes in the `IGMarkets::Streaming` module
@@ -6,7 +6,7 @@ module IGMarkets
6
6
  #
7
7
  # @param [DealingPlatform] dealing_platform The dealing platform.
8
8
  def initialize(dealing_platform)
9
- @dealing_platform = dealing_platform
9
+ @dealing_platform = WeakRef.new dealing_platform
10
10
  end
11
11
 
12
12
  # Returns all accounts associated with the current IG Markets login.
@@ -6,7 +6,7 @@ module IGMarkets
6
6
  #
7
7
  # @param [DealingPlatform] dealing_platform The dealing platform.
8
8
  def initialize(dealing_platform)
9
- @dealing_platform = dealing_platform
9
+ @dealing_platform = WeakRef.new dealing_platform
10
10
  end
11
11
 
12
12
  # Returns the client sentiment for a market.
@@ -6,7 +6,7 @@ module IGMarkets
6
6
  #
7
7
  # @param [DealingPlatform] dealing_platform The dealing platform.
8
8
  def initialize(dealing_platform)
9
- @dealing_platform = dealing_platform
9
+ @dealing_platform = WeakRef.new dealing_platform
10
10
  end
11
11
 
12
12
  # Returns details on the market hierarchy directly under the specified node.
@@ -6,7 +6,7 @@ module IGMarkets
6
6
  #
7
7
  # @param [DealingPlatform] dealing_platform The dealing platform.
8
8
  def initialize(dealing_platform)
9
- @dealing_platform = dealing_platform
9
+ @dealing_platform = WeakRef.new dealing_platform
10
10
  end
11
11
 
12
12
  # Returns all positions.
@@ -6,7 +6,7 @@ module IGMarkets
6
6
  #
7
7
  # @param [DealingPlatform] dealing_platform The dealing platform.
8
8
  def initialize(dealing_platform)
9
- @dealing_platform = dealing_platform
9
+ @dealing_platform = WeakRef.new dealing_platform
10
10
  end
11
11
 
12
12
  # Returns all sprint market positions.
@@ -6,7 +6,7 @@ module IGMarkets
6
6
  #
7
7
  # @param [DealingPlatform] dealing_platform The dealing platform.
8
8
  def initialize(dealing_platform)
9
- @dealing_platform = dealing_platform
9
+ @dealing_platform = WeakRef.new dealing_platform
10
10
  @queue = Queue.new
11
11
  @on_error_callbacks = []
12
12
  end
@@ -6,7 +6,7 @@ module IGMarkets
6
6
  #
7
7
  # @param [DealingPlatform] dealing_platform The dealing platform.
8
8
  def initialize(dealing_platform)
9
- @dealing_platform = dealing_platform
9
+ @dealing_platform = WeakRef.new dealing_platform
10
10
  end
11
11
 
12
12
  # Returns all watchlists.
@@ -6,7 +6,7 @@ module IGMarkets
6
6
  #
7
7
  # @param [DealingPlatform] dealing_platform The dealing platform.
8
8
  def initialize(dealing_platform)
9
- @dealing_platform = dealing_platform
9
+ @dealing_platform = WeakRef.new dealing_platform
10
10
  end
11
11
 
12
12
  # Returns all working orders.
@@ -89,6 +89,10 @@ module IGMarkets
89
89
  class TooManyEPICSError < IGMarketsError
90
90
  end
91
91
 
92
+ # This error is raised when an invalid page size is specified.
93
+ class InvalidPageSizeError < IGMarketsError
94
+ end
95
+
92
96
  # This error is raised when the account has been denied login privileges.
93
97
  class AccountAccessDeniedError < IGMarketsError
94
98
  end
@@ -142,6 +146,10 @@ module IGMarkets
142
146
  class APIKeyRevokedError < IGMarketsError
143
147
  end
144
148
 
149
+ # This error is raised when a timeout occurs during authentication.
150
+ class AuthenticationTimeoutError < IGMarketsError
151
+ end
152
+
145
153
  # This error is raised when the client has been suspended from using the platform.
146
154
  class ClientSuspendedError < IGMarketsError
147
155
  end
@@ -170,6 +178,10 @@ module IGMarkets
170
178
  class InvalidWebsiteError < IGMarketsError
171
179
  end
172
180
 
181
+ # This error is raised when an invalid OAuth access token is encountered.
182
+ class OAuthTokenInvalidError < IGMarketsError
183
+ end
184
+
173
185
  # This error is raised when there have been too many failed login attempts.
174
186
  class TooManyFailedLoginAttemptsError < IGMarketsError
175
187
  end
@@ -178,6 +190,22 @@ module IGMarkets
178
190
  class WatchlistInvalidEPICError < IGMarketsError
179
191
  end
180
192
 
193
+ # This error is raised when the expiry period of the sprint market position is invalid.
194
+ class SprintMarketPositionInvalidExpiryError < IGMarketsError
195
+ end
196
+
197
+ # This error is raised when an unspecified error occurs trying to create a sprint market position.
198
+ class SprintMarketPositionCreateError < IGMarketsError
199
+ end
200
+
201
+ # This error is raised when the expiry time of a sprint market falls outside market trading hours.
202
+ class SprintMarketClosedError < IGMarketsError
203
+ end
204
+
205
+ # This error is raised when a sprint market position's order size is invalid.
206
+ class SprintMarketInvalidOrderSizeError < IGMarketsError
207
+ end
208
+
181
209
  # This error is raised when trying to set the current account to the current account.
182
210
  class AccountAlreadyCurrentError < IGMarketsError
183
211
  end
@@ -190,6 +218,10 @@ module IGMarkets
190
218
  class InvalidAccountIDError < IGMarketsError
191
219
  end
192
220
 
221
+ # This error is raised when a specified instrument is not found.
222
+ class InstrumentNotFoundError < IGMarketsError
223
+ end
224
+
193
225
  # This error is raised when an unsupported EPIC was specified.
194
226
  class UnsupportedEPICError < IGMarketsError
195
227
  end
@@ -246,13 +278,20 @@ module IGMarkets
246
278
  #
247
279
  # @param [String] error_code The error code.
248
280
  #
249
- # @return [LightstreamerError]
281
+ # @return [IGMarketsError]
250
282
  #
251
283
  # @private
252
284
  def self.build(error_code)
253
285
  if API_ERROR_CODE_TO_CLASS.key? error_code
254
286
  API_ERROR_CODE_TO_CLASS[error_code].new ''
255
287
  else
288
+ @reported_unrecognized_error_codes ||= []
289
+
290
+ unless @reported_unrecognized_error_codes.include? error_code
291
+ @reported_unrecognized_error_codes << error_code
292
+ warn "ig_markets: unrecognized error code #{error_code}"
293
+ end
294
+
256
295
  new error_code
257
296
  end
258
297
  end
@@ -280,6 +319,8 @@ module IGMarkets
280
319
  'error.public-api.failure.preferred.account.not.set' => Errors::PreferredAccountNotSetError,
281
320
  'error.public-api.failure.stockbroking-not-supported' => Errors::StockbrokingNotSupportedError,
282
321
  'error.public-api.too-many-epics' => Errors::TooManyEPICSError,
322
+ 'error.request.invalid.date-range' => Errors::InvalidDateRangeError,
323
+ 'error.request.invalid.page-size' => Errors::InvalidPageSizeError,
283
324
  'error.security.account-access-denied' => Errors::AccountAccessDeniedError,
284
325
  'error.security.account-migrated' => Errors::AccountMigratedError,
285
326
  'error.security.account-not-yet-activated' => Errors::AccountNotYetActivatedError,
@@ -293,6 +334,7 @@ module IGMarkets
293
334
  'error.security.api-key-missing' => Errors::APIKeyMissingError,
294
335
  'error.security.api-key-restricted' => Errors::APIKeyRestrictedError,
295
336
  'error.security.api-key-revoked' => Errors::APIKeyRevokedError,
337
+ 'error.security.authentication.timeout' => Errors::AuthenticationTimeoutError,
296
338
  'error.security.client-suspended' => Errors::ClientSuspendedError,
297
339
  'error.security.client-token-invalid' => Errors::ClientTokenInvalidError,
298
340
  'error.security.client-token-missing' => Errors::ClientTokenMissingError,
@@ -300,11 +342,17 @@ module IGMarkets
300
342
  'error.security.invalid-application' => Errors::InvalidApplicationError,
301
343
  'error.security.invalid-details' => Errors::InvalidCredentialsError,
302
344
  'error.security.invalid-website' => Errors::InvalidWebsiteError,
345
+ 'error.security.oauth-token-invalid' => Errors::OAuthTokenInvalidError,
303
346
  'error.security.too-many-failed-attempts' => Errors::TooManyFailedLoginAttemptsError,
304
347
  'error.service.watchlists.add-instrument.invalid-epic' => Errors::WatchlistInvalidEPICError,
348
+ 'error.sprintmarket.create-position.expiry.outside-valid-range' => Errors::SprintMarketPositionInvalidExpiryError,
349
+ 'error.sprintmarket.create-position.failure' => Errors::SprintMarketPositionCreateError,
350
+ 'error.sprintmarket.create-position.market-closed' => Errors::SprintMarketPositionInvalidExpiryError,
351
+ 'error.sprintmarket.create-position.order-size.invalid' => Errors::SprintMarketInvalidOrderSizeError,
305
352
  'error.switch.accountId-must-be-different' => Errors::AccountAlreadyCurrentError,
306
353
  'error.switch.cannot-set-default-account' => Errors::CannotSetDefaultAccountError,
307
354
  'error.switch.invalid-accountId' => Errors::InvalidAccountIDError,
355
+ 'error.trading.otc.instrument-not-found' => Errors::InstrumentNotFoundError,
308
356
  'error.unsupported.epic' => Errors::UnsupportedEPICError,
309
357
  'error.watchlists.management.cannot-delete-watchlist' => Errors::CannotDeleteWatchlistError,
310
358
  'error.watchlists.management.duplicate-name' => Errors::DuplicateWatchlistNameError,
@@ -31,12 +31,14 @@ module IGMarkets
31
31
  attribute :open_time
32
32
 
33
33
  # This method is used by {DealingPlatform#instantiate_models} to work around a vagary in the IG API where there
34
- # is a seemingly unnecessary hash for the :opening_hours value that contains a single :market_times key which is
34
+ # is a seemingly unnecessary hash for the :opening_hours value that contains a single `:market_times` key which is
35
35
  # what holds the actual opening hours data.
36
36
  #
37
37
  # @param [Hash] attributes
38
38
  #
39
39
  # @return [Hash]
40
+ #
41
+ # @private
40
42
  def self.adjusted_api_attributes(attributes)
41
43
  attributes.keys == [:market_times] ? attributes[:market_times] : attributes
42
44
  end
@@ -51,11 +51,12 @@ module IGMarkets
51
51
  update_market_subscriptions
52
52
  end
53
53
 
54
- # Returns whether there is any data waiting to be processed by a call to {#process_queued_data}
54
+ # Returns whether the data queue is empty. If this returns false then there is data waiting to be processed by a
55
+ # call to {#process_queued_data}.
55
56
  #
56
57
  # @return [Boolean]
57
- def data_to_process?
58
- !@data_queue.empty?
58
+ def data_queue_empty?
59
+ @data_queue.empty?
59
60
  end
60
61
 
61
62
  # Processes all queued data and updates {#accounts}, {#positions} and {#working_orders} accordingly. If there are
@@ -1,4 +1,4 @@
1
1
  module IGMarkets
2
2
  # The version of this gem.
3
- VERSION = '0.20'.freeze
3
+ VERSION = '0.21'.freeze
4
4
  end
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.20'
4
+ version: '0.21'
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-08-20 00:00:00.000000000 Z
11
+ date: 2016-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize