Class: ProtonApi::GoalAccumulationRecommendationRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/proton_api/models/goal_accumulation_recommendation_request.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ GoalAccumulationRecommendationRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 137

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'recommendation_config')
    self.recommendation_config = attributes[:'recommendation_config']
  end

  if attributes.has_key?(:'compounding_rate')
    self.compounding_rate = attributes[:'compounding_rate']
  else
    self.compounding_rate = 0.0
  end

  if attributes.has_key?(:'recommend_type')
    self.recommend_type = attributes[:'recommend_type']
  else
    self.recommend_type = 'horizon'
  end

  if attributes.has_key?(:'create_log')
    self.create_log = attributes[:'create_log']
  else
    self.create_log = false
  end

  if attributes.has_key?(:'goal_config')
    self.goal_config = attributes[:'goal_config']
  end

  if attributes.has_key?(:'n')
    self.n = attributes[:'n']
  else
    self.n = 1000
  end

  if attributes.has_key?(:'p_risk')
    if (value = attributes[:'p_risk']).is_a?(Array)
      self.p_risk = value
    end
  end

  if attributes.has_key?(:'remove_outliers')
    self.remove_outliers = attributes[:'remove_outliers']
  else
    self.remove_outliers = true
  end

  if attributes.has_key?(:'adjust_for_compounding')
    self.adjust_for_compounding = attributes[:'adjust_for_compounding']
  else
    self.adjust_for_compounding = false
  end

  if attributes.has_key?(:'goal_id')
    self.goal_id = attributes[:'goal_id']
  end

  if attributes.has_key?(:'conf_tgt')
    self.conf_tgt = attributes[:'conf_tgt']
  else
    self.conf_tgt = 0.9
  end

  if attributes.has_key?(:'trading_days_per_year')
    self.trading_days_per_year = attributes[:'trading_days_per_year']
  else
    self.trading_days_per_year = 252
  end

  if attributes.has_key?(:'thresh')
    self.thresh = attributes[:'thresh']
  end

  if attributes.has_key?(:'withdrawal_tax')
    self.withdrawal_tax = attributes[:'withdrawal_tax']
  else
    self.withdrawal_tax = 0.0
  end

  if attributes.has_key?(:'client_id')
    self.client_id = attributes[:'client_id']
  end

  if attributes.has_key?(:'thresh_type')
    self.thresh_type = attributes[:'thresh_type']
  else
    self.thresh_type = 'perc'
  end

  if attributes.has_key?(:'horizon_frequency')
    self.horizon_frequency = attributes[:'horizon_frequency']
  else
    self.horizon_frequency = 'year'
  end

  if attributes.has_key?(:'horizon')
    self.horizon = attributes[:'horizon']
  end

  if attributes.has_key?(:'curr_inv')
    self.curr_inv = attributes[:'curr_inv']
  end

  if attributes.has_key?(:'deposit_config')
    if (value = attributes[:'deposit_config']).is_a?(Array)
      self.deposit_config = value
    end
  end

  if attributes.has_key?(:'p_ret')
    if (value = attributes[:'p_ret']).is_a?(Array)
      self.p_ret = value
    end
  end
end

Instance Attribute Details

#adjust_for_compoundingObject

Returns the value of attribute adjust_for_compounding.



33
34
35
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 33

def adjust_for_compounding
  @adjust_for_compounding
end

#client_idObject

Returns the value of attribute client_id.



45
46
47
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 45

def client_id
  @client_id
end

#compounding_rateObject

Returns the value of attribute compounding_rate.



19
20
21
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 19

def compounding_rate
  @compounding_rate
end

#conf_tgtObject

Returns the value of attribute conf_tgt.



37
38
39
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 37

def conf_tgt
  @conf_tgt
end

#create_logObject

Returns the value of attribute create_log.



23
24
25
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 23

def create_log
  @create_log
end

#curr_invObject

Returns the value of attribute curr_inv.



53
54
55
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 53

def curr_inv
  @curr_inv
end

#deposit_configObject

Returns the value of attribute deposit_config.



55
56
57
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 55

def deposit_config
  @deposit_config
end

#goal_configObject

Returns the value of attribute goal_config.



25
26
27
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 25

def goal_config
  @goal_config
end

#goal_idObject

Returns the value of attribute goal_id.



35
36
37
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 35

def goal_id
  @goal_id
end

#horizonObject

Returns the value of attribute horizon.



51
52
53
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 51

def horizon
  @horizon
end

#horizon_frequencyObject

Returns the value of attribute horizon_frequency.



49
50
51
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 49

def horizon_frequency
  @horizon_frequency
end

#nObject

Returns the value of attribute n.



27
28
29
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 27

def n
  @n
end

#p_retObject

Returns the value of attribute p_ret.



57
58
59
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 57

def p_ret
  @p_ret
end

#p_riskObject

Returns the value of attribute p_risk.



29
30
31
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 29

def p_risk
  @p_risk
end

#recommend_typeObject

Returns the value of attribute recommend_type.



21
22
23
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 21

def recommend_type
  @recommend_type
end

#recommendation_configObject

Returns the value of attribute recommendation_config.



17
18
19
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 17

def recommendation_config
  @recommendation_config
end

#remove_outliersObject

Returns the value of attribute remove_outliers.



31
32
33
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 31

def remove_outliers
  @remove_outliers
end

#threshObject

Returns the value of attribute thresh.



41
42
43
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 41

def thresh
  @thresh
end

#thresh_typeObject

Returns the value of attribute thresh_type.



47
48
49
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 47

def thresh_type
  @thresh_type
end

#trading_days_per_yearObject

Returns the value of attribute trading_days_per_year.



39
40
41
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 39

def trading_days_per_year
  @trading_days_per_year
end

#withdrawal_taxObject

Returns the value of attribute withdrawal_tax.



43
44
45
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 43

def withdrawal_tax
  @withdrawal_tax
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 82

def self.attribute_map
  {
    :'recommendation_config' => :'recommendation_config',
    :'compounding_rate' => :'compounding_rate',
    :'recommend_type' => :'recommend_type',
    :'create_log' => :'create_log',
    :'goal_config' => :'goal_config',
    :'n' => :'n',
    :'p_risk' => :'p_risk',
    :'remove_outliers' => :'remove_outliers',
    :'adjust_for_compounding' => :'adjust_for_compounding',
    :'goal_id' => :'goal_id',
    :'conf_tgt' => :'conf_tgt',
    :'trading_days_per_year' => :'trading_days_per_year',
    :'thresh' => :'thresh',
    :'withdrawal_tax' => :'withdrawal_tax',
    :'client_id' => :'client_id',
    :'thresh_type' => :'thresh_type',
    :'horizon_frequency' => :'horizon_frequency',
    :'horizon' => :'horizon',
    :'curr_inv' => :'curr_inv',
    :'deposit_config' => :'deposit_config',
    :'p_ret' => :'p_ret'
  }
end

.swagger_typesObject

Attribute type mapping.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 109

def self.swagger_types
  {
    :'recommendation_config' => :'RecommendationConfig1',
    :'compounding_rate' => :'Float',
    :'recommend_type' => :'String',
    :'create_log' => :'BOOLEAN',
    :'goal_config' => :'GoalConfig',
    :'n' => :'Integer',
    :'p_risk' => :'Array<Float>',
    :'remove_outliers' => :'BOOLEAN',
    :'adjust_for_compounding' => :'BOOLEAN',
    :'goal_id' => :'String',
    :'conf_tgt' => :'Float',
    :'trading_days_per_year' => :'Integer',
    :'thresh' => :'Float',
    :'withdrawal_tax' => :'Float',
    :'client_id' => :'String',
    :'thresh_type' => :'String',
    :'horizon_frequency' => :'String',
    :'horizon' => :'Integer',
    :'curr_inv' => :'Float',
    :'deposit_config' => :'Array<AccumulationGoalDepositConfig>',
    :'p_ret' => :'Array<Float>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 482

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      recommendation_config == o.recommendation_config &&
      compounding_rate == o.compounding_rate &&
      recommend_type == o.recommend_type &&
      create_log == o.create_log &&
      goal_config == o.goal_config &&
      n == o.n &&
      p_risk == o.p_risk &&
      remove_outliers == o.remove_outliers &&
      adjust_for_compounding == o.adjust_for_compounding &&
      goal_id == o.goal_id &&
      conf_tgt == o.conf_tgt &&
      trading_days_per_year == o.trading_days_per_year &&
      thresh == o.thresh &&
      withdrawal_tax == o.withdrawal_tax &&
      client_id == o.client_id &&
      thresh_type == o.thresh_type &&
      horizon_frequency == o.horizon_frequency &&
      horizon == o.horizon &&
      curr_inv == o.curr_inv &&
      deposit_config == o.deposit_config &&
      p_ret == o.p_ret
end

#_deserialize(type, value) ⇒ Object

Returns Deserialized data.

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 543

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    value
  when :Date
    value
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = ProtonApi.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



607
608
609
610
611
612
613
614
615
616
617
618
619
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 607

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 523

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


510
511
512
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 510

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



516
517
518
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 516

def hash
  [recommendation_config, compounding_rate, recommend_type, create_log, goal_config, n, p_risk, remove_outliers, adjust_for_compounding, goal_id, conf_tgt, trading_days_per_year, thresh, withdrawal_tax, client_id, thresh_type, horizon_frequency, horizon, curr_inv, deposit_config, p_ret].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 258

def list_invalid_properties
  invalid_properties = Array.new
  if !@compounding_rate.nil? && @compounding_rate < -1
    invalid_properties.push('invalid value for "compounding_rate", must be greater than or equal to -1.')
  end

  if !@n.nil? && @n > 10000
    invalid_properties.push('invalid value for "n", must be smaller than or equal to 10000.')
  end

  if !@n.nil? && @n < 1
    invalid_properties.push('invalid value for "n", must be greater than or equal to 1.')
  end

  if @p_risk.nil?
    invalid_properties.push('invalid value for "p_risk", p_risk cannot be nil.')
  end

  if !@conf_tgt.nil? && @conf_tgt > 1
    invalid_properties.push('invalid value for "conf_tgt", must be smaller than or equal to 1.')
  end

  if !@conf_tgt.nil? && @conf_tgt < 0
    invalid_properties.push('invalid value for "conf_tgt", must be greater than or equal to 0.')
  end

  if !@trading_days_per_year.nil? && @trading_days_per_year > 365
    invalid_properties.push('invalid value for "trading_days_per_year", must be smaller than or equal to 365.')
  end

  if !@trading_days_per_year.nil? && @trading_days_per_year < 1
    invalid_properties.push('invalid value for "trading_days_per_year", must be greater than or equal to 1.')
  end

  if !@thresh.nil? && @thresh < 0
    invalid_properties.push('invalid value for "thresh", must be greater than or equal to 0.')
  end

  if !@withdrawal_tax.nil? && @withdrawal_tax > 1
    invalid_properties.push('invalid value for "withdrawal_tax", must be smaller than or equal to 1.')
  end

  if !@withdrawal_tax.nil? && @withdrawal_tax < 0
    invalid_properties.push('invalid value for "withdrawal_tax", must be greater than or equal to 0.')
  end

  if !@horizon.nil? && @horizon > 350
    invalid_properties.push('invalid value for "horizon", must be smaller than or equal to 350.')
  end

  if !@horizon.nil? && @horizon < 0
    invalid_properties.push('invalid value for "horizon", must be greater than or equal to 0.')
  end

  if !@curr_inv.nil? && @curr_inv < 0
    invalid_properties.push('invalid value for "curr_inv", must be greater than or equal to 0.')
  end

  if @p_ret.nil?
    invalid_properties.push('invalid value for "p_ret", p_ret cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



588
589
590
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 588

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



594
595
596
597
598
599
600
601
602
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 594

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns String presentation of the object.

Returns:

  • (String)

    String presentation of the object



582
583
584
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 582

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/proton_api/models/goal_accumulation_recommendation_request.rb', line 325

def valid?
  return false if !@compounding_rate.nil? && @compounding_rate < -1
  recommend_type_validator = EnumAttributeValidator.new('String', ['recurring', 'one-time', 'combo', 'horizon'])
  return false unless recommend_type_validator.valid?(@recommend_type)
  return false if !@n.nil? && @n > 10000
  return false if !@n.nil? && @n < 1
  return false if @p_risk.nil?
  return false if !@conf_tgt.nil? && @conf_tgt > 1
  return false if !@conf_tgt.nil? && @conf_tgt < 0
  return false if !@trading_days_per_year.nil? && @trading_days_per_year > 365
  return false if !@trading_days_per_year.nil? && @trading_days_per_year < 1
  return false if !@thresh.nil? && @thresh < 0
  return false if !@withdrawal_tax.nil? && @withdrawal_tax > 1
  return false if !@withdrawal_tax.nil? && @withdrawal_tax < 0
  thresh_type_validator = EnumAttributeValidator.new('String', ['amnt', 'perc'])
  return false unless thresh_type_validator.valid?(@thresh_type)
  horizon_frequency_validator = EnumAttributeValidator.new('String', ['year', 'six_months', 'quarter', 'month', 'two_weeks', 'week', 'day'])
  return false unless horizon_frequency_validator.valid?(@horizon_frequency)
  return false if !@horizon.nil? && @horizon > 350
  return false if !@horizon.nil? && @horizon < 0
  return false if !@curr_inv.nil? && @curr_inv < 0
  return false if @p_ret.nil?
  true
end