snaptrade 3.0.29 → 3.0.31

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +202 -2
  3. data/lib/snaptrade/api/account_information_api.rb +6 -2
  4. data/lib/snaptrade/api/experimental_endpoints_api.rb +406 -0
  5. data/lib/snaptrade/models/account_position.rb +1 -1
  6. data/lib/snaptrade/models/account_value_history_response.rb +1 -1
  7. data/lib/snaptrade/models/all_user_accounts_response.rb +225 -0
  8. data/lib/snaptrade/models/{account_type.rb → cash_or_margin.rb} +3 -3
  9. data/lib/snaptrade/models/connection_account.rb +1 -1
  10. data/lib/snaptrade/models/institution.rb +1 -1
  11. data/lib/snaptrade/models/investment_account.rb +8 -8
  12. data/lib/snaptrade/models/position.rb +1 -1
  13. data/lib/snaptrade/models/release_stage.rb +2 -1
  14. data/lib/snaptrade/models/simple_trade_form.rb +346 -0
  15. data/lib/snaptrade/models/simple_trade_form_order_type.rb +39 -0
  16. data/lib/snaptrade/models/simple_trade_form_price_effect.rb +38 -0
  17. data/lib/snaptrade/models/simple_trade_form_time_in_force.rb +40 -0
  18. data/lib/snaptrade/models/simple_trade_form_trading_session.rb +37 -0
  19. data/lib/snaptrade/models/simple_trade_instrument.rb +255 -0
  20. data/lib/snaptrade/models/simple_trade_instrument_kind.rb +39 -0
  21. data/lib/snaptrade/models/simple_trade_leg.rb +246 -0
  22. data/lib/snaptrade/models/simple_trade_leg_action.rb +41 -0
  23. data/lib/snaptrade/models/simple_trade_response.rb +222 -0
  24. data/lib/snaptrade/version.rb +1 -1
  25. data/lib/snaptrade.rb +12 -1
  26. data/spec/api/account_information_api_spec.rb +1 -1
  27. data/spec/api/experimental_endpoints_api_spec.rb +42 -0
  28. data/spec/models/all_user_accounts_response_spec.rb +29 -0
  29. data/spec/models/{account_type_spec.rb → cash_or_margin_spec.rb} +6 -6
  30. data/spec/models/investment_account_spec.rb +1 -1
  31. data/spec/models/simple_trade_form_order_type_spec.rb +23 -0
  32. data/spec/models/simple_trade_form_price_effect_spec.rb +23 -0
  33. data/spec/models/simple_trade_form_spec.rb +83 -0
  34. data/spec/models/simple_trade_form_time_in_force_spec.rb +23 -0
  35. data/spec/models/simple_trade_form_trading_session_spec.rb +23 -0
  36. data/spec/models/simple_trade_instrument_kind_spec.rb +23 -0
  37. data/spec/models/simple_trade_instrument_spec.rb +35 -0
  38. data/spec/models/simple_trade_leg_action_spec.rb +23 -0
  39. data/spec/models/simple_trade_leg_spec.rb +41 -0
  40. data/spec/models/simple_trade_response_spec.rb +29 -0
  41. metadata +264 -231
@@ -0,0 +1,225 @@
1
+ =begin
2
+ #SnapTrade
3
+
4
+ #Connect brokerage accounts to your app for live positions and trading. ## Rate limiting Two limits apply to requests signed with your `clientId`. The stricter one wins, and exceeding either returns `429 Too Many Requests`. - **Customer-level** — 250 requests/minute by default, scoped to your `clientId` and applied across all endpoints. Reported in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. - **Account-level** — 10 requests/minute per account, scoped to (`clientId`, `accountId`). All covered operations for one account draw on the same bucket — reading balances and reading positions share it — and enforcement does not depend on the HTTP method, so updating an account consumes the same bucket as reading it. Only enforced for Personal users, and only for integrations it has been rolled out to — it is not yet in force for every Personal integration. It also does not apply on every operation that documents a 429 below. Where it applies it is reported in `X-RateLimit-Account-Limit`, `X-RateLimit-Account-Remaining` and `X-RateLimit-Account-Reset`. Do not read the absence of those headers as proof the limit is off — some configurations omit the rate limit headers while still enforcing the limit, so header absence tells you nothing about your allowance. On a 429, `X-RateLimit-Remaining: 0` means you hit the customer-level limit and `X-RateLimit-Account-Remaining: 0` means the account-level one. Wait for the corresponding `*-Reset` value (seconds) before retrying, or fall back to exponential backoff with jitter. Not every 429 is explained by those headers. A separate per-authenticated-user limit, reported in no `X-RateLimit-*` header, covers OAuth-authenticated requests and signed requests in configurations where the customer-level limit is not in effect — on the operations that use the default throttles. A few operations override those and are governed by the customer-level limit alone. The two do not stack: a signed request governed by the customer-level limit above is not additionally subject to the per-user one. If a 429 arrives with no header at zero — or with no `X-RateLimit-*` headers at all — honour `Retry-After` and back off. Treat the remaining counts as a hint, not a guarantee that the next request will succeed. Because the customer-level limit applies everywhere, any signed request can return 429. **OAuth-authenticated requests are an exception.** They are not subject to the customer-level limit and do not receive `X-RateLimit-Limit`, `X-RateLimit-Remaining` or `X-RateLimit-Reset` — do not wait on those headers or design around a customer-level allowance on this path. The account-level limit still applies to them on the account-data endpoints above, reported in the `X-RateLimit-Account-*` headers. On operations using the default throttles the per-user limit above applies to them as well, so an OAuth request can be rejected while the account headers still show capacity; on the few operations that override those throttles, OAuth callers have no per-user ceiling at all. Drive retries from `Retry-After` and exponential backoff with jitter rather than from the headers. See https://docs.snaptrade.com/docs/ratelimiting.
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
+ # Accounts across all of the user's connections.
15
+ class AllUserAccountsResponse
16
+ # Accounts returned for the request.
17
+ attr_accessor :results
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'results' => :'results'
23
+ }
24
+ end
25
+
26
+ # Returns all the JSON keys this model knows about
27
+ def self.acceptable_attributes
28
+ attribute_map.values
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'results' => :'Array<ConnectionAccount>'
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new([
41
+ ])
42
+ end
43
+
44
+ # Initializes the object
45
+ # @param [Hash] attributes Model attributes in the form of hash
46
+ def initialize(attributes = {})
47
+ if (!attributes.is_a?(Hash))
48
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::AllUserAccountsResponse` initialize method"
49
+ end
50
+
51
+ # check to see if the attribute exists and convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}) { |(k, v), h|
53
+ if (!self.class.attribute_map.key?(k.to_sym))
54
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::AllUserAccountsResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
+ end
56
+ h[k.to_sym] = v
57
+ }
58
+
59
+ if attributes.key?(:'results')
60
+ if (value = attributes[:'results']).is_a?(Array)
61
+ self.results = value
62
+ end
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ if @results.nil?
71
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
72
+ end
73
+
74
+ invalid_properties
75
+ end
76
+
77
+ # Check to see if the all the properties in the model are valid
78
+ # @return true if the model is valid
79
+ def valid?
80
+ return false if @results.nil?
81
+ true
82
+ end
83
+
84
+ # Checks equality by comparing each attribute.
85
+ # @param [Object] Object to be compared
86
+ def ==(o)
87
+ return true if self.equal?(o)
88
+ self.class == o.class &&
89
+ results == o.results
90
+ end
91
+
92
+ # @see the `==` method
93
+ # @param [Object] Object to be compared
94
+ def eql?(o)
95
+ self == o
96
+ end
97
+
98
+ # Calculates hash code according to all attributes.
99
+ # @return [Integer] Hash code
100
+ def hash
101
+ [results].hash
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def self.build_from_hash(attributes)
108
+ new.build_from_hash(attributes)
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ attributes = attributes.transform_keys(&:to_sym)
117
+ self.class.openapi_types.each_pair do |key, type|
118
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
119
+ self.send("#{key}=", nil)
120
+ elsif type =~ /\AArray<(.*)>/i
121
+ # check to ensure the input is an array given that the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
124
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
125
+ end
126
+ elsif !attributes[self.class.attribute_map[key]].nil?
127
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
128
+ end
129
+ end
130
+
131
+ self
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def _deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = SnapTrade.const_get(type)
173
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ end
@@ -11,7 +11,7 @@ require 'date'
11
11
  require 'time'
12
12
 
13
13
  module SnapTrade
14
- class AccountType
14
+ class CashOrMargin
15
15
  CASH = "cash".freeze
16
16
  MARGIN = "margin".freeze
17
17
  UNKNOWN = "unknown".freeze
@@ -31,8 +31,8 @@ module SnapTrade
31
31
  # @param [String] The enum value in the form of the string
32
32
  # @return [String] The enum value
33
33
  def build_from_hash(value)
34
- return value if AccountType.all_vars.include?(value)
35
- raise "Invalid ENUM value #{value} for class #AccountType"
34
+ return value if CashOrMargin.all_vars.include?(value)
35
+ raise "Invalid ENUM value #{value} for class #CashOrMargin"
36
36
  end
37
37
  end
38
38
  end
@@ -11,7 +11,7 @@ require 'date'
11
11
  require 'time'
12
12
 
13
13
  module SnapTrade
14
- # A single account under a connection, from the `kind`-discriminated union used by `Connections_listConnectionAccounts`. Use `kind` to determine which schema is present. `investment`, `deposit`, and `line_of_credit` are implemented today.
14
+ # A single account under a connection, from the `kind`-discriminated union used by `Connections_listConnectionAccounts` and `AccountInformation_listAllUserAccounts`. Use `kind` to determine which schema is present. `investment`, `deposit`, and `line_of_credit` are implemented today.
15
15
  module ConnectionAccount
16
16
  class << self
17
17
  # List of class defined in oneOf (OpenAPI v3)
@@ -34,7 +34,7 @@ module SnapTrade
34
34
  # URL of the institution's square logo.
35
35
  attr_accessor :square_logo_url
36
36
 
37
- # How mature the integration is. - `GENERALLY_AVAILABLE`: fully supported and validated for production use. - `BETA`: production-ready, with ongoing validation and improvements.
37
+ # How mature the integration is. - `GENERALLY_AVAILABLE`: fully supported and validated for production use. - `BETA`: production-ready, with ongoing validation and improvements. - `ALPHA`: early access with limited validation. Expect issues and incomplete functionality.
38
38
  attr_accessor :release_stage
39
39
 
40
40
  # Regions where end users can connect to this institution. - `US`: United States - `CA`: Canada - `EUROPE`: Europe, including the United Kingdom - `AU`: Australia - `IN`: India
@@ -11,7 +11,7 @@ require 'date'
11
11
  require 'time'
12
12
 
13
13
  module SnapTrade
14
- # An investment account under a connection. `opening_date`, `funding_date`, and `net_value` are real-time or cached depending on the caller's plan -- see `Connections_listConnectionAccounts`.
14
+ # An investment account under a connection. `opening_date`, `funding_date`, and `net_value` are real-time or cached depending on the caller's plan -- see `Connections_listConnectionAccounts` -- and always cached on `AccountInformation_listAllUserAccounts`.
15
15
  class InvestmentAccount
16
16
  # Discriminator for the account kind.
17
17
  attr_accessor :kind
@@ -46,7 +46,7 @@ module SnapTrade
46
46
  attr_accessor :raw_type
47
47
 
48
48
  # Whether the institution reports the account as a cash or margin account, normalized across institutions. - `cash`: A cash account. The account cannot borrow on margin. - `margin`: A margin account, including portfolio margin accounts. Some institutions also report retirement accounts with limited margin (for example, trading before funds settle) as margin accounts. - `unknown`: The institution does not report whether the account is cash or margin. **Beta:** only returned for some institutions and partners it has been enabled for. Omitted otherwise.
49
- attr_accessor :account_type
49
+ attr_accessor :cash_or_margin
50
50
 
51
51
  # Indicates whether the account is a paper (simulated) trading account.
52
52
  attr_accessor :is_paper
@@ -67,7 +67,7 @@ module SnapTrade
67
67
  :'funding_date' => :'funding_date',
68
68
  :'sync_status' => :'sync_status',
69
69
  :'raw_type' => :'raw_type',
70
- :'account_type' => :'account_type',
70
+ :'cash_or_margin' => :'cash_or_margin',
71
71
  :'is_paper' => :'is_paper',
72
72
  :'net_value' => :'net_value'
73
73
  }
@@ -92,7 +92,7 @@ module SnapTrade
92
92
  :'funding_date' => :'Time',
93
93
  :'sync_status' => :'ConnectionAccountSyncStatus',
94
94
  :'raw_type' => :'String',
95
- :'account_type' => :'AccountType',
95
+ :'cash_or_margin' => :'CashOrMargin',
96
96
  :'is_paper' => :'Boolean',
97
97
  :'net_value' => :'InvestmentAccountNetValue'
98
98
  }
@@ -169,8 +169,8 @@ module SnapTrade
169
169
  self.raw_type = attributes[:'raw_type']
170
170
  end
171
171
 
172
- if attributes.key?(:'account_type')
173
- self.account_type = attributes[:'account_type']
172
+ if attributes.key?(:'cash_or_margin')
173
+ self.cash_or_margin = attributes[:'cash_or_margin']
174
174
  end
175
175
 
176
176
  if attributes.key?(:'is_paper')
@@ -241,7 +241,7 @@ module SnapTrade
241
241
  funding_date == o.funding_date &&
242
242
  sync_status == o.sync_status &&
243
243
  raw_type == o.raw_type &&
244
- account_type == o.account_type &&
244
+ cash_or_margin == o.cash_or_margin &&
245
245
  is_paper == o.is_paper &&
246
246
  net_value == o.net_value
247
247
  end
@@ -255,7 +255,7 @@ module SnapTrade
255
255
  # Calculates hash code according to all attributes.
256
256
  # @return [Integer] Hash code
257
257
  def hash
258
- [kind, id, connection_id, display_name, masked_account_number, institution_account_id, institution_id, opening_date, funding_date, sync_status, raw_type, account_type, is_paper, net_value].hash
258
+ [kind, id, connection_id, display_name, masked_account_number, institution_account_id, institution_id, opening_date, funding_date, sync_status, raw_type, cash_or_margin, is_paper, net_value].hash
259
259
  end
260
260
 
261
261
  # Builds the object from hash
@@ -35,7 +35,7 @@ module SnapTrade
35
35
  # If the position is a cash equivalent (usually a money market fund) that is also counted in account cash balance and buying power
36
36
  attr_accessor :cash_equivalent
37
37
 
38
- # List of tax lots for the given position. Disabled by default, only available on paid plans, enable this feature in the [Add-on page of the Customer Dashboard](https://dashboard.snaptrade.com/add-ons)
38
+ # List of tax lots for the given position. Disabled by default, enable this feature in the [Add-on page of the Customer Dashboard](https://dashboard.snaptrade.com/add-ons)
39
39
  attr_accessor :tax_lots
40
40
 
41
41
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -14,9 +14,10 @@ module SnapTrade
14
14
  class ReleaseStage
15
15
  GENERALLY_AVAILABLE = "GENERALLY_AVAILABLE".freeze
16
16
  BETA = "BETA".freeze
17
+ ALPHA = "ALPHA".freeze
17
18
 
18
19
  def self.all_vars
19
- @all_vars ||= [GENERALLY_AVAILABLE, BETA].freeze
20
+ @all_vars ||= [GENERALLY_AVAILABLE, BETA, ALPHA].freeze
20
21
  end
21
22
 
22
23
  # Builds the enum from string