snaptrade 3.0.30 → 3.0.32

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +120 -2
  3. data/lib/snaptrade/api/account_information_api.rb +12 -4
  4. data/lib/snaptrade/api/experimental_endpoints_api.rb +176 -0
  5. data/lib/snaptrade/models/account_information_get_user_holdings409_response.rb +234 -0
  6. data/lib/snaptrade/models/account_position.rb +1 -1
  7. data/lib/snaptrade/models/account_value_history_response.rb +1 -1
  8. data/lib/snaptrade/models/{account_type.rb → cash_or_margin.rb} +3 -3
  9. data/lib/snaptrade/models/institution.rb +1 -1
  10. data/lib/snaptrade/models/investment_account.rb +7 -7
  11. data/lib/snaptrade/models/position.rb +1 -1
  12. data/lib/snaptrade/models/release_stage.rb +2 -1
  13. data/lib/snaptrade/models/simple_trade_form.rb +346 -0
  14. data/lib/snaptrade/models/simple_trade_form_order_type.rb +39 -0
  15. data/lib/snaptrade/models/simple_trade_form_price_effect.rb +38 -0
  16. data/lib/snaptrade/models/simple_trade_form_time_in_force.rb +40 -0
  17. data/lib/snaptrade/models/simple_trade_form_trading_session.rb +37 -0
  18. data/lib/snaptrade/models/simple_trade_instrument.rb +255 -0
  19. data/lib/snaptrade/models/simple_trade_instrument_kind.rb +39 -0
  20. data/lib/snaptrade/models/simple_trade_leg.rb +246 -0
  21. data/lib/snaptrade/models/simple_trade_leg_action.rb +41 -0
  22. data/lib/snaptrade/models/simple_trade_response.rb +222 -0
  23. data/lib/snaptrade/version.rb +1 -1
  24. data/lib/snaptrade.rb +12 -1
  25. data/spec/api/account_information_api_spec.rb +2 -2
  26. data/spec/api/experimental_endpoints_api_spec.rb +15 -0
  27. data/spec/models/account_information_get_user_holdings409_response_spec.rb +41 -0
  28. data/spec/models/{account_type_spec.rb → cash_or_margin_spec.rb} +6 -6
  29. data/spec/models/investment_account_spec.rb +1 -1
  30. data/spec/models/simple_trade_form_order_type_spec.rb +23 -0
  31. data/spec/models/simple_trade_form_price_effect_spec.rb +23 -0
  32. data/spec/models/simple_trade_form_spec.rb +83 -0
  33. data/spec/models/simple_trade_form_time_in_force_spec.rb +23 -0
  34. data/spec/models/simple_trade_form_trading_session_spec.rb +23 -0
  35. data/spec/models/simple_trade_instrument_kind_spec.rb +23 -0
  36. data/spec/models/simple_trade_instrument_spec.rb +35 -0
  37. data/spec/models/simple_trade_leg_action_spec.rb +23 -0
  38. data/spec/models/simple_trade_leg_spec.rb +41 -0
  39. data/spec/models/simple_trade_response_spec.rb +29 -0
  40. metadata +266 -233
@@ -0,0 +1,234 @@
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
+ class AccountInformationGetUserHoldings409Response
15
+ attr_accessor :detail
16
+
17
+ attr_accessor :status_code
18
+
19
+ attr_accessor :code
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'detail' => :'detail',
25
+ :'status_code' => :'status_code',
26
+ :'code' => :'code'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'detail' => :'String',
39
+ :'status_code' => :'Integer',
40
+ :'code' => :'String'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::AccountInformationGetUserHoldings409Response` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::AccountInformationGetUserHoldings409Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'detail')
66
+ self.detail = attributes[:'detail']
67
+ end
68
+
69
+ if attributes.key?(:'status_code')
70
+ self.status_code = attributes[:'status_code']
71
+ end
72
+
73
+ if attributes.key?(:'code')
74
+ self.code = attributes[:'code']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ detail == o.detail &&
97
+ status_code == o.status_code &&
98
+ code == o.code
99
+ end
100
+
101
+ # @see the `==` method
102
+ # @param [Object] Object to be compared
103
+ def eql?(o)
104
+ self == o
105
+ end
106
+
107
+ # Calculates hash code according to all attributes.
108
+ # @return [Integer] Hash code
109
+ def hash
110
+ [detail, status_code, code].hash
111
+ end
112
+
113
+ # Builds the object from hash
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ # @return [Object] Returns the model itself
116
+ def self.build_from_hash(attributes)
117
+ new.build_from_hash(attributes)
118
+ end
119
+
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
123
+ def build_from_hash(attributes)
124
+ return nil unless attributes.is_a?(Hash)
125
+ attributes = attributes.transform_keys(&:to_sym)
126
+ self.class.openapi_types.each_pair do |key, type|
127
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
128
+ self.send("#{key}=", nil)
129
+ elsif type =~ /\AArray<(.*)>/i
130
+ # check to ensure the input is an array given that the attribute
131
+ # is documented as an array but the input is not
132
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
133
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
134
+ end
135
+ elsif !attributes[self.class.attribute_map[key]].nil?
136
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
137
+ end
138
+ end
139
+
140
+ self
141
+ end
142
+
143
+ # Deserializes the data based on type
144
+ # @param string type Data type
145
+ # @param string value Value to be deserialized
146
+ # @return [Object] Deserialized data
147
+ def _deserialize(type, value)
148
+ case type.to_sym
149
+ when :Time
150
+ Time.parse(value)
151
+ when :Date
152
+ Date.parse(value)
153
+ when :String
154
+ value.to_s
155
+ when :Integer
156
+ value.to_i
157
+ when :Float
158
+ value.to_f
159
+ when :Boolean
160
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
161
+ true
162
+ else
163
+ false
164
+ end
165
+ when :Object
166
+ # generic object (usually a Hash), return directly
167
+ value
168
+ when /\AArray<(?<inner_type>.+)>\z/
169
+ inner_type = Regexp.last_match[:inner_type]
170
+ value.map { |v| _deserialize(inner_type, v) }
171
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
172
+ k_type = Regexp.last_match[:k_type]
173
+ v_type = Regexp.last_match[:v_type]
174
+ {}.tap do |hash|
175
+ value.each do |k, v|
176
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
177
+ end
178
+ end
179
+ else # model
180
+ # models (e.g. Pet) or oneOf
181
+ klass = SnapTrade.const_get(type)
182
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
183
+ end
184
+ end
185
+
186
+ # Returns the string representation of the object
187
+ # @return [String] String presentation of the object
188
+ def to_s
189
+ to_hash.to_s
190
+ end
191
+
192
+ # to_body is an alias to to_hash (backward compatibility)
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_body
195
+ to_hash
196
+ end
197
+
198
+ # Returns the object in the form of hash
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_hash
201
+ hash = {}
202
+ self.class.attribute_map.each_pair do |attr, param|
203
+ value = self.send(attr)
204
+ if value.nil?
205
+ is_nullable = self.class.openapi_nullable.include?(attr)
206
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
207
+ end
208
+
209
+ hash[param] = _to_hash(value)
210
+ end
211
+ hash
212
+ end
213
+
214
+ # Outputs non-array value in the form of hash
215
+ # For object, use to_hash. Otherwise, just return the value
216
+ # @param [Object] value Any valid value
217
+ # @return [Hash] Returns the value in the form of hash
218
+ def _to_hash(value)
219
+ if value.is_a?(Array)
220
+ value.compact.map { |v| _to_hash(v) }
221
+ elsif value.is_a?(Hash)
222
+ {}.tap do |hash|
223
+ value.each { |k, v| hash[k] = _to_hash(v) }
224
+ end
225
+ elsif value.respond_to? :to_hash
226
+ value.to_hash
227
+ else
228
+ value
229
+ end
230
+ end
231
+
232
+ end
233
+
234
+ end
@@ -30,7 +30,7 @@ module SnapTrade
30
30
  # Present for mutual fund positions and for other instrument kinds when true. A true value means the position is also counted in cash balance or buying power.
31
31
  attr_accessor :cash_equivalent
32
32
 
33
- # List of tax lots for the given position (disabled by default, only available on paid plans, contact support if needed)
33
+ # List of tax lots for the given position. Disabled by default; enable via the Customer Dashboard Add-ons page. When enabled, this field is included only for stocks, ADRs, ETFs, mutual funds, and crypto positions. For these positions, an empty list means no tax lot data is available. Availability varies by brokerage and position. This field is omitted for all other instrument kinds or when the feature is disabled.
34
34
  attr_accessor :tax_lots
35
35
 
36
36
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -13,7 +13,7 @@ require 'time'
13
13
  module SnapTrade
14
14
  # The response to the account value history endpoint, containing a list of estimated account values at different points in time.
15
15
  class AccountValueHistoryResponse
16
- # List of estimated account values over time returned by the endpoint.
16
+ # List of estimated account values over time returned by the endpoint. The data may contain gaps and is best used for charting trends, rather than as a complete or exact record of historical account values.
17
17
  attr_accessor :history
18
18
 
19
19
  # The ISO-4217 currency code for the account values.
@@ -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
@@ -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
@@ -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