snaptrade 3.0.2 → 3.0.4

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.
@@ -0,0 +1,288 @@
1
+ =begin
2
+ #SnapTrade
3
+
4
+ #Connect brokerage accounts to your app for live positions and trading
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: api@snaptrade.com
8
+ =end
9
+
10
+ require 'date'
11
+ require 'time'
12
+
13
+ module SnapTrade
14
+ class UserAumPercentileResponseData
15
+ # The band the user falls into. Deliberately coarse: the underlying totals are only as current as each brokerage's last sync, so an exact percentile would imply more precision than the data supports.
16
+ attr_accessor :bucket
17
+
18
+ # The percent of the cohort the user's assets are strictly above, 0-100. Integer by design: the distribution is stored as 101 interpolated cutoffs, so a fractional percentile would not mean anything. Prefer `bucket` for anything you display prominently. The distribution is recomputed monthly, so a user's percentile can move a few points on its own as other users' holdings refresh, while their bucket stays put. Users tied on the same total all receive the lowest percentile that total spans.
19
+ attr_accessor :percentile
20
+
21
+ # Number of your users the distribution was computed from.
22
+ attr_accessor :cohort_size
23
+
24
+ # The month whose distribution produced this placement.
25
+ attr_accessor :as_of
26
+
27
+ # The currency the distribution was computed in.
28
+ attr_accessor :currency
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'bucket' => :'bucket',
34
+ :'percentile' => :'percentile',
35
+ :'cohort_size' => :'cohort_size',
36
+ :'as_of' => :'as_of',
37
+ :'currency' => :'currency'
38
+ }
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'bucket' => :'Bucket',
50
+ :'percentile' => :'Integer',
51
+ :'cohort_size' => :'Integer',
52
+ :'as_of' => :'Date',
53
+ :'currency' => :'String'
54
+ }
55
+ end
56
+
57
+ # List of attributes with nullable: true
58
+ def self.openapi_nullable
59
+ Set.new([
60
+ ])
61
+ end
62
+
63
+ # List of class defined in allOf (OpenAPI v3)
64
+ def self.openapi_all_of
65
+ [
66
+ :'UserAumPercentileObject'
67
+ ]
68
+ end
69
+
70
+ # Initializes the object
71
+ # @param [Hash] attributes Model attributes in the form of hash
72
+ def initialize(attributes = {})
73
+ if (!attributes.is_a?(Hash))
74
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::UserAumPercentileResponseData` initialize method"
75
+ end
76
+
77
+ # check to see if the attribute exists and convert string to symbol for hash key
78
+ attributes = attributes.each_with_object({}) { |(k, v), h|
79
+ if (!self.class.attribute_map.key?(k.to_sym))
80
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::UserAumPercentileResponseData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
81
+ end
82
+ h[k.to_sym] = v
83
+ }
84
+
85
+ if attributes.key?(:'bucket')
86
+ self.bucket = attributes[:'bucket']
87
+ end
88
+
89
+ if attributes.key?(:'percentile')
90
+ self.percentile = attributes[:'percentile']
91
+ end
92
+
93
+ if attributes.key?(:'cohort_size')
94
+ self.cohort_size = attributes[:'cohort_size']
95
+ end
96
+
97
+ if attributes.key?(:'as_of')
98
+ self.as_of = attributes[:'as_of']
99
+ end
100
+
101
+ if attributes.key?(:'currency')
102
+ self.currency = attributes[:'currency']
103
+ end
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properties with the reasons
108
+ def list_invalid_properties
109
+ invalid_properties = Array.new
110
+ if !@percentile.nil? && @percentile > 100
111
+ invalid_properties.push('invalid value for "percentile", must be smaller than or equal to 100.')
112
+ end
113
+
114
+ if !@percentile.nil? && @percentile < 0
115
+ invalid_properties.push('invalid value for "percentile", must be greater than or equal to 0.')
116
+ end
117
+
118
+ invalid_properties
119
+ end
120
+
121
+ # Check to see if the all the properties in the model are valid
122
+ # @return true if the model is valid
123
+ def valid?
124
+ return false if !@percentile.nil? && @percentile > 100
125
+ return false if !@percentile.nil? && @percentile < 0
126
+ true
127
+ end
128
+
129
+ # Custom attribute writer method with validation
130
+ # @param [Object] percentile Value to be assigned
131
+ def percentile=(percentile)
132
+ if !percentile.nil? && percentile > 100
133
+ fail ArgumentError, 'invalid value for "percentile", must be smaller than or equal to 100.'
134
+ end
135
+
136
+ if !percentile.nil? && percentile < 0
137
+ fail ArgumentError, 'invalid value for "percentile", must be greater than or equal to 0.'
138
+ end
139
+
140
+ @percentile = percentile
141
+ end
142
+
143
+ # Checks equality by comparing each attribute.
144
+ # @param [Object] Object to be compared
145
+ def ==(o)
146
+ return true if self.equal?(o)
147
+ self.class == o.class &&
148
+ bucket == o.bucket &&
149
+ percentile == o.percentile &&
150
+ cohort_size == o.cohort_size &&
151
+ as_of == o.as_of &&
152
+ currency == o.currency
153
+ end
154
+
155
+ # @see the `==` method
156
+ # @param [Object] Object to be compared
157
+ def eql?(o)
158
+ self == o
159
+ end
160
+
161
+ # Calculates hash code according to all attributes.
162
+ # @return [Integer] Hash code
163
+ def hash
164
+ [bucket, percentile, cohort_size, as_of, currency].hash
165
+ end
166
+
167
+ # Builds the object from hash
168
+ # @param [Hash] attributes Model attributes in the form of hash
169
+ # @return [Object] Returns the model itself
170
+ def self.build_from_hash(attributes)
171
+ new.build_from_hash(attributes)
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def build_from_hash(attributes)
178
+ return nil unless attributes.is_a?(Hash)
179
+ attributes = attributes.transform_keys(&:to_sym)
180
+ self.class.openapi_types.each_pair do |key, type|
181
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
182
+ self.send("#{key}=", nil)
183
+ elsif type =~ /\AArray<(.*)>/i
184
+ # check to ensure the input is an array given that the attribute
185
+ # is documented as an array but the input is not
186
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
187
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
188
+ end
189
+ elsif !attributes[self.class.attribute_map[key]].nil?
190
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
191
+ end
192
+ end
193
+
194
+ self
195
+ end
196
+
197
+ # Deserializes the data based on type
198
+ # @param string type Data type
199
+ # @param string value Value to be deserialized
200
+ # @return [Object] Deserialized data
201
+ def _deserialize(type, value)
202
+ case type.to_sym
203
+ when :Time
204
+ Time.parse(value)
205
+ when :Date
206
+ Date.parse(value)
207
+ when :String
208
+ value.to_s
209
+ when :Integer
210
+ value.to_i
211
+ when :Float
212
+ value.to_f
213
+ when :Boolean
214
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
215
+ true
216
+ else
217
+ false
218
+ end
219
+ when :Object
220
+ # generic object (usually a Hash), return directly
221
+ value
222
+ when /\AArray<(?<inner_type>.+)>\z/
223
+ inner_type = Regexp.last_match[:inner_type]
224
+ value.map { |v| _deserialize(inner_type, v) }
225
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
226
+ k_type = Regexp.last_match[:k_type]
227
+ v_type = Regexp.last_match[:v_type]
228
+ {}.tap do |hash|
229
+ value.each do |k, v|
230
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
231
+ end
232
+ end
233
+ else # model
234
+ # models (e.g. Pet) or oneOf
235
+ klass = SnapTrade.const_get(type)
236
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
237
+ end
238
+ end
239
+
240
+ # Returns the string representation of the object
241
+ # @return [String] String presentation of the object
242
+ def to_s
243
+ to_hash.to_s
244
+ end
245
+
246
+ # to_body is an alias to to_hash (backward compatibility)
247
+ # @return [Hash] Returns the object in the form of hash
248
+ def to_body
249
+ to_hash
250
+ end
251
+
252
+ # Returns the object in the form of hash
253
+ # @return [Hash] Returns the object in the form of hash
254
+ def to_hash
255
+ hash = {}
256
+ self.class.attribute_map.each_pair do |attr, param|
257
+ value = self.send(attr)
258
+ if value.nil?
259
+ is_nullable = self.class.openapi_nullable.include?(attr)
260
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
261
+ end
262
+
263
+ hash[param] = _to_hash(value)
264
+ end
265
+ hash
266
+ end
267
+
268
+ # Outputs non-array value in the form of hash
269
+ # For object, use to_hash. Otherwise, just return the value
270
+ # @param [Object] value Any valid value
271
+ # @return [Hash] Returns the value in the form of hash
272
+ def _to_hash(value)
273
+ if value.is_a?(Array)
274
+ value.compact.map { |v| _to_hash(v) }
275
+ elsif value.is_a?(Hash)
276
+ {}.tap do |hash|
277
+ value.each { |k, v| hash[k] = _to_hash(v) }
278
+ end
279
+ elsif value.respond_to? :to_hash
280
+ value.to_hash
281
+ else
282
+ value
283
+ end
284
+ end
285
+
286
+ end
287
+
288
+ end
@@ -8,5 +8,5 @@ Contact: api@snaptrade.com
8
8
  =end
9
9
 
10
10
  module SnapTrade
11
- VERSION = '3.0.2'
11
+ VERSION = '3.0.4'
12
12
  end
data/lib/snaptrade.rb CHANGED
@@ -68,6 +68,7 @@ require 'snaptrade/models/brokerage_authorization_type_read_only_type'
68
68
  require 'snaptrade/models/brokerage_instrument'
69
69
  require 'snaptrade/models/brokerage_instruments_response'
70
70
  require 'snaptrade/models/brokerage_type'
71
+ require 'snaptrade/models/bucket'
71
72
  require 'snaptrade/models/cancel_order_response'
72
73
  require 'snaptrade/models/cash_change_direction'
73
74
  require 'snaptrade/models/cef_instrument'
@@ -236,6 +237,9 @@ require 'snaptrade/models/underlying_symbol_exchange'
236
237
  require 'snaptrade/models/underlying_symbol_type'
237
238
  require 'snaptrade/models/universal_activity'
238
239
  require 'snaptrade/models/universal_symbol'
240
+ require 'snaptrade/models/user_aum_percentile_object'
241
+ require 'snaptrade/models/user_aum_percentile_response'
242
+ require 'snaptrade/models/user_aum_percentile_response_data'
239
243
  require 'snaptrade/models/user_i_dand_secret'
240
244
  require 'snaptrade/models/validated_trade_body'
241
245
 
@@ -163,6 +163,19 @@ describe 'AccountInformationApi' do
163
163
  end
164
164
  end
165
165
 
166
+ # unit tests for get_user_aum_percentile
167
+ # Get the user&#39;s AUM percentile
168
+ # Returns where the user&#39;s total assets sit within the distribution of a cohort of comparable users, as a coarse bucket plus an integer percentile. The cohort is scoped to your own book: a user is only ever compared against your other users, never across SnapTrade customers. (Users on personal-use keys are the exception — they are compared against all other personal-use users, since a personal key has a single user and cannot form a distribution of its own.) The distribution is recomputed monthly, and &#x60;as_of&#x60; reports which month&#39;s distribution the placement came from. &#x60;data&#x60; is &#x60;null&#x60; — a 200, not an error — when SnapTrade declines to place the user. That happens when the cohort is too small to publish a distribution, or when the user&#39;s own holdings are incomplete or stale (for example they hold a disabled connection). A placement computed from a partial view of a user&#39;s assets would understate them, so none is returned.
169
+ # @param user_id
170
+ # @param user_secret
171
+ # @param [Hash] opts the optional parameters
172
+ # @return [UserAumPercentileResponse]
173
+ describe 'get_user_aum_percentile test' do
174
+ it 'should work' do
175
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
176
+ end
177
+ end
178
+
166
179
  # unit tests for get_user_holdings
167
180
  # List account holdings
168
181
  # **Deprecated.** Use the finer-grained account data endpoints instead: [balances](/reference/Account%20Information/AccountInformation_getUserAccountBalance), [positions](/reference/Account%20Information/AccountInformation_getAllAccountPositions), and [orders](/reference/Account%20Information/AccountInformation_getUserAccountOrders). This endpoint will return HTTP 410 Gone for all customers that sign up after May 11, 2026. Returns a list of balances, positions, and recent orders for the specified account. Check your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing) to see if you have real-time data access: - If you do, this endpoint returns real-time data. - If you don&#39;t, Daily data is cached and refreshed once a day. Exact refresh timing may vary by brokerage. If you need real-time, use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint. If the connection has become disabled, it can no longer access the latest data from the brokerage, but will continue to return the last available cached state. Please see [this guide](/docs/fix-broken-connections) on how to fix a disabled connection.
@@ -0,0 +1,23 @@
1
+ =begin
2
+ #SnapTrade
3
+
4
+ #Connect brokerage accounts to your app for live positions and trading
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: api@snaptrade.com
8
+ =end
9
+
10
+ require 'spec_helper'
11
+ require 'json'
12
+ require 'date'
13
+
14
+ # Unit tests for SnapTrade::Bucket
15
+ describe SnapTrade::Bucket do
16
+ let(:instance) { SnapTrade::Bucket.new }
17
+
18
+ describe 'test an instance of Bucket' do
19
+ it 'should create an instance of Bucket' do
20
+ expect(instance).to be_instance_of(SnapTrade::Bucket)
21
+ end
22
+ end
23
+ end
@@ -62,6 +62,12 @@ describe SnapTrade::SnapTradeLoginUserRequestBody do
62
62
  end
63
63
  end
64
64
 
65
+ describe 'test attribute "locale"' do
66
+ it 'should work' do
67
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
68
+ end
69
+ end
70
+
65
71
  describe 'test attribute "connection_portal_version"' do
66
72
  it 'should work' do
67
73
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
@@ -0,0 +1,53 @@
1
+ =begin
2
+ #SnapTrade
3
+
4
+ #Connect brokerage accounts to your app for live positions and trading
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: api@snaptrade.com
8
+ =end
9
+
10
+ require 'spec_helper'
11
+ require 'json'
12
+ require 'date'
13
+
14
+ # Unit tests for SnapTrade::UserAumPercentileObject
15
+ describe SnapTrade::UserAumPercentileObject do
16
+ let(:instance) { SnapTrade::UserAumPercentileObject.new }
17
+
18
+ describe 'test an instance of UserAumPercentileObject' do
19
+ it 'should create an instance of UserAumPercentileObject' do
20
+ expect(instance).to be_instance_of(SnapTrade::UserAumPercentileObject)
21
+ end
22
+ end
23
+ describe 'test attribute "bucket"' do
24
+ it 'should work' do
25
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
26
+ end
27
+ end
28
+
29
+ describe 'test attribute "percentile"' do
30
+ it 'should work' do
31
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
32
+ end
33
+ end
34
+
35
+ describe 'test attribute "cohort_size"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ describe 'test attribute "as_of"' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ describe 'test attribute "currency"' do
48
+ it 'should work' do
49
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,53 @@
1
+ =begin
2
+ #SnapTrade
3
+
4
+ #Connect brokerage accounts to your app for live positions and trading
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: api@snaptrade.com
8
+ =end
9
+
10
+ require 'spec_helper'
11
+ require 'json'
12
+ require 'date'
13
+
14
+ # Unit tests for SnapTrade::UserAumPercentileResponseData
15
+ describe SnapTrade::UserAumPercentileResponseData do
16
+ let(:instance) { SnapTrade::UserAumPercentileResponseData.new }
17
+
18
+ describe 'test an instance of UserAumPercentileResponseData' do
19
+ it 'should create an instance of UserAumPercentileResponseData' do
20
+ expect(instance).to be_instance_of(SnapTrade::UserAumPercentileResponseData)
21
+ end
22
+ end
23
+ describe 'test attribute "bucket"' do
24
+ it 'should work' do
25
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
26
+ end
27
+ end
28
+
29
+ describe 'test attribute "percentile"' do
30
+ it 'should work' do
31
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
32
+ end
33
+ end
34
+
35
+ describe 'test attribute "cohort_size"' do
36
+ it 'should work' do
37
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
38
+ end
39
+ end
40
+
41
+ describe 'test attribute "as_of"' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ describe 'test attribute "currency"' do
48
+ it 'should work' do
49
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,29 @@
1
+ =begin
2
+ #SnapTrade
3
+
4
+ #Connect brokerage accounts to your app for live positions and trading
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: api@snaptrade.com
8
+ =end
9
+
10
+ require 'spec_helper'
11
+ require 'json'
12
+ require 'date'
13
+
14
+ # Unit tests for SnapTrade::UserAumPercentileResponse
15
+ describe SnapTrade::UserAumPercentileResponse do
16
+ let(:instance) { SnapTrade::UserAumPercentileResponse.new }
17
+
18
+ describe 'test an instance of UserAumPercentileResponse' do
19
+ it 'should create an instance of UserAumPercentileResponse' do
20
+ expect(instance).to be_instance_of(SnapTrade::UserAumPercentileResponse)
21
+ end
22
+ end
23
+ describe 'test attribute "data"' do
24
+ it 'should work' do
25
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
26
+ end
27
+ end
28
+
29
+ end