snaptrade 2.0.185 → 2.0.186
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/Gemfile.lock +1 -1
- data/README.md +52 -2
- data/lib/snaptrade/api/experimental_endpoints_api.rb +141 -0
- data/lib/snaptrade/models/account_order_record_option_symbol.rb +1 -1
- data/lib/snaptrade/models/account_order_record_quote_universal_symbol.rb +1 -1
- data/lib/snaptrade/models/account_order_record_universal_symbol.rb +1 -1
- data/lib/snaptrade/models/account_position.rb +288 -0
- data/lib/snaptrade/models/account_universal_activity_option_symbol.rb +1 -1
- data/lib/snaptrade/models/account_universal_activity_symbol.rb +1 -1
- data/lib/snaptrade/models/all_account_positions_response.rb +262 -0
- data/lib/snaptrade/models/crypto_instrument.rb +311 -0
- data/lib/snaptrade/models/crypto_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/etf_instrument.rb +311 -0
- data/lib/snaptrade/models/etf_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/future_instrument.rb +326 -0
- data/lib/snaptrade/models/future_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/instrument.rb +61 -0
- data/lib/snaptrade/models/kind.rb +36 -0
- data/lib/snaptrade/models/option_instrument.rb +322 -0
- data/lib/snaptrade/models/option_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/options_symbol.rb +1 -1
- data/lib/snaptrade/models/options_symbol_option_type.rb +37 -0
- data/lib/snaptrade/models/other_instrument.rb +311 -0
- data/lib/snaptrade/models/other_instrument_kind.rb +36 -0
- data/lib/snaptrade/models/stock_instrument.rb +311 -0
- data/lib/snaptrade/models/{symbol_figi_instrument.rb → stock_instrument_figi_instrument.rb} +3 -3
- data/lib/snaptrade/models/symbol.rb +1 -1
- data/lib/snaptrade/models/underlying_option_instrument.rb +57 -0
- data/lib/snaptrade/models/underlying_symbol.rb +1 -1
- data/lib/snaptrade/models/universal_symbol.rb +1 -1
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +18 -1
- data/spec/api/experimental_endpoints_api_spec.rb +16 -0
- data/spec/models/account_position_spec.rb +65 -0
- data/spec/models/all_account_positions_response_spec.rb +47 -0
- data/spec/models/crypto_instrument_kind_spec.rb +23 -0
- data/spec/models/crypto_instrument_spec.rb +71 -0
- data/spec/models/etf_instrument_kind_spec.rb +23 -0
- data/spec/models/etf_instrument_spec.rb +71 -0
- data/spec/models/future_instrument_kind_spec.rb +23 -0
- data/spec/models/future_instrument_spec.rb +77 -0
- data/spec/models/instrument_spec.rb +38 -0
- data/spec/models/kind_spec.rb +23 -0
- data/spec/models/option_instrument_kind_spec.rb +23 -0
- data/spec/models/option_instrument_spec.rb +71 -0
- data/spec/models/options_symbol_option_type_spec.rb +23 -0
- data/spec/models/other_instrument_kind_spec.rb +23 -0
- data/spec/models/other_instrument_spec.rb +71 -0
- data/spec/models/{symbol_figi_instrument_spec.rb → stock_instrument_figi_instrument_spec.rb} +6 -6
- data/spec/models/stock_instrument_spec.rb +71 -0
- data/spec/models/underlying_option_instrument_spec.rb +38 -0
- metadata +56 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd4322701e75c8d0af2ed0b015c1e525bd4fce27720cfab7babab3ed73368c41
|
|
4
|
+
data.tar.gz: 3e9811048508415bd62640ae9ecf39a7839162495c054b613e049932fa8ebefe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d300944a9b5724d7f3de66b3d541f9b98ed6b17ac2e156fc8f384b557e9b730b01b96efa175676b7ebd74e4c30dde89f62dbdbec3ae7a1036645fccacf97930f
|
|
7
|
+
data.tar.gz: 1fdb7e6ba9a4e79a83a7d2a5ac78c7f020d49e681e25a5d88a6184784273dffa7dddb6599f4b437231d166e6a892bc7bf71174d0e97d5a2a6d7054e3c3756fc2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Connect brokerage accounts to your app for live positions and trading
|
|
8
8
|
|
|
9
|
-
[](https://rubygems.org/gems/snaptrade/versions/2.0.186)
|
|
10
10
|
[](https://snaptrade.com/)
|
|
11
11
|
|
|
12
12
|
</div>
|
|
@@ -46,6 +46,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
|
46
46
|
* [`snaptrade.connections.return_rates`](#snaptradeconnectionsreturn_rates)
|
|
47
47
|
* [`snaptrade.connections.session_events`](#snaptradeconnectionssession_events)
|
|
48
48
|
* [`snaptrade.experimental_endpoints.get_account_balance_history`](#snaptradeexperimental_endpointsget_account_balance_history)
|
|
49
|
+
* [`snaptrade.experimental_endpoints.get_all_account_positions`](#snaptradeexperimental_endpointsget_all_account_positions)
|
|
49
50
|
* [`snaptrade.experimental_endpoints.get_user_account_order_detail_v2`](#snaptradeexperimental_endpointsget_user_account_order_detail_v2)
|
|
50
51
|
* [`snaptrade.experimental_endpoints.get_user_account_orders_v2`](#snaptradeexperimental_endpointsget_user_account_orders_v2)
|
|
51
52
|
* [`snaptrade.experimental_endpoints.get_user_account_recent_orders_v2`](#snaptradeexperimental_endpointsget_user_account_recent_orders_v2)
|
|
@@ -89,7 +90,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
|
89
90
|
Add to Gemfile:
|
|
90
91
|
|
|
91
92
|
```ruby
|
|
92
|
-
gem 'snaptrade', '~> 2.0.
|
|
93
|
+
gem 'snaptrade', '~> 2.0.186'
|
|
93
94
|
```
|
|
94
95
|
|
|
95
96
|
## Getting Started<a id="getting-started"></a>
|
|
@@ -1218,6 +1219,55 @@ p result
|
|
|
1218
1219
|
---
|
|
1219
1220
|
|
|
1220
1221
|
|
|
1222
|
+
### `snaptrade.experimental_endpoints.get_all_account_positions`<a id="snaptradeexperimental_endpointsget_all_account_positions"></a>
|
|
1223
|
+
|
|
1224
|
+
Returns a paginated list of all positions in the specified account.
|
|
1225
|
+
|
|
1226
|
+
The `results` list can contain multiple instrument types in the same response page, including stocks, ETFs, crypto, futures, and option positions. Use the `instrument.kind` discriminator to determine the schema for each position's `instrument`.
|
|
1227
|
+
|
|
1228
|
+
Stock positions may also include `cash_equivalent`, and may include `tax_lots` when tax lot data is enabled for the account.
|
|
1229
|
+
|
|
1230
|
+
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.
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
|
1234
|
+
|
|
1235
|
+
```ruby
|
|
1236
|
+
result = snaptrade.experimental_endpoints.get_all_account_positions(
|
|
1237
|
+
user_id: "snaptrade-user-123",
|
|
1238
|
+
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1239
|
+
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
1240
|
+
page: 1,
|
|
1241
|
+
page_size: 100,
|
|
1242
|
+
)
|
|
1243
|
+
p result
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
1247
|
+
|
|
1248
|
+
##### user_id: `String`<a id="user_id-string"></a>
|
|
1249
|
+
##### user_secret: `String`<a id="user_secret-string"></a>
|
|
1250
|
+
##### account_id: `String`<a id="account_id-string"></a>
|
|
1251
|
+
##### page: `Integer`<a id="page-integer"></a>
|
|
1252
|
+
The page number to return. Defaults to 1.
|
|
1253
|
+
|
|
1254
|
+
##### page_size: `Integer`<a id="page_size-integer"></a>
|
|
1255
|
+
The number of positions to return per page. Defaults to 100 with a maximum of
|
|
1256
|
+
1000.
|
|
1257
|
+
|
|
1258
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
|
1259
|
+
|
|
1260
|
+
[AllAccountPositionsResponse](./lib/snaptrade/models/all_account_positions_response.rb)
|
|
1261
|
+
|
|
1262
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
|
1263
|
+
|
|
1264
|
+
`/accounts/{accountId}/positions/all` `GET`
|
|
1265
|
+
|
|
1266
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
|
1267
|
+
|
|
1268
|
+
---
|
|
1269
|
+
|
|
1270
|
+
|
|
1221
1271
|
### `snaptrade.experimental_endpoints.get_user_account_order_detail_v2`<a id="snaptradeexperimental_endpointsget_user_account_order_detail_v2"></a>
|
|
1222
1272
|
|
|
1223
1273
|
Returns the detail of a single order using the brokerage order ID provided as a path parameter.
|
|
@@ -120,6 +120,147 @@ module SnapTrade
|
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
|
|
123
|
+
# List all account positions
|
|
124
|
+
#
|
|
125
|
+
# Returns a paginated list of all positions in the specified account.
|
|
126
|
+
#
|
|
127
|
+
# The `results` list can contain multiple instrument types in the same response page, including stocks, ETFs, crypto, futures, and option positions. Use the `instrument.kind` discriminator to determine the schema for each position's `instrument`.
|
|
128
|
+
#
|
|
129
|
+
# Stock positions may also include `cash_equivalent`, and may include `tax_lots` when tax lot data is enabled for the account.
|
|
130
|
+
#
|
|
131
|
+
# 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.
|
|
132
|
+
#
|
|
133
|
+
# @param user_id [String]
|
|
134
|
+
# @param user_secret [String]
|
|
135
|
+
# @param account_id [String]
|
|
136
|
+
# @param page [Integer] The page number to return. Defaults to 1.
|
|
137
|
+
# @param page_size [Integer] The number of positions to return per page. Defaults to 100 with a maximum of 1000.
|
|
138
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
139
|
+
def get_all_account_positions(user_id:, user_secret:, account_id:, page: SENTINEL, page_size: SENTINEL, extra: {})
|
|
140
|
+
extra[:page] = page if page != SENTINEL
|
|
141
|
+
extra[:page_size] = page_size if page_size != SENTINEL
|
|
142
|
+
data, _status_code, _headers = get_all_account_positions_with_http_info_impl(user_id, user_secret, account_id, extra)
|
|
143
|
+
data
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# List all account positions
|
|
147
|
+
#
|
|
148
|
+
# Returns a paginated list of all positions in the specified account.
|
|
149
|
+
#
|
|
150
|
+
# The `results` list can contain multiple instrument types in the same response page, including stocks, ETFs, crypto, futures, and option positions. Use the `instrument.kind` discriminator to determine the schema for each position's `instrument`.
|
|
151
|
+
#
|
|
152
|
+
# Stock positions may also include `cash_equivalent`, and may include `tax_lots` when tax lot data is enabled for the account.
|
|
153
|
+
#
|
|
154
|
+
# 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.
|
|
155
|
+
#
|
|
156
|
+
# @param user_id [String]
|
|
157
|
+
# @param user_secret [String]
|
|
158
|
+
# @param account_id [String]
|
|
159
|
+
# @param page [Integer] The page number to return. Defaults to 1.
|
|
160
|
+
# @param page_size [Integer] The number of positions to return per page. Defaults to 100 with a maximum of 1000.
|
|
161
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
162
|
+
def get_all_account_positions_with_http_info(user_id:, user_secret:, account_id:, page: SENTINEL, page_size: SENTINEL, extra: {})
|
|
163
|
+
extra[:page] = page if page != SENTINEL
|
|
164
|
+
extra[:page_size] = page_size if page_size != SENTINEL
|
|
165
|
+
get_all_account_positions_with_http_info_impl(user_id, user_secret, account_id, extra)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# List all account positions
|
|
169
|
+
# Returns a paginated list of all positions in the specified account. The `results` list can contain multiple instrument types in the same response page, including stocks, ETFs, crypto, futures, and option positions. Use the `instrument.kind` discriminator to determine the schema for each position's `instrument`. Stock positions may also include `cash_equivalent`, and may include `tax_lots` when tax lot data is enabled for the account. 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.
|
|
170
|
+
# @param user_id [String]
|
|
171
|
+
# @param user_secret [String]
|
|
172
|
+
# @param account_id [String]
|
|
173
|
+
# @param [Hash] opts the optional parameters
|
|
174
|
+
# @option opts [Integer] :page The page number to return. Defaults to 1.
|
|
175
|
+
# @option opts [Integer] :page_size The number of positions to return per page. Defaults to 100 with a maximum of 1000.
|
|
176
|
+
# @return [AllAccountPositionsResponse]
|
|
177
|
+
private def get_all_account_positions_impl(user_id, user_secret, account_id, opts = {})
|
|
178
|
+
data, _status_code, _headers = get_all_account_positions_with_http_info(user_id, user_secret, account_id, opts)
|
|
179
|
+
data
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# List all account positions
|
|
183
|
+
# Returns a paginated list of all positions in the specified account. The `results` list can contain multiple instrument types in the same response page, including stocks, ETFs, crypto, futures, and option positions. Use the `instrument.kind` discriminator to determine the schema for each position's `instrument`. Stock positions may also include `cash_equivalent`, and may include `tax_lots` when tax lot data is enabled for the account. 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.
|
|
184
|
+
# @param user_id [String]
|
|
185
|
+
# @param user_secret [String]
|
|
186
|
+
# @param account_id [String]
|
|
187
|
+
# @param [Hash] opts the optional parameters
|
|
188
|
+
# @option opts [Integer] :page The page number to return. Defaults to 1.
|
|
189
|
+
# @option opts [Integer] :page_size The number of positions to return per page. Defaults to 100 with a maximum of 1000.
|
|
190
|
+
# @return [Array<(AllAccountPositionsResponse, Integer, Hash)>] AllAccountPositionsResponse data, response status code and response headers
|
|
191
|
+
private def get_all_account_positions_with_http_info_impl(user_id, user_secret, account_id, opts = {})
|
|
192
|
+
if @api_client.config.debugging
|
|
193
|
+
@api_client.config.logger.debug 'Calling API: ExperimentalEndpointsApi.get_all_account_positions ...'
|
|
194
|
+
end
|
|
195
|
+
# verify the required parameter 'user_id' is set
|
|
196
|
+
if @api_client.config.client_side_validation && user_id.nil?
|
|
197
|
+
fail ArgumentError, "Missing the required parameter 'user_id' when calling ExperimentalEndpointsApi.get_all_account_positions"
|
|
198
|
+
end
|
|
199
|
+
# verify the required parameter 'user_secret' is set
|
|
200
|
+
if @api_client.config.client_side_validation && user_secret.nil?
|
|
201
|
+
fail ArgumentError, "Missing the required parameter 'user_secret' when calling ExperimentalEndpointsApi.get_all_account_positions"
|
|
202
|
+
end
|
|
203
|
+
# verify the required parameter 'account_id' is set
|
|
204
|
+
if @api_client.config.client_side_validation && account_id.nil?
|
|
205
|
+
fail ArgumentError, "Missing the required parameter 'account_id' when calling ExperimentalEndpointsApi.get_all_account_positions"
|
|
206
|
+
end
|
|
207
|
+
if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
|
|
208
|
+
fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ExperimentalEndpointsApi.get_all_account_positions, must be greater than or equal to 1.'
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000
|
|
212
|
+
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ExperimentalEndpointsApi.get_all_account_positions, must be smaller than or equal to 1000.'
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
|
|
216
|
+
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ExperimentalEndpointsApi.get_all_account_positions, must be greater than or equal to 1.'
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# resource path
|
|
220
|
+
local_var_path = '/accounts/{accountId}/positions/all'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
|
|
221
|
+
|
|
222
|
+
# query parameters
|
|
223
|
+
query_params = opts[:query_params] || {}
|
|
224
|
+
query_params[:'userId'] = user_id
|
|
225
|
+
query_params[:'userSecret'] = user_secret
|
|
226
|
+
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
|
227
|
+
query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
|
|
228
|
+
|
|
229
|
+
# header parameters
|
|
230
|
+
header_params = opts[:header_params] || {}
|
|
231
|
+
# HTTP header 'Accept' (if needed)
|
|
232
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
|
233
|
+
|
|
234
|
+
# form parameters
|
|
235
|
+
form_params = opts[:form_params] || {}
|
|
236
|
+
|
|
237
|
+
# http body (model)
|
|
238
|
+
post_body = opts[:debug_body]
|
|
239
|
+
|
|
240
|
+
# return_type
|
|
241
|
+
return_type = opts[:debug_return_type] || 'AllAccountPositionsResponse'
|
|
242
|
+
|
|
243
|
+
# auth_names
|
|
244
|
+
auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
|
|
245
|
+
|
|
246
|
+
new_options = opts.merge(
|
|
247
|
+
:operation => :"ExperimentalEndpointsApi.get_all_account_positions",
|
|
248
|
+
:header_params => header_params,
|
|
249
|
+
:query_params => query_params,
|
|
250
|
+
:form_params => form_params,
|
|
251
|
+
:body => post_body,
|
|
252
|
+
:auth_names => auth_names,
|
|
253
|
+
:return_type => return_type
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
|
|
257
|
+
if @api_client.config.debugging
|
|
258
|
+
@api_client.config.logger.debug "API called: ExperimentalEndpointsApi#get_all_account_positions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
259
|
+
end
|
|
260
|
+
return data, status_code, headers, response
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
|
|
123
264
|
# Get account order detail (V2)
|
|
124
265
|
#
|
|
125
266
|
# Returns the detail of a single order using the brokerage order ID provided as a path parameter.
|
|
@@ -71,7 +71,7 @@ module SnapTrade
|
|
|
71
71
|
:'exchange' => :'SymbolExchange',
|
|
72
72
|
:'type' => :'SecurityType',
|
|
73
73
|
:'figi_code' => :'String',
|
|
74
|
-
:'figi_instrument' => :'
|
|
74
|
+
:'figi_instrument' => :'StockInstrumentFigiInstrument',
|
|
75
75
|
:'currencies' => :'Array<Currency>'
|
|
76
76
|
}
|
|
77
77
|
end
|
|
@@ -71,7 +71,7 @@ module SnapTrade
|
|
|
71
71
|
:'exchange' => :'SymbolExchange',
|
|
72
72
|
:'type' => :'SecurityType',
|
|
73
73
|
:'figi_code' => :'String',
|
|
74
|
-
:'figi_instrument' => :'
|
|
74
|
+
:'figi_instrument' => :'StockInstrumentFigiInstrument',
|
|
75
75
|
:'currencies' => :'Array<Currency>'
|
|
76
76
|
}
|
|
77
77
|
end
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#SnapTrade
|
|
3
|
+
|
|
4
|
+
#Connect brokerage accounts to your app for live positions and trading
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: api@snaptrade.com
|
|
8
|
+
=end
|
|
9
|
+
|
|
10
|
+
require 'date'
|
|
11
|
+
require 'time'
|
|
12
|
+
|
|
13
|
+
module SnapTrade
|
|
14
|
+
# Describes a single position.
|
|
15
|
+
class AccountPosition
|
|
16
|
+
attr_accessor :instrument
|
|
17
|
+
|
|
18
|
+
# The number of units held in the position. Positive numbers indicate long positions and negative numbers indicate short positions.
|
|
19
|
+
attr_accessor :units
|
|
20
|
+
|
|
21
|
+
# Last known market price for the position.
|
|
22
|
+
attr_accessor :price
|
|
23
|
+
|
|
24
|
+
# Book price or average purchase price for the position.
|
|
25
|
+
attr_accessor :cost_basis
|
|
26
|
+
|
|
27
|
+
# ISO-4217 currency code for the position `price` and `cost_basis`.
|
|
28
|
+
attr_accessor :currency
|
|
29
|
+
|
|
30
|
+
# Present for stock positions that are also counted in cash balance or buying power.
|
|
31
|
+
attr_accessor :cash_equivalent
|
|
32
|
+
|
|
33
|
+
# Present for stock positions when tax lot data is enabled for the account.
|
|
34
|
+
attr_accessor :tax_lots
|
|
35
|
+
|
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
37
|
+
def self.attribute_map
|
|
38
|
+
{
|
|
39
|
+
:'instrument' => :'instrument',
|
|
40
|
+
:'units' => :'units',
|
|
41
|
+
:'price' => :'price',
|
|
42
|
+
:'cost_basis' => :'cost_basis',
|
|
43
|
+
:'currency' => :'currency',
|
|
44
|
+
:'cash_equivalent' => :'cash_equivalent',
|
|
45
|
+
:'tax_lots' => :'tax_lots'
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Returns all the JSON keys this model knows about
|
|
50
|
+
def self.acceptable_attributes
|
|
51
|
+
attribute_map.values
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Attribute type mapping.
|
|
55
|
+
def self.openapi_types
|
|
56
|
+
{
|
|
57
|
+
:'instrument' => :'Instrument',
|
|
58
|
+
:'units' => :'Float',
|
|
59
|
+
:'price' => :'Float',
|
|
60
|
+
:'cost_basis' => :'Float',
|
|
61
|
+
:'currency' => :'String',
|
|
62
|
+
:'cash_equivalent' => :'Boolean',
|
|
63
|
+
:'tax_lots' => :'Array<TaxLot>'
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# List of attributes with nullable: true
|
|
68
|
+
def self.openapi_nullable
|
|
69
|
+
Set.new([
|
|
70
|
+
:'units',
|
|
71
|
+
:'price',
|
|
72
|
+
:'cost_basis',
|
|
73
|
+
:'currency',
|
|
74
|
+
])
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Initializes the object
|
|
78
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
79
|
+
def initialize(attributes = {})
|
|
80
|
+
if (!attributes.is_a?(Hash))
|
|
81
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::AccountPosition` initialize method"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
85
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
86
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
87
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::AccountPosition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
88
|
+
end
|
|
89
|
+
h[k.to_sym] = v
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if attributes.key?(:'instrument')
|
|
93
|
+
self.instrument = attributes[:'instrument']
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
if attributes.key?(:'units')
|
|
97
|
+
self.units = attributes[:'units']
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
if attributes.key?(:'price')
|
|
101
|
+
self.price = attributes[:'price']
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if attributes.key?(:'cost_basis')
|
|
105
|
+
self.cost_basis = attributes[:'cost_basis']
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
if attributes.key?(:'currency')
|
|
109
|
+
self.currency = attributes[:'currency']
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
if attributes.key?(:'cash_equivalent')
|
|
113
|
+
self.cash_equivalent = attributes[:'cash_equivalent']
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
if attributes.key?(:'tax_lots')
|
|
117
|
+
if (value = attributes[:'tax_lots']).is_a?(Array)
|
|
118
|
+
self.tax_lots = value
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
124
|
+
# @return Array for valid properties with the reasons
|
|
125
|
+
def list_invalid_properties
|
|
126
|
+
invalid_properties = Array.new
|
|
127
|
+
if @instrument.nil?
|
|
128
|
+
invalid_properties.push('invalid value for "instrument", instrument cannot be nil.')
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
invalid_properties
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Check to see if the all the properties in the model are valid
|
|
135
|
+
# @return true if the model is valid
|
|
136
|
+
def valid?
|
|
137
|
+
return false if @instrument.nil?
|
|
138
|
+
true
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Checks equality by comparing each attribute.
|
|
142
|
+
# @param [Object] Object to be compared
|
|
143
|
+
def ==(o)
|
|
144
|
+
return true if self.equal?(o)
|
|
145
|
+
self.class == o.class &&
|
|
146
|
+
instrument == o.instrument &&
|
|
147
|
+
units == o.units &&
|
|
148
|
+
price == o.price &&
|
|
149
|
+
cost_basis == o.cost_basis &&
|
|
150
|
+
currency == o.currency &&
|
|
151
|
+
cash_equivalent == o.cash_equivalent &&
|
|
152
|
+
tax_lots == o.tax_lots
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# @see the `==` method
|
|
156
|
+
# @param [Object] Object to be compared
|
|
157
|
+
def eql?(o)
|
|
158
|
+
self == o
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Calculates hash code according to all attributes.
|
|
162
|
+
# @return [Integer] Hash code
|
|
163
|
+
def hash
|
|
164
|
+
[instrument, units, price, cost_basis, currency, cash_equivalent, tax_lots].hash
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Builds the object from hash
|
|
168
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
169
|
+
# @return [Object] Returns the model itself
|
|
170
|
+
def self.build_from_hash(attributes)
|
|
171
|
+
new.build_from_hash(attributes)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Builds the object from hash
|
|
175
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
176
|
+
# @return [Object] Returns the model itself
|
|
177
|
+
def build_from_hash(attributes)
|
|
178
|
+
return nil unless attributes.is_a?(Hash)
|
|
179
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
180
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
181
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
182
|
+
self.send("#{key}=", nil)
|
|
183
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
184
|
+
# check to ensure the input is an array given that the attribute
|
|
185
|
+
# is documented as an array but the input is not
|
|
186
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
187
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
188
|
+
end
|
|
189
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
190
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
self
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Deserializes the data based on type
|
|
198
|
+
# @param string type Data type
|
|
199
|
+
# @param string value Value to be deserialized
|
|
200
|
+
# @return [Object] Deserialized data
|
|
201
|
+
def _deserialize(type, value)
|
|
202
|
+
case type.to_sym
|
|
203
|
+
when :Time
|
|
204
|
+
Time.parse(value)
|
|
205
|
+
when :Date
|
|
206
|
+
Date.parse(value)
|
|
207
|
+
when :String
|
|
208
|
+
value.to_s
|
|
209
|
+
when :Integer
|
|
210
|
+
value.to_i
|
|
211
|
+
when :Float
|
|
212
|
+
value.to_f
|
|
213
|
+
when :Boolean
|
|
214
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
215
|
+
true
|
|
216
|
+
else
|
|
217
|
+
false
|
|
218
|
+
end
|
|
219
|
+
when :Object
|
|
220
|
+
# generic object (usually a Hash), return directly
|
|
221
|
+
value
|
|
222
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
223
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
224
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
225
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
226
|
+
k_type = Regexp.last_match[:k_type]
|
|
227
|
+
v_type = Regexp.last_match[:v_type]
|
|
228
|
+
{}.tap do |hash|
|
|
229
|
+
value.each do |k, v|
|
|
230
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
else # model
|
|
234
|
+
# models (e.g. Pet) or oneOf
|
|
235
|
+
klass = SnapTrade.const_get(type)
|
|
236
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Returns the string representation of the object
|
|
241
|
+
# @return [String] String presentation of the object
|
|
242
|
+
def to_s
|
|
243
|
+
to_hash.to_s
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
247
|
+
# @return [Hash] Returns the object in the form of hash
|
|
248
|
+
def to_body
|
|
249
|
+
to_hash
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
# Returns the object in the form of hash
|
|
253
|
+
# @return [Hash] Returns the object in the form of hash
|
|
254
|
+
def to_hash
|
|
255
|
+
hash = {}
|
|
256
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
257
|
+
value = self.send(attr)
|
|
258
|
+
if value.nil?
|
|
259
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
260
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
hash[param] = _to_hash(value)
|
|
264
|
+
end
|
|
265
|
+
hash
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Outputs non-array value in the form of hash
|
|
269
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
270
|
+
# @param [Object] value Any valid value
|
|
271
|
+
# @return [Hash] Returns the value in the form of hash
|
|
272
|
+
def _to_hash(value)
|
|
273
|
+
if value.is_a?(Array)
|
|
274
|
+
value.compact.map { |v| _to_hash(v) }
|
|
275
|
+
elsif value.is_a?(Hash)
|
|
276
|
+
{}.tap do |hash|
|
|
277
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
278
|
+
end
|
|
279
|
+
elsif value.respond_to? :to_hash
|
|
280
|
+
value.to_hash
|
|
281
|
+
else
|
|
282
|
+
value
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
end
|