snaptrade 3.0.53 → 3.0.55
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.
- checksums.yaml +4 -4
- data/README.md +53 -4
- data/lib/snaptrade/api/account_information_api.rb +6 -6
- data/lib/snaptrade/api/experimental_endpoints_api.rb +128 -0
- data/lib/snaptrade/models/account_position.rb +1 -1
- data/lib/snaptrade/models/all_account_orders_response.rb +1 -1
- data/lib/snaptrade/models/instrument.rb +2 -0
- data/lib/snaptrade/models/preferred_stock_instrument.rb +311 -0
- data/lib/snaptrade/models/preferred_stock_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/underlying_cfd_instrument.rb +2 -0
- data/lib/snaptrade/models/underlying_option_instrument.rb +2 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +2 -0
- data/spec/api/account_information_api_spec.rb +1 -1
- data/spec/api/experimental_endpoints_api_spec.rb +15 -0
- data/spec/models/preferred_stock_instrument_kind_spec.rb +23 -0
- data/spec/models/preferred_stock_instrument_spec.rb +71 -0
- metadata +286 -280
|
@@ -0,0 +1,311 @@
|
|
|
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
|
+
# Security instrument metadata for preferred stock positions. Preferred shares were previously returned with kind `other`.
|
|
15
|
+
class PreferredStockInstrument
|
|
16
|
+
# Type of security instrument.
|
|
17
|
+
attr_accessor :kind
|
|
18
|
+
|
|
19
|
+
# Unique identifier for the instrument.
|
|
20
|
+
attr_accessor :id
|
|
21
|
+
|
|
22
|
+
# The formatted trading symbol for the security.
|
|
23
|
+
attr_accessor :symbol
|
|
24
|
+
|
|
25
|
+
# The raw symbol without any exchange suffix.
|
|
26
|
+
attr_accessor :raw_symbol
|
|
27
|
+
|
|
28
|
+
# Human-readable description of the security.
|
|
29
|
+
attr_accessor :description
|
|
30
|
+
|
|
31
|
+
# ISO-4217 currency code for the security listing.
|
|
32
|
+
attr_accessor :currency
|
|
33
|
+
|
|
34
|
+
# Exchange MIC code or exchange code for the security.
|
|
35
|
+
attr_accessor :exchange
|
|
36
|
+
|
|
37
|
+
attr_accessor :figi_instrument
|
|
38
|
+
|
|
39
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
40
|
+
def self.attribute_map
|
|
41
|
+
{
|
|
42
|
+
:'kind' => :'kind',
|
|
43
|
+
:'id' => :'id',
|
|
44
|
+
:'symbol' => :'symbol',
|
|
45
|
+
:'raw_symbol' => :'raw_symbol',
|
|
46
|
+
:'description' => :'description',
|
|
47
|
+
:'currency' => :'currency',
|
|
48
|
+
:'exchange' => :'exchange',
|
|
49
|
+
:'figi_instrument' => :'figi_instrument'
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns all the JSON keys this model knows about
|
|
54
|
+
def self.acceptable_attributes
|
|
55
|
+
attribute_map.values
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Attribute type mapping.
|
|
59
|
+
def self.openapi_types
|
|
60
|
+
{
|
|
61
|
+
:'kind' => :'PreferredStockInstrumentKind',
|
|
62
|
+
:'id' => :'String',
|
|
63
|
+
:'symbol' => :'String',
|
|
64
|
+
:'raw_symbol' => :'String',
|
|
65
|
+
:'description' => :'String',
|
|
66
|
+
:'currency' => :'String',
|
|
67
|
+
:'exchange' => :'String',
|
|
68
|
+
:'figi_instrument' => :'StockInstrumentFigiInstrument'
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# List of attributes with nullable: true
|
|
73
|
+
def self.openapi_nullable
|
|
74
|
+
Set.new([
|
|
75
|
+
:'description',
|
|
76
|
+
:'currency',
|
|
77
|
+
:'exchange',
|
|
78
|
+
:'figi_instrument'
|
|
79
|
+
])
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Initializes the object
|
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
84
|
+
def initialize(attributes = {})
|
|
85
|
+
if (!attributes.is_a?(Hash))
|
|
86
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::PreferredStockInstrument` initialize method"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
90
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
91
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
92
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::PreferredStockInstrument`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
93
|
+
end
|
|
94
|
+
h[k.to_sym] = v
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if attributes.key?(:'kind')
|
|
98
|
+
self.kind = attributes[:'kind']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'id')
|
|
102
|
+
self.id = attributes[:'id']
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if attributes.key?(:'symbol')
|
|
106
|
+
self.symbol = attributes[:'symbol']
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if attributes.key?(:'raw_symbol')
|
|
110
|
+
self.raw_symbol = attributes[:'raw_symbol']
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if attributes.key?(:'description')
|
|
114
|
+
self.description = attributes[:'description']
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
if attributes.key?(:'currency')
|
|
118
|
+
self.currency = attributes[:'currency']
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if attributes.key?(:'exchange')
|
|
122
|
+
self.exchange = attributes[:'exchange']
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
if attributes.key?(:'figi_instrument')
|
|
126
|
+
self.figi_instrument = attributes[:'figi_instrument']
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
131
|
+
# @return Array for valid properties with the reasons
|
|
132
|
+
def list_invalid_properties
|
|
133
|
+
invalid_properties = Array.new
|
|
134
|
+
if @kind.nil?
|
|
135
|
+
invalid_properties.push('invalid value for "kind", kind cannot be nil.')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
if @id.nil?
|
|
139
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
if @symbol.nil?
|
|
143
|
+
invalid_properties.push('invalid value for "symbol", symbol cannot be nil.')
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
if @raw_symbol.nil?
|
|
147
|
+
invalid_properties.push('invalid value for "raw_symbol", raw_symbol cannot be nil.')
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
invalid_properties
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Check to see if the all the properties in the model are valid
|
|
154
|
+
# @return true if the model is valid
|
|
155
|
+
def valid?
|
|
156
|
+
return false if @kind.nil?
|
|
157
|
+
return false if @id.nil?
|
|
158
|
+
return false if @symbol.nil?
|
|
159
|
+
return false if @raw_symbol.nil?
|
|
160
|
+
true
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Checks equality by comparing each attribute.
|
|
164
|
+
# @param [Object] Object to be compared
|
|
165
|
+
def ==(o)
|
|
166
|
+
return true if self.equal?(o)
|
|
167
|
+
self.class == o.class &&
|
|
168
|
+
kind == o.kind &&
|
|
169
|
+
id == o.id &&
|
|
170
|
+
symbol == o.symbol &&
|
|
171
|
+
raw_symbol == o.raw_symbol &&
|
|
172
|
+
description == o.description &&
|
|
173
|
+
currency == o.currency &&
|
|
174
|
+
exchange == o.exchange &&
|
|
175
|
+
figi_instrument == o.figi_instrument
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# @see the `==` method
|
|
179
|
+
# @param [Object] Object to be compared
|
|
180
|
+
def eql?(o)
|
|
181
|
+
self == o
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Calculates hash code according to all attributes.
|
|
185
|
+
# @return [Integer] Hash code
|
|
186
|
+
def hash
|
|
187
|
+
[kind, id, symbol, raw_symbol, description, currency, exchange, figi_instrument].hash
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Builds the object from hash
|
|
191
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
192
|
+
# @return [Object] Returns the model itself
|
|
193
|
+
def self.build_from_hash(attributes)
|
|
194
|
+
new.build_from_hash(attributes)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Builds the object from hash
|
|
198
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
199
|
+
# @return [Object] Returns the model itself
|
|
200
|
+
def build_from_hash(attributes)
|
|
201
|
+
return nil unless attributes.is_a?(Hash)
|
|
202
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
203
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
204
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
205
|
+
self.send("#{key}=", nil)
|
|
206
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
207
|
+
# check to ensure the input is an array given that the attribute
|
|
208
|
+
# is documented as an array but the input is not
|
|
209
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
210
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
211
|
+
end
|
|
212
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
213
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
self
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Deserializes the data based on type
|
|
221
|
+
# @param string type Data type
|
|
222
|
+
# @param string value Value to be deserialized
|
|
223
|
+
# @return [Object] Deserialized data
|
|
224
|
+
def _deserialize(type, value)
|
|
225
|
+
case type.to_sym
|
|
226
|
+
when :Time
|
|
227
|
+
Time.parse(value)
|
|
228
|
+
when :Date
|
|
229
|
+
Date.parse(value)
|
|
230
|
+
when :String
|
|
231
|
+
value.to_s
|
|
232
|
+
when :Integer
|
|
233
|
+
value.to_i
|
|
234
|
+
when :Float
|
|
235
|
+
value.to_f
|
|
236
|
+
when :Boolean
|
|
237
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
238
|
+
true
|
|
239
|
+
else
|
|
240
|
+
false
|
|
241
|
+
end
|
|
242
|
+
when :Object
|
|
243
|
+
# generic object (usually a Hash), return directly
|
|
244
|
+
value
|
|
245
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
246
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
247
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
248
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
249
|
+
k_type = Regexp.last_match[:k_type]
|
|
250
|
+
v_type = Regexp.last_match[:v_type]
|
|
251
|
+
{}.tap do |hash|
|
|
252
|
+
value.each do |k, v|
|
|
253
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
else # model
|
|
257
|
+
# models (e.g. Pet) or oneOf
|
|
258
|
+
klass = SnapTrade.const_get(type)
|
|
259
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# Returns the string representation of the object
|
|
264
|
+
# @return [String] String presentation of the object
|
|
265
|
+
def to_s
|
|
266
|
+
to_hash.to_s
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
270
|
+
# @return [Hash] Returns the object in the form of hash
|
|
271
|
+
def to_body
|
|
272
|
+
to_hash
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# Returns the object in the form of hash
|
|
276
|
+
# @return [Hash] Returns the object in the form of hash
|
|
277
|
+
def to_hash
|
|
278
|
+
hash = {}
|
|
279
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
280
|
+
value = self.send(attr)
|
|
281
|
+
if value.nil?
|
|
282
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
283
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
hash[param] = _to_hash(value)
|
|
287
|
+
end
|
|
288
|
+
hash
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Outputs non-array value in the form of hash
|
|
292
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
293
|
+
# @param [Object] value Any valid value
|
|
294
|
+
# @return [Hash] Returns the value in the form of hash
|
|
295
|
+
def _to_hash(value)
|
|
296
|
+
if value.is_a?(Array)
|
|
297
|
+
value.compact.map { |v| _to_hash(v) }
|
|
298
|
+
elsif value.is_a?(Hash)
|
|
299
|
+
{}.tap do |hash|
|
|
300
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
301
|
+
end
|
|
302
|
+
elsif value.respond_to? :to_hash
|
|
303
|
+
value.to_hash
|
|
304
|
+
else
|
|
305
|
+
value
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
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 PreferredStockInstrumentKind
|
|
15
|
+
PREFERRED_STOCK = "preferred_stock".freeze
|
|
16
|
+
|
|
17
|
+
def self.all_vars
|
|
18
|
+
@all_vars ||= [PREFERRED_STOCK].freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Builds the enum from string
|
|
22
|
+
# @param [String] The enum value in the form of the string
|
|
23
|
+
# @return [String] The enum value
|
|
24
|
+
def self.build_from_hash(value)
|
|
25
|
+
new.build_from_hash(value)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Builds the enum from string
|
|
29
|
+
# @param [String] The enum value in the form of the string
|
|
30
|
+
# @return [String] The enum value
|
|
31
|
+
def build_from_hash(value)
|
|
32
|
+
return value if PreferredStockInstrumentKind.all_vars.include?(value)
|
|
33
|
+
raise "Invalid ENUM value #{value} for class #PreferredStockInstrumentKind"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -23,6 +23,7 @@ module SnapTrade
|
|
|
23
23
|
:'EtfInstrument',
|
|
24
24
|
:'MutualFundInstrument',
|
|
25
25
|
:'OtherInstrument',
|
|
26
|
+
:'PreferredStockInstrument',
|
|
26
27
|
:'StockInstrument'
|
|
27
28
|
]
|
|
28
29
|
end
|
|
@@ -42,6 +43,7 @@ module SnapTrade
|
|
|
42
43
|
:'etf' => :'EtfInstrument',
|
|
43
44
|
:'mutualfund' => :'MutualFundInstrument',
|
|
44
45
|
:'other' => :'OtherInstrument',
|
|
46
|
+
:'preferred_stock' => :'PreferredStockInstrument',
|
|
45
47
|
:'stock' => :'StockInstrument'
|
|
46
48
|
}
|
|
47
49
|
end
|
|
@@ -23,6 +23,7 @@ module SnapTrade
|
|
|
23
23
|
:'EtfInstrument',
|
|
24
24
|
:'MutualFundInstrument',
|
|
25
25
|
:'OtherInstrument',
|
|
26
|
+
:'PreferredStockInstrument',
|
|
26
27
|
:'StockInstrument'
|
|
27
28
|
]
|
|
28
29
|
end
|
|
@@ -42,6 +43,7 @@ module SnapTrade
|
|
|
42
43
|
:'etf' => :'EtfInstrument',
|
|
43
44
|
:'mutualfund' => :'MutualFundInstrument',
|
|
44
45
|
:'other' => :'OtherInstrument',
|
|
46
|
+
:'preferred_stock' => :'PreferredStockInstrument',
|
|
45
47
|
:'stock' => :'StockInstrument'
|
|
46
48
|
}
|
|
47
49
|
end
|
data/lib/snaptrade/version.rb
CHANGED
data/lib/snaptrade.rb
CHANGED
|
@@ -239,6 +239,8 @@ require 'snaptrade/models/performance_custom'
|
|
|
239
239
|
require 'snaptrade/models/position'
|
|
240
240
|
require 'snaptrade/models/position_currency'
|
|
241
241
|
require 'snaptrade/models/position_symbol'
|
|
242
|
+
require 'snaptrade/models/preferred_stock_instrument'
|
|
243
|
+
require 'snaptrade/models/preferred_stock_instrument_kind'
|
|
242
244
|
require 'snaptrade/models/price_effect'
|
|
243
245
|
require 'snaptrade/models/priced_in_instrument'
|
|
244
246
|
require 'snaptrade/models/rate_of_return_object'
|
|
@@ -90,7 +90,7 @@ describe 'AccountInformationApi' do
|
|
|
90
90
|
|
|
91
91
|
# unit tests for get_all_account_positions
|
|
92
92
|
# List all account positions
|
|
93
|
-
# Returns a list of all positions in the specified account. The `results` list can contain multiple instrument types in the same response, including stocks, ADRs, ETFs, mutual funds, closed-end funds, bonds, crypto, futures, option positions, future option positions, CFD positions, and tokenized asset positions. Use the `instrument.kind` discriminator to determine the schema for each position's `instrument`. **Beta:** future option positions (`instrument.kind: future_option`) are in beta. They are currently returned only for tastytrade and Interactive Brokers connections, and only for partners they have been enabled for — please contact the SnapTrade team to enable them. The `FutureOptionInstrument` schema may change. Positions counted in account cash balance or buying power include `cash_equivalent: true`. Security positions (`stock`, `adr`, `etf`, `mutualfund`, `cef`, `crypto`, `bond`, and `other`) may include `tax_lots` when tax lot data is enabled for the account; derivative, CFD, tokenized asset, and cash positions never do. To see which institutions support tax lot data, please see our [supported institutions doc](https://support.snaptrade.com/brokerages). 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.
|
|
93
|
+
# Returns a list of all positions in the specified account. The `results` list can contain multiple instrument types in the same response, including stocks, preferred stocks, ADRs, ETFs, mutual funds, closed-end funds, bonds, crypto, futures, option positions, future option positions, CFD positions, and tokenized asset positions. Use the `instrument.kind` discriminator to determine the schema for each position's `instrument`. **Beta:** future option positions (`instrument.kind: future_option`) are in beta. They are currently returned only for tastytrade and Interactive Brokers connections, and only for partners they have been enabled for — please contact the SnapTrade team to enable them. The `FutureOptionInstrument` schema may change. Positions counted in account cash balance or buying power include `cash_equivalent: true`. Security positions (`stock`, `preferred_stock`, `adr`, `etf`, `mutualfund`, `cef`, `crypto`, `bond`, and `other`) may include `tax_lots` when tax lot data is enabled for the account; derivative, CFD, tokenized asset, and cash positions never do. To see which institutions support tax lot data, please see our [supported institutions doc](https://support.snaptrade.com/brokerages). 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.
|
|
94
94
|
# @param user_id
|
|
95
95
|
# @param user_secret
|
|
96
96
|
# @param account_id
|
|
@@ -69,6 +69,21 @@ describe 'ExperimentalEndpointsApi' do
|
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
# unit tests for get_all_account_recent_orders
|
|
73
|
+
# List all account recent orders (last 24 hours only)
|
|
74
|
+
# A lightweight endpoint that returns the latest page of orders placed in the last 24 hours in the specified account, in the same `kind`-discriminated format as `/accounts/{accountId}/orders/all`. For most brokerages, the default page size is 100 meaning the endpoint will return a max of 100 orders. This endpoint is realtime and can be used to quickly check if account state has recently changed due to an execution, or check status of recently placed orders. Differs from `/accounts/{accountId}/orders/all` in that it is always realtime, and only checks the last 24 hours as opposed to the last 30 days. By default only returns executed orders, but that can be changed by setting *only_executed* to false. Every order carries a `legs` list with at least one leg; switch on `legs[].instrument.kind` and `order_type.kind` to know which fields are present. `data_freshness.as_of` is the time of this live request. **Experimental:** this endpoint may change without notice. **Because of the cost of realtime requests, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](https://dashboard.snaptrade.com/settings/billing)**
|
|
75
|
+
# @param user_id
|
|
76
|
+
# @param user_secret
|
|
77
|
+
# @param account_id
|
|
78
|
+
# @param [Hash] opts the optional parameters
|
|
79
|
+
# @option opts [Boolean] :only_executed Defaults to true. Indicates if request should fetch only executed orders. Set to false to retrieve non executed orders as well
|
|
80
|
+
# @return [AllAccountOrdersResponse]
|
|
81
|
+
describe 'get_all_account_recent_orders test' do
|
|
82
|
+
it 'should work' do
|
|
83
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
72
87
|
# unit tests for get_user_account_order_detail_v2
|
|
73
88
|
# Get account order detail (V2)
|
|
74
89
|
# Returns the detail of a single order using the brokerage order ID provided as a path parameter. The V2 order response format includes all legs of the order in the `legs` list field. If the order is single legged, `legs` will be a list of one leg. This endpoint is always realtime and does not rely on cached data. This endpoint only returns orders placed through SnapTrade. In other words, orders placed outside of the SnapTrade network are not returned by this endpoint.
|
|
@@ -0,0 +1,23 @@
|
|
|
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 'spec_helper'
|
|
11
|
+
require 'json'
|
|
12
|
+
require 'date'
|
|
13
|
+
|
|
14
|
+
# Unit tests for SnapTrade::PreferredStockInstrumentKind
|
|
15
|
+
describe SnapTrade::PreferredStockInstrumentKind do
|
|
16
|
+
let(:instance) { SnapTrade::PreferredStockInstrumentKind.new }
|
|
17
|
+
|
|
18
|
+
describe 'test an instance of PreferredStockInstrumentKind' do
|
|
19
|
+
it 'should create an instance of PreferredStockInstrumentKind' do
|
|
20
|
+
expect(instance).to be_instance_of(SnapTrade::PreferredStockInstrumentKind)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
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 'spec_helper'
|
|
11
|
+
require 'json'
|
|
12
|
+
require 'date'
|
|
13
|
+
|
|
14
|
+
# Unit tests for SnapTrade::PreferredStockInstrument
|
|
15
|
+
describe SnapTrade::PreferredStockInstrument do
|
|
16
|
+
let(:instance) { SnapTrade::PreferredStockInstrument.new }
|
|
17
|
+
|
|
18
|
+
describe 'test an instance of PreferredStockInstrument' do
|
|
19
|
+
it 'should create an instance of PreferredStockInstrument' do
|
|
20
|
+
expect(instance).to be_instance_of(SnapTrade::PreferredStockInstrument)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
describe 'test attribute "kind"' 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 "id"' 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 "symbol"' 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 "raw_symbol"' 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 "description"' 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
|
+
describe 'test attribute "currency"' do
|
|
54
|
+
it 'should work' do
|
|
55
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe 'test attribute "exchange"' do
|
|
60
|
+
it 'should work' do
|
|
61
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe 'test attribute "figi_instrument"' 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
|
+
|
|
71
|
+
end
|