ig_markets 0.7 → 0.8

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: fe408c4f3b1493d7da7574265ceab99d931d8685
4
- data.tar.gz: b21bbe2f50cb5a5bedbd92b718fea4afc02462b5
3
+ metadata.gz: 905ebb175a410a5b6a86f1b92c215745e642e04b
4
+ data.tar.gz: 6bb5b7d2360c936c46c2380002a15f632b853b63
5
5
  SHA512:
6
- metadata.gz: 8ff8f42c43576533bd8c44de769f5bb43f725857294c9edce1ab8a45716704c2551eeddb0eb8307345cbfa292a0b1aacb53e45129a3b7ce4c317534ab81dd14c
7
- data.tar.gz: d7a8011e786e30d2cd5a75de50edf5b129ab73ddc4d037fb6f22e18ec00a783adbd7276035326752f7a42fe2f7dad93a78dd0f77c11dcd5b6f772bd146d6ece2
6
+ metadata.gz: 0abc1a40d8fb0c4ef98835c40cf525c129ea5623dc23cff94792034431d2109ce164dbbea6d1097fef176b599c3ae823d88d9aa1bb78f330a7a10ce919239aa9
7
+ data.tar.gz: e0a4e9984d8eb1286ef8e92547512ec1cafb94fbdfc14bb152ffba9f9ff41072d8475b54805da3e1db7191bbf7b41ee958dc1f37e0e73ced7642e6a1f945cbb8
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # IG Markets Changelog
2
2
 
3
- ### 0.71 May, 2016
3
+ ### 0.8April 30, 2016
4
+
5
+ - The `ig_markets` prices command now takes `--from` and `--to` arguments accurate to one second
6
+ - Fixed incomplete data being returned by `IGMarkets::DealingPlatform::AccountMethods#activities` and
7
+ `IGMarkets::DealingPlatform::AccountMethods#transactions`
8
+ - Fixed errors calling `IGMarkets::DealingPlatform#instantiate_models` for models that have deprecated attributes
9
+
10
+ ### 0.7 — April 30, 2016
4
11
 
5
12
  - Added `ig_markets console` command which logs in then opens a live Ruby console
6
13
  - Merged `IGMarkets::DealingPlatform::AccountMethods#activities_in_date_range` and
@@ -44,7 +51,7 @@
44
51
  - Added `IGMarkets::Position#close_level`
45
52
  - Removed `IGMarkets::Position#formatted_size` and `IGMarkets::Transaction#formatted_transaction_type`
46
53
 
47
- ### 0.4 — April 18, 2016
54
+ ### 0.4 — April 17, 2016
48
55
 
49
56
  - Added `create`, `update` and `delete` subcommands to `ig_markets orders`
50
57
  - Added `create`, `update` and `close` subcommands to `ig_markets positions`
@@ -5,14 +5,14 @@ module IGMarkets
5
5
  desc 'prices', 'Prints historical prices for a market'
6
6
 
7
7
  option :epic, required: true, desc: 'The EPIC of the market to print historical prices for'
8
- option :resolution, enum: %w(minute minute-2 minute-3 minute-5 minute-10 minute-15 minute-30 hour hour-2 hour-3
9
- hour-4 day week month), required: true, desc: 'The price resolution'
8
+ option :resolution, enum: %w(second minute minute-2 minute-3 minute-5 minute-10 minute-15 minute-30 hour hour-2
9
+ hour-3 hour-4 day week month), required: true, desc: 'The price resolution'
10
10
  option :number, type: :numeric, desc: 'The number of historical prices to return, if this is specified then ' \
11
- '--start-date and --end-date are ignored, otherwise they are required'
12
- option :start_date, desc: 'The start of the period to return prices for, required unless --number is specified' \
13
- ', format: yyyy-mm-ddThh:mm(+|-)zz:zz'
14
- option :end_date, desc: 'The end of the period to return prices for, required unless --number is specified' \
15
- ', format: yyyy-mm-ddThh:mm(+|-)zz:zz'
11
+ '--from and --to are ignored, otherwise they are required'
12
+ option :from, desc: 'The start of the period to return prices for, required unless --number is specified, ' \
13
+ 'format: yyyy-mm-ddThh:mm:ss(+|-)zz:zz'
14
+ option :to, desc: 'The end of the period to return prices for, required unless --number is specified, ' \
15
+ 'format: yyyy-mm-ddThh:mm:ss(+|-)zz:zz'
16
16
 
17
17
  def prices
18
18
  self.class.begin_session(options) do |dealing_platform|
@@ -43,24 +43,25 @@ END
43
43
 
44
44
  if options[:number]
45
45
  historical_price_result_from_number market
46
- elsif options[:start_date] && options[:end_date]
46
+ elsif options[:from] && options[:to]
47
47
  historical_price_result_from_date_range market
48
48
  else
49
- raise ArgumentError, 'specify --number or both --start-date and --end-date'
49
+ raise ArgumentError, 'specify --number or both --from and --to'
50
50
  end
51
51
  end
52
52
 
53
53
  def historical_price_result_from_number(market)
54
- market.historical_prices resolution: resolution, max: options[:number]
54
+ market.historical_prices resolution: resolution, number: options[:number]
55
55
  end
56
56
 
57
57
  def historical_price_result_from_date_range(market)
58
- filtered = self.class.filter_options options, [:start_date, :end_date]
58
+ filtered = self.class.filter_options options, [:from, :to]
59
59
 
60
- self.class.parse_date_time filtered, :start_date, Time, '%FT%R%z', 'yyyy-mm-ddThh:mm(+|-)zz:zz'
61
- self.class.parse_date_time filtered, :end_date, Time, '%FT%R%z', 'yyyy-mm-ddThh:mm(+|-)zz:zz'
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'
62
+ end
62
63
 
63
- market.historical_prices resolution: resolution, from: filtered[:start_date], to: filtered[:end_date]
64
+ market.historical_prices resolution: resolution, from: filtered[:from], to: filtered[:to]
64
65
  end
65
66
  end
66
67
  end
@@ -79,6 +79,7 @@ module IGMarkets
79
79
  options[:maxSpanSeconds] = (options.delete(:days).to_f * 24 * 60 * 60).to_i if options.key? :days
80
80
  options[:from] = options[:from].strftime('%F') if options.key? :from
81
81
  options[:to] = options[:to].strftime('%F') if options.key? :to
82
+ options[:pageSize] = 0
82
83
  end
83
84
  end
84
85
  end
@@ -68,11 +68,14 @@ module IGMarkets
68
68
  # @return [Hash] A hash containing details of all attributes that have been defined on this model.
69
69
  attr_accessor :defined_attributes
70
70
 
71
+ # @return [Hash] The names of the deprecated attributes on this model.
72
+ attr_accessor :deprecated_attributes
73
+
71
74
  # Returns the names of all currently defined attributes for this model.
72
75
  #
73
76
  # @return [Array<Symbol>]
74
77
  def defined_attribute_names
75
- (defined_attributes || {}).keys
78
+ Hash(defined_attributes).keys
76
79
  end
77
80
 
78
81
  # Returns the type of the specified attribute.
@@ -81,7 +84,9 @@ module IGMarkets
81
84
  #
82
85
  # @return The type of the specified attribute.
83
86
  def attribute_type(attribute_name)
84
- defined_attributes.fetch(attribute_name).fetch :type
87
+ return NilClass if Array(deprecated_attributes).include? attribute_name
88
+
89
+ Hash(defined_attributes).fetch(attribute_name).fetch :type
85
90
  end
86
91
 
87
92
  # Returns the array of allowed values for the specified attribute that was passed to {attribute}.
@@ -90,7 +95,7 @@ module IGMarkets
90
95
  #
91
96
  # @return [Array]
92
97
  def allowed_values(attribute_name)
93
- defined_attributes.fetch(attribute_name).fetch :allowed_values
98
+ Hash(defined_attributes).fetch(attribute_name).fetch :allowed_values
94
99
  end
95
100
 
96
101
  # Defines setter and getter methods for a new attribute on this class.
@@ -118,11 +123,17 @@ module IGMarkets
118
123
  end
119
124
 
120
125
  # Defines a no-op setter method for each of the passed attribute names. This is used to silently allow deprecated
121
- # attributes to be set on the model but not have them be otherwise part of the model's structure.
126
+ # attributes to be set on the model but not have them be part of the model's structure.
127
+ #
128
+ # @param [Array<Symbol>] names The names of the deprecated attributes.
129
+ #
130
+ # @return [void]
122
131
  def deprecated_attribute(*names)
123
132
  names.each do |name|
124
133
  define_method "#{name}=" do |_value|
125
134
  end
135
+
136
+ (self.deprecated_attributes ||= []) << name
126
137
  end
127
138
  end
128
139
 
@@ -1,4 +1,4 @@
1
1
  module IGMarkets
2
2
  # The version of this gem.
3
- VERSION = '0.7'.freeze
3
+ VERSION = '0.8'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ig_markets
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: '0.8'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Viney