snaptrade 3.0.53 → 3.0.54
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 +4 -4
- data/lib/snaptrade/api/account_information_api.rb +6 -6
- data/lib/snaptrade/models/account_position.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/models/preferred_stock_instrument_kind_spec.rb +23 -0
- data/spec/models/preferred_stock_instrument_spec.rb +71 -0
- metadata +285 -279
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b3a3742502a8df2558260e29af1647b33e0f873f723f13da27eee4a55939982
|
|
4
|
+
data.tar.gz: 7c1790c3f6cd9e61240fee672b8a4fffdd6e7a6b4466b6bae98c3a1a3feae137
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a51be49443ba26b24dba10b86b420b341b93455c1502d592f906f9d270f5cb4b5a7a8f6be4c03293363270701d5eba410e63e3f1ba7a89808a9e95b450df302
|
|
7
|
+
data.tar.gz: aa8b494471ff63f3120547109fec1dfb0ecf61e15e162057eadf202eadce39e3be19769a7418899c7917d05e264a27d16bed36b399dd8d21bb810a3d4d517321
|
data/README.md
CHANGED
|
@@ -63,7 +63,7 @@ backoff with jitter rather than from the headers.
|
|
|
63
63
|
See https://docs.snaptrade.com/docs/ratelimiting.
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
[](https://rubygems.org/gems/snaptrade/versions/3.0.54)
|
|
67
67
|
[](https://snaptrade.com/)
|
|
68
68
|
|
|
69
69
|
</div>
|
|
@@ -147,7 +147,7 @@ See https://docs.snaptrade.com/docs/ratelimiting.
|
|
|
147
147
|
Add to Gemfile:
|
|
148
148
|
|
|
149
149
|
```ruby
|
|
150
|
-
gem 'snaptrade', '~> 3.0.
|
|
150
|
+
gem 'snaptrade', '~> 3.0.54'
|
|
151
151
|
```
|
|
152
152
|
|
|
153
153
|
## Getting Started<a id="getting-started"></a>
|
|
@@ -403,11 +403,11 @@ p result
|
|
|
403
403
|
|
|
404
404
|
Returns a list of all positions in the specified account.
|
|
405
405
|
|
|
406
|
-
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`.
|
|
406
|
+
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`.
|
|
407
407
|
|
|
408
408
|
**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.
|
|
409
409
|
|
|
410
|
-
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).
|
|
410
|
+
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).
|
|
411
411
|
|
|
412
412
|
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.
|
|
413
413
|
|
|
@@ -536,11 +536,11 @@ module SnapTrade
|
|
|
536
536
|
#
|
|
537
537
|
# Returns a list of all positions in the specified account.
|
|
538
538
|
#
|
|
539
|
-
# 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`.
|
|
539
|
+
# 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`.
|
|
540
540
|
#
|
|
541
541
|
# **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.
|
|
542
542
|
#
|
|
543
|
-
# 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).
|
|
543
|
+
# 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).
|
|
544
544
|
#
|
|
545
545
|
# 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.
|
|
546
546
|
#
|
|
@@ -557,11 +557,11 @@ module SnapTrade
|
|
|
557
557
|
#
|
|
558
558
|
# Returns a list of all positions in the specified account.
|
|
559
559
|
#
|
|
560
|
-
# 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`.
|
|
560
|
+
# 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`.
|
|
561
561
|
#
|
|
562
562
|
# **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.
|
|
563
563
|
#
|
|
564
|
-
# 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).
|
|
564
|
+
# 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).
|
|
565
565
|
#
|
|
566
566
|
# 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.
|
|
567
567
|
#
|
|
@@ -574,7 +574,7 @@ module SnapTrade
|
|
|
574
574
|
end
|
|
575
575
|
|
|
576
576
|
# List all account positions
|
|
577
|
-
# 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.
|
|
577
|
+
# 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.
|
|
578
578
|
# @param user_id [String]
|
|
579
579
|
# @param user_secret [String]
|
|
580
580
|
# @param account_id [String]
|
|
@@ -586,7 +586,7 @@ module SnapTrade
|
|
|
586
586
|
end
|
|
587
587
|
|
|
588
588
|
# List all account positions
|
|
589
|
-
# 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.
|
|
589
|
+
# 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.
|
|
590
590
|
# @param user_id [String]
|
|
591
591
|
# @param user_secret [String]
|
|
592
592
|
# @param account_id [String]
|
|
@@ -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; enable via the Customer Dashboard Add-ons page. When enabled, this field is included for security positions (`stock`, `adr`, `etf`, `mutualfund`, `cef`, `crypto`, `bond`, and `other`). For these positions, an empty list means no tax lot data is available. Availability varies by brokerage and position. This field is omitted for options, futures, future options, CFDs, tokenized assets, and cash, or when the feature is disabled.
|
|
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 for security positions (`stock`, `preferred_stock`, `adr`, `etf`, `mutualfund`, `cef`, `crypto`, `bond`, and `other`). For these positions, an empty list means no tax lot data is available. Availability varies by brokerage and position. This field is omitted for options, futures, future options, CFDs, tokenized assets, and cash, 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.
|
|
@@ -28,6 +28,7 @@ module SnapTrade
|
|
|
28
28
|
:'MutualFundInstrument',
|
|
29
29
|
:'OptionInstrument',
|
|
30
30
|
:'OtherInstrument',
|
|
31
|
+
:'PreferredStockInstrument',
|
|
31
32
|
:'StockInstrument',
|
|
32
33
|
:'TokenizedAssetInstrument'
|
|
33
34
|
]
|
|
@@ -53,6 +54,7 @@ module SnapTrade
|
|
|
53
54
|
:'mutualfund' => :'MutualFundInstrument',
|
|
54
55
|
:'option' => :'OptionInstrument',
|
|
55
56
|
:'other' => :'OtherInstrument',
|
|
57
|
+
:'preferred_stock' => :'PreferredStockInstrument',
|
|
56
58
|
:'stock' => :'StockInstrument',
|
|
57
59
|
:'tokenized_asset' => :'TokenizedAssetInstrument'
|
|
58
60
|
}
|
|
@@ -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
|
|
@@ -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
|