Class: SnapTrade::PerformanceCustom

Inherits:
Object
  • Object
show all
Defined in:
lib/snaptrade/models/performance_custom.rb

Overview

Performance Custom Response Object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PerformanceCustom

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
# File 'lib/snaptrade/models/performance_custom.rb', line 137

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::PerformanceCustom` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::PerformanceCustom`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

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

  if attributes.key?(:'contributions')
    self.contributions = attributes[:'contributions']
  end

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

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

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

  if attributes.key?(:'contribution_streak')
    self.contribution_streak = attributes[:'contribution_streak']
  end

  if attributes.key?(:'contribution_months_contributed')
    self.contribution_months_contributed = attributes[:'contribution_months_contributed']
  end

  if attributes.key?(:'contribution_total_months')
    self.contribution_total_months = attributes[:'contribution_total_months']
  end

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

  if attributes.key?(:'dividend_income')
    self.dividend_income = attributes[:'dividend_income']
  end

  if attributes.key?(:'monthly_dividends')
    self.monthly_dividends = attributes[:'monthly_dividends']
  end

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

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

  if attributes.key?(:'commissions')
    self.commissions = attributes[:'commissions']
  end

  if attributes.key?(:'forex_fees')
    self.forex_fees = attributes[:'forex_fees']
  end

  if attributes.key?(:'fees')
    self.fees = attributes[:'fees']
  end

  if attributes.key?(:'rate_of_return')
    self.rate_of_return = attributes[:'rate_of_return']
  end

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

  if attributes.key?(:'detailed_mode')
    self.detailed_mode = attributes[:'detailed_mode']
  end
end

Instance Attribute Details

#bad_tickersObject

list of tickers which may not be supported or may not have accurate price data



44
45
46
# File 'lib/snaptrade/models/performance_custom.rb', line 44

def bad_tickers
  @bad_tickers
end

#commissionsObject

commissions incurred during the timeframe



49
50
51
# File 'lib/snaptrade/models/performance_custom.rb', line 49

def commissions
  @commissions
end

#contribution_months_contributedObject

Number of months in the timeframe with contributions



30
31
32
# File 'lib/snaptrade/models/performance_custom.rb', line 30

def contribution_months_contributed
  @contribution_months_contributed
end

#contribution_streakObject

Current streak of cosecutive months where contributions were made



27
28
29
# File 'lib/snaptrade/models/performance_custom.rb', line 27

def contribution_streak
  @contribution_streak
end

#contribution_timeframeObject

Returns the value of attribute contribution_timeframe.



20
21
22
# File 'lib/snaptrade/models/performance_custom.rb', line 20

def contribution_timeframe
  @contribution_timeframe
end

#contribution_timeframe_cumulativeObject

Returns the value of attribute contribution_timeframe_cumulative.



22
23
24
# File 'lib/snaptrade/models/performance_custom.rb', line 22

def contribution_timeframe_cumulative
  @contribution_timeframe_cumulative
end

#contribution_total_monthsObject

Total months in timeframe



33
34
35
# File 'lib/snaptrade/models/performance_custom.rb', line 33

def contribution_total_months
  @contribution_total_months
end

#contributionsObject

Returns the value of attribute contributions.



18
19
20
# File 'lib/snaptrade/models/performance_custom.rb', line 18

def contributions
  @contributions
end

#detailed_modeObject

Whether the user has detailed mode enabled (more frequent data points for totalEquity and contribution timeframes)



63
64
65
# File 'lib/snaptrade/models/performance_custom.rb', line 63

def detailed_mode
  @detailed_mode
end

#dividend_incomeObject

Total dividends received over the timeframe



38
39
40
# File 'lib/snaptrade/models/performance_custom.rb', line 38

def dividend_income
  @dividend_income
end

#dividend_timelineObject

Returns the value of attribute dividend_timeline.



46
47
48
# File 'lib/snaptrade/models/performance_custom.rb', line 46

def dividend_timeline
  @dividend_timeline
end

#dividendsObject

Returns the value of attribute dividends.



35
36
37
# File 'lib/snaptrade/models/performance_custom.rb', line 35

def dividends
  @dividends
end

#feesObject

other fees incurred during the timeframe



55
56
57
# File 'lib/snaptrade/models/performance_custom.rb', line 55

def fees
  @fees
end

#forex_feesObject

forex fees incurred during the timeframe



52
53
54
# File 'lib/snaptrade/models/performance_custom.rb', line 52

def forex_fees
  @forex_fees
end

#monthly_dividendsObject

Average dividends received per month over the timeframe



41
42
43
# File 'lib/snaptrade/models/performance_custom.rb', line 41

def monthly_dividends
  @monthly_dividends
end

#rate_of_returnObject

The return rate over the timeframe. Annualized if timeframe is longer than 1 year



58
59
60
# File 'lib/snaptrade/models/performance_custom.rb', line 58

def rate_of_return
  @rate_of_return
end

#return_rate_timeframeObject

Returns the value of attribute return_rate_timeframe.



60
61
62
# File 'lib/snaptrade/models/performance_custom.rb', line 60

def return_rate_timeframe
  @return_rate_timeframe
end

#total_equity_timeframeObject

Returns the value of attribute total_equity_timeframe.



16
17
18
# File 'lib/snaptrade/models/performance_custom.rb', line 16

def total_equity_timeframe
  @total_equity_timeframe
end

#withdrawal_timeframeObject

Returns the value of attribute withdrawal_timeframe.



24
25
26
# File 'lib/snaptrade/models/performance_custom.rb', line 24

def withdrawal_timeframe
  @withdrawal_timeframe
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



91
92
93
# File 'lib/snaptrade/models/performance_custom.rb', line 91

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/snaptrade/models/performance_custom.rb', line 66

def self.attribute_map
  {
    :'total_equity_timeframe' => :'totalEquityTimeframe',
    :'contributions' => :'contributions',
    :'contribution_timeframe' => :'contributionTimeframe',
    :'contribution_timeframe_cumulative' => :'contributionTimeframeCumulative',
    :'withdrawal_timeframe' => :'withdrawalTimeframe',
    :'contribution_streak' => :'contributionStreak',
    :'contribution_months_contributed' => :'contributionMonthsContributed',
    :'contribution_total_months' => :'contributionTotalMonths',
    :'dividends' => :'dividends',
    :'dividend_income' => :'dividendIncome',
    :'monthly_dividends' => :'monthlyDividends',
    :'bad_tickers' => :'badTickers',
    :'dividend_timeline' => :'dividendTimeline',
    :'commissions' => :'commissions',
    :'forex_fees' => :'forexFees',
    :'fees' => :'fees',
    :'rate_of_return' => :'rateOfReturn',
    :'return_rate_timeframe' => :'returnRateTimeframe',
    :'detailed_mode' => :'detailedMode'
  }
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



297
298
299
# File 'lib/snaptrade/models/performance_custom.rb', line 297

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/snaptrade/models/performance_custom.rb', line 121

def self.openapi_nullable
  Set.new([
    :'contribution_streak',
    :'contribution_months_contributed',
    :'contribution_total_months',
    :'dividend_income',
    :'monthly_dividends',
    :'commissions',
    :'forex_fees',
    :'fees',
    :'rate_of_return',
  ])
end

.openapi_typesObject

Attribute type mapping.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/snaptrade/models/performance_custom.rb', line 96

def self.openapi_types
  {
    :'total_equity_timeframe' => :'Array<PastValue>',
    :'contributions' => :'NetContributions',
    :'contribution_timeframe' => :'Array<PastValue>',
    :'contribution_timeframe_cumulative' => :'Array<PastValue>',
    :'withdrawal_timeframe' => :'Array<PastValue>',
    :'contribution_streak' => :'Float',
    :'contribution_months_contributed' => :'Float',
    :'contribution_total_months' => :'Float',
    :'dividends' => :'Array<NetDividend>',
    :'dividend_income' => :'Float',
    :'monthly_dividends' => :'Float',
    :'bad_tickers' => :'Array<String>',
    :'dividend_timeline' => :'Array<MonthlyDividends>',
    :'commissions' => :'Float',
    :'forex_fees' => :'Float',
    :'fees' => :'Float',
    :'rate_of_return' => :'Float',
    :'return_rate_timeframe' => :'Array<SubPeriodReturnRate>',
    :'detailed_mode' => :'Boolean'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/snaptrade/models/performance_custom.rb', line 258

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      total_equity_timeframe == o.total_equity_timeframe &&
      contributions == o.contributions &&
      contribution_timeframe == o.contribution_timeframe &&
      contribution_timeframe_cumulative == o.contribution_timeframe_cumulative &&
      withdrawal_timeframe == o.withdrawal_timeframe &&
      contribution_streak == o.contribution_streak &&
      contribution_months_contributed == o.contribution_months_contributed &&
      contribution_total_months == o.contribution_total_months &&
      dividends == o.dividends &&
      dividend_income == o.dividend_income &&
      monthly_dividends == o.monthly_dividends &&
      bad_tickers == o.bad_tickers &&
      dividend_timeline == o.dividend_timeline &&
      commissions == o.commissions &&
      forex_fees == o.forex_fees &&
      fees == o.fees &&
      rate_of_return == o.rate_of_return &&
      return_rate_timeframe == o.return_rate_timeframe &&
      detailed_mode == o.detailed_mode
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/snaptrade/models/performance_custom.rb', line 328

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(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
    # models (e.g. Pet) or oneOf
    klass = SnapTrade.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of 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



399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/snaptrade/models/performance_custom.rb', line 399

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



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/snaptrade/models/performance_custom.rb', line 304

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    elsif 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
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


284
285
286
# File 'lib/snaptrade/models/performance_custom.rb', line 284

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



290
291
292
# File 'lib/snaptrade/models/performance_custom.rb', line 290

def hash
  [total_equity_timeframe, contributions, contribution_timeframe, contribution_timeframe_cumulative, withdrawal_timeframe, contribution_streak, contribution_months_contributed, contribution_total_months, dividends, dividend_income, monthly_dividends, bad_tickers, dividend_timeline, commissions, forex_fees, fees, rate_of_return, return_rate_timeframe, detailed_mode].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



245
246
247
248
# File 'lib/snaptrade/models/performance_custom.rb', line 245

def list_invalid_properties
  invalid_properties = Array.new
  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



375
376
377
# File 'lib/snaptrade/models/performance_custom.rb', line 375

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



381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/snaptrade/models/performance_custom.rb', line 381

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



369
370
371
# File 'lib/snaptrade/models/performance_custom.rb', line 369

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



252
253
254
# File 'lib/snaptrade/models/performance_custom.rb', line 252

def valid?
  true
end