ig_markets 0.25 → 0.26

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: 604a5b20ab0813dd47194df5ffcda03dc550d001
4
- data.tar.gz: b95a26c8bbc3a1496023c58c6139b1ef4bf74e67
3
+ metadata.gz: 593ec96300d193a18f730b26cf9dedb9aec19f54
4
+ data.tar.gz: fa29e0da14e82bfb9f53c266275d7a176286a124
5
5
  SHA512:
6
- metadata.gz: e254d0c4f8843a0ffc14b6c07dd35e9a7c21ca2878d9fc7c4d0d42b5e7ca41cce5e75c3c3f716cfadf2df7d8b2b58a44aa664adeb8cd99f0b956c336e27b47a4
7
- data.tar.gz: a39efc2951c35df42eb2defa2bb6d64489aa254f562f39d642f282c2b36205c8006e2f18f0c0ada0a8da42257bcac8afc30e4b0a0b93822f72d4a26bbdd5ac6e
6
+ metadata.gz: 11a54058f41f9a7e897be4040590eb35f4d1e18117c1ed2a021dc4040f0f937f930f57dcf6565de534e911c47c84139020519a03b0672ba5a28f34bddf66f97f
7
+ data.tar.gz: 04def1bdd5817c224bac244e0caf332ae1aed58d951de207b220d061902d38f934b917ea9193a3945ae539d877fce8cc5a1abf2c51bdf7411a5401f950a1c2da
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # IG Markets Changelog
2
2
 
3
+ ### 0.26 — January 12, 2017
4
+
5
+ - Fully support Ruby 2.4
6
+ - Added `IGMarkets::Errors::MarketOrdersNotSupported` and `IGMarkets::Errors::TooManyMarketsError`
7
+ - Fixed incorrect exception messages when trying to set an invalid or disallowed value on an attribute
8
+ - Fixed the `ig_markets stream` command not finding the `curses` gem
9
+ - The `curses` gem is now installed automatically on non-Windows platforms
10
+
3
11
  ### 0.25 — December 7, 2016
4
12
 
5
13
  - Increased required Ruby version to >= 2.2.2
data/LICENSE.md CHANGED
@@ -1,7 +1,7 @@
1
1
  The MIT License (MIT)
2
2
  =====================
3
3
 
4
- Copyright © 2015-2016 Richard Viney
4
+ Copyright © 2015-2017 Richard Viney
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person
7
7
  obtaining a copy of this software and associated documentation
data/ext/mkrf_conf.rb ADDED
@@ -0,0 +1,9 @@
1
+ # This script is responsible for installing the curses gem on all platforms except Windows.
2
+
3
+ require 'rubygems/command'
4
+ require 'rubygems/dependency_installer'
5
+
6
+ Gem::Command.build_args = ARGV
7
+ Gem::DependencyInstaller.new.install 'curses', '~> 1.0' unless Gem.win_platform?
8
+
9
+ File.write File.join(File.dirname(__FILE__), 'Rakefile'), 'task :default'
@@ -39,7 +39,7 @@ END
39
39
  def historical_price_result(dealing_platform)
40
40
  market = dealing_platform.markets[options[:epic]]
41
41
 
42
- raise ArgumentError, 'invalid epic' unless market
42
+ raise ArgumentError, 'invalid EPIC' unless market
43
43
 
44
44
  if options[:number]
45
45
  historical_price_result_from_number market
@@ -55,13 +55,13 @@ END
55
55
  end
56
56
 
57
57
  def historical_price_result_from_date_range(market)
58
- filtered = self.class.filter_options options, [:from, :to]
58
+ filtered_options = self.class.filter_options options, [:from, :to]
59
59
 
60
60
  [:from, :to].each do |attribute|
61
- self.class.parse_date_time filtered, attribute, Time, '%FT%T%z', 'yyyy-mm-ddThh:mm:ss(+|-)zz:zz'
61
+ self.class.parse_date_time filtered_options, attribute, Time, '%FT%T%z', 'yyyy-mm-ddThh:mm:ss(+|-)zz:zz'
62
62
  end
63
63
 
64
- market.historical_prices resolution: resolution, from: filtered[:from], to: filtered[:to]
64
+ market.historical_prices resolution: resolution, from: filtered_options[:from], to: filtered_options[:to]
65
65
  end
66
66
  end
67
67
  end
@@ -43,7 +43,7 @@ module IGMarkets
43
43
  # Returns whether curses support is available. On Windows the 'curses' gem is optional and so this class may not
44
44
  # be usable.
45
45
  def available?
46
- Kernel.require 'curses'
46
+ require 'curses'
47
47
  true
48
48
  rescue LoadError
49
49
  false
@@ -46,7 +46,7 @@ module IGMarkets
46
46
  options[:type] ||= :all
47
47
 
48
48
  unless [:all, :all_deal, :deposit, :withdrawal].include? options[:type]
49
- raise ArgumentError, "Invalid transaction type: #{options[:type]}"
49
+ raise ArgumentError, "invalid transaction type: #{options[:type]}"
50
50
  end
51
51
 
52
52
  history_request_complete url: 'history/transactions', url_parameters: history_url_parameters(options),
@@ -110,10 +110,10 @@ module IGMarkets
110
110
  end
111
111
 
112
112
  if limit_distance && limit_level
113
- raise ArgumentError, 'Do not specify both limit_distance and limit_level options'
113
+ raise ArgumentError, 'do not specify both limit_distance and limit_level options'
114
114
  end
115
115
 
116
- raise ArgumentError, 'Do not specify both stop_distance and stop_level options' if stop_distance && stop_level
116
+ raise ArgumentError, 'do not specify both stop_distance and stop_level options' if stop_distance && stop_level
117
117
  end
118
118
  end
119
119
 
@@ -89,6 +89,10 @@ module IGMarkets
89
89
  class TooManyEPICSError < IGMarketsError
90
90
  end
91
91
 
92
+ # This error is raised when too many markets are specified for a request.
93
+ class TooManyMarketsError < IGMarketsError
94
+ end
95
+
92
96
  # This error is raised when an invalid page size is specified.
93
97
  class InvalidPageSizeError < IGMarketsError
94
98
  end
@@ -222,6 +226,10 @@ module IGMarkets
222
226
  class InstrumentNotFoundError < IGMarketsError
223
227
  end
224
228
 
229
+ # This error is raised when market orders are not supported.
230
+ class MarketOrdersNotSupported < IGMarketsError
231
+ end
232
+
225
233
  # This error is raised when an unsupported EPIC was specified.
226
234
  class UnsupportedEPICError < IGMarketsError
227
235
  end
@@ -353,12 +361,14 @@ module IGMarkets
353
361
  'error.switch.cannot-set-default-account' => Errors::CannotSetDefaultAccountError,
354
362
  'error.switch.invalid-accountId' => Errors::InvalidAccountIDError,
355
363
  'error.trading.otc.instrument-not-found' => Errors::InstrumentNotFoundError,
364
+ 'error.trading.otc.market-orders.not-supported' => Errors::MarketOrdersNotSupported,
356
365
  'error.unsupported.epic' => Errors::UnsupportedEPICError,
357
366
  'error.watchlists.management.cannot-delete-watchlist' => Errors::CannotDeleteWatchlistError,
358
367
  'error.watchlists.management.duplicate-name' => Errors::DuplicateWatchlistNameError,
359
368
  'error.watchlists.management.error' => Errors::WatchlistError,
360
369
  'error.watchlists.management.watchlist-not-found' => Errors::WatchlistNotFoundError,
361
370
  'invalid.input' => Errors::InvalidInputError,
371
+ 'invalid.input.too.many.markets' => Errors::TooManyMarketsError,
362
372
  'invalid.url' => Errors::InvalidURLError,
363
373
  'system.error' => Errors::SystemError,
364
374
  'unauthorised.access.to.equity.exception' => Errors::UnauthorisedAccessToEquityError,
@@ -18,14 +18,14 @@ module IGMarkets
18
18
  end
19
19
  end
20
20
 
21
- def typecaster_boolean(value, _options, _name)
21
+ def typecaster_boolean(value, _options, name)
22
22
  return value if [nil, true, false].include? value
23
23
  return value == '1' if %w(0 1).include? value
24
24
 
25
25
  raise ArgumentError, "#{self}##{name}: invalid boolean value: #{value}"
26
26
  end
27
27
 
28
- def typecaster_string(value, options, _name)
28
+ def typecaster_string(value, options, name)
29
29
  return nil if value.nil?
30
30
 
31
31
  if options.key?(:regex) && !options[:regex].match(value.to_s)
@@ -41,10 +41,12 @@ module IGMarkets
41
41
  value.to_s.to_i
42
42
  end
43
43
 
44
- def typecaster_float(value, _options, _name)
44
+ def typecaster_float(value, _options, name)
45
45
  return nil if value.nil? || value == ''
46
46
 
47
47
  Float(value)
48
+ rescue ArgumentError
49
+ raise ArgumentError, "#{self}##{name}: invalid float value: #{value}"
48
50
  end
49
51
 
50
52
  def typecaster_symbol(value, _options, _name)
@@ -188,7 +188,7 @@ module IGMarkets
188
188
  value = self.class.send "sanitize_#{name}_value", value
189
189
 
190
190
  unless self.class.attribute_value_allowed? name, value
191
- raise ArgumentError, "#{self}##{name}: invalid value: #{value.inspect}"
191
+ raise ArgumentError, "#{self.class}##{name}: invalid value: #{value.inspect}"
192
192
  end
193
193
 
194
194
  (@attributes ||= {})[name] = value
@@ -1,4 +1,4 @@
1
1
  module IGMarkets
2
2
  # The version of this gem.
3
- VERSION = '0.25'.freeze
3
+ VERSION = '0.26'.freeze
4
4
  end
@@ -85,10 +85,10 @@ module IGMarkets
85
85
  # Markets API.
86
86
  def validate
87
87
  if limit_distance && limit_level
88
- raise ArgumentError, 'Do not specify both limit_distance and limit_level options'
88
+ raise ArgumentError, 'do not specify both limit_distance and limit_level'
89
89
  end
90
90
 
91
- raise ArgumentError, 'Do not specify both stop_distance and stop_level options' if stop_distance && stop_level
91
+ raise ArgumentError, 'do not specify both stop_distance and stop_level' if stop_distance && stop_level
92
92
  end
93
93
  end
94
94
 
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.25'
4
+ version: '0.26'
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-12-07 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -224,13 +224,15 @@ description:
224
224
  email: richard.viney@gmail.com
225
225
  executables:
226
226
  - ig_markets
227
- extensions: []
227
+ extensions:
228
+ - ext/mkrf_conf.rb
228
229
  extra_rdoc_files: []
229
230
  files:
230
231
  - CHANGELOG.md
231
232
  - LICENSE.md
232
233
  - README.md
233
234
  - bin/ig_markets
235
+ - ext/mkrf_conf.rb
234
236
  - lib/ig_markets.rb
235
237
  - lib/ig_markets/account.rb
236
238
  - lib/ig_markets/activity.rb
@@ -330,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
332
  version: '0'
331
333
  requirements: []
332
334
  rubyforge_project:
333
- rubygems_version: 2.5.1
335
+ rubygems_version: 2.5.2
334
336
  signing_key:
335
337
  specification_version: 4
336
338
  summary: Library and command-line client for accessing the IG Markets dealing platform.