snaptrade 2.0.184 → 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 +126 -2
- data/lib/snaptrade/api/experimental_endpoints_api.rb +141 -0
- data/lib/snaptrade/api/trading_api.rb +142 -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/complex_order_leg.rb +319 -0
- data/lib/snaptrade/models/complex_order_response.rb +229 -0
- data/lib/snaptrade/models/complex_order_response_type.rb +38 -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/manual_trade_form_complex.rb +251 -0
- data/lib/snaptrade/models/manual_trade_form_complex_type.rb +38 -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/order_role.rb +38 -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 +24 -1
- data/spec/api/experimental_endpoints_api_spec.rb +16 -0
- data/spec/api/trading_api_spec.rb +15 -0
- data/spec/models/account_position_spec.rb +65 -0
- data/spec/models/all_account_positions_response_spec.rb +47 -0
- data/spec/models/complex_order_leg_spec.rb +71 -0
- data/spec/models/complex_order_response_spec.rb +35 -0
- data/spec/models/complex_order_response_type_spec.rb +23 -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/manual_trade_form_complex_spec.rb +41 -0
- data/spec/models/manual_trade_form_complex_type_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/order_role_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 +231 -162
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)
|
|
@@ -71,6 +72,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
|
71
72
|
* [`snaptrade.trading.get_user_account_option_quotes`](#snaptradetradingget_user_account_option_quotes)
|
|
72
73
|
* [`snaptrade.trading.get_user_account_quotes`](#snaptradetradingget_user_account_quotes)
|
|
73
74
|
* [`snaptrade.trading.place_bracket_order`](#snaptradetradingplace_bracket_order)
|
|
75
|
+
* [`snaptrade.trading.place_complex_order`](#snaptradetradingplace_complex_order)
|
|
74
76
|
* [`snaptrade.trading.place_crypto_order`](#snaptradetradingplace_crypto_order)
|
|
75
77
|
* [`snaptrade.trading.place_force_order`](#snaptradetradingplace_force_order)
|
|
76
78
|
* [`snaptrade.trading.place_mleg_order`](#snaptradetradingplace_mleg_order)
|
|
@@ -88,7 +90,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
|
88
90
|
Add to Gemfile:
|
|
89
91
|
|
|
90
92
|
```ruby
|
|
91
|
-
gem 'snaptrade', '~> 2.0.
|
|
93
|
+
gem 'snaptrade', '~> 2.0.186'
|
|
92
94
|
```
|
|
93
95
|
|
|
94
96
|
## Getting Started<a id="getting-started"></a>
|
|
@@ -1217,6 +1219,55 @@ p result
|
|
|
1217
1219
|
---
|
|
1218
1220
|
|
|
1219
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
|
+
|
|
1220
1271
|
### `snaptrade.experimental_endpoints.get_user_account_order_detail_v2`<a id="snaptradeexperimental_endpointsget_user_account_order_detail_v2"></a>
|
|
1221
1272
|
|
|
1222
1273
|
Returns the detail of a single order using the brokerage order ID provided as a path parameter.
|
|
@@ -2205,6 +2256,79 @@ Must be `null` if `notional_value` is provided.
|
|
|
2205
2256
|
---
|
|
2206
2257
|
|
|
2207
2258
|
|
|
2259
|
+
### `snaptrade.trading.place_complex_order`<a id="snaptradetradingplace_complex_order"></a>
|
|
2260
|
+
|
|
2261
|
+
Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable.
|
|
2262
|
+
Only supported on certain brokerages.
|
|
2263
|
+
|
|
2264
|
+
- **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled.
|
|
2265
|
+
- **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order.
|
|
2266
|
+
- **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
|
|
2267
|
+
|
|
2268
|
+
|
|
2269
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
|
2270
|
+
|
|
2271
|
+
```ruby
|
|
2272
|
+
result = snaptrade.trading.place_complex_order(
|
|
2273
|
+
type: "OTO",
|
|
2274
|
+
orders: [
|
|
2275
|
+
{
|
|
2276
|
+
"order_role" => "TRIGGER",
|
|
2277
|
+
"action" => "BUY",
|
|
2278
|
+
"instrument" => {
|
|
2279
|
+
"symbol" => "AAPL",
|
|
2280
|
+
"type" => "EQUITY",
|
|
2281
|
+
},
|
|
2282
|
+
"order_type" => "Market",
|
|
2283
|
+
"units" => 10.5,
|
|
2284
|
+
"time_in_force" => "Day",
|
|
2285
|
+
"price" => 31.33,
|
|
2286
|
+
"stop" => 29.5,
|
|
2287
|
+
}
|
|
2288
|
+
],
|
|
2289
|
+
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2290
|
+
user_id: "snaptrade-user-123",
|
|
2291
|
+
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2292
|
+
client_order_id: "my-order-123",
|
|
2293
|
+
)
|
|
2294
|
+
p result
|
|
2295
|
+
```
|
|
2296
|
+
|
|
2297
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
|
2298
|
+
|
|
2299
|
+
##### type: [`ManualTradeFormComplexType`](./lib/snaptrade/models/manual_trade_form_complex_type.rb)<a id="type-manualtradeformcomplextypelibsnaptrademodelsmanual_trade_form_complex_typerb"></a>
|
|
2300
|
+
The complex order type. - `OCO`: One Cancels the Other — two peer orders. -
|
|
2301
|
+
`OTO`: One Triggers the Other — a trigger order and a conditional order. -
|
|
2302
|
+
`OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer
|
|
2303
|
+
orders.
|
|
2304
|
+
|
|
2305
|
+
##### orders: Array<[`ComplexOrderLeg`](./lib/snaptrade/models/complex_order_leg.rb)><a id="orders-array"></a>
|
|
2306
|
+
The orders that make up the complex order. Required counts and roles per type: -
|
|
2307
|
+
`OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER`
|
|
2308
|
+
and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
|
|
2309
|
+
|
|
2310
|
+
##### account_id: `String`<a id="account_id-string"></a>
|
|
2311
|
+
The ID of the account to execute the trade on.
|
|
2312
|
+
|
|
2313
|
+
##### user_id: `String`<a id="user_id-string"></a>
|
|
2314
|
+
##### user_secret: `String`<a id="user_secret-string"></a>
|
|
2315
|
+
##### client_order_id: `String`<a id="client_order_id-string"></a>
|
|
2316
|
+
An optional client-provided identifier for this complex order. Passed through to
|
|
2317
|
+
the brokerage and returned in the response.
|
|
2318
|
+
|
|
2319
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
|
2320
|
+
|
|
2321
|
+
[ComplexOrderResponse](./lib/snaptrade/models/complex_order_response.rb)
|
|
2322
|
+
|
|
2323
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
|
2324
|
+
|
|
2325
|
+
`/accounts/{accountId}/trading/complex` `POST`
|
|
2326
|
+
|
|
2327
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
|
2328
|
+
|
|
2329
|
+
---
|
|
2330
|
+
|
|
2331
|
+
|
|
2208
2332
|
### `snaptrade.trading.place_crypto_order`<a id="snaptradetradingplace_crypto_order"></a>
|
|
2209
2333
|
|
|
2210
2334
|
Places an order in the specified account.
|
|
@@ -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.
|
|
@@ -1079,6 +1079,148 @@ module SnapTrade
|
|
|
1079
1079
|
end
|
|
1080
1080
|
|
|
1081
1081
|
|
|
1082
|
+
# Place complex order
|
|
1083
|
+
#
|
|
1084
|
+
# Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable.
|
|
1085
|
+
# Only supported on certain brokerages.
|
|
1086
|
+
#
|
|
1087
|
+
# - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled.
|
|
1088
|
+
# - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order.
|
|
1089
|
+
# - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
|
|
1090
|
+
#
|
|
1091
|
+
# @param type [ManualTradeFormComplexType] The complex order type. - `OCO`: One Cancels the Other — two peer orders. - `OTO`: One Triggers the Other — a trigger order and a conditional order. - `OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer orders.
|
|
1092
|
+
# @param orders [Array<ComplexOrderLeg>] The orders that make up the complex order. Required counts and roles per type: - `OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER` and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
|
|
1093
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
|
1094
|
+
# @param user_id [String]
|
|
1095
|
+
# @param user_secret [String]
|
|
1096
|
+
# @param client_order_id [String] An optional client-provided identifier for this complex order. Passed through to the brokerage and returned in the response.
|
|
1097
|
+
# @param body [ManualTradeFormComplex]
|
|
1098
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
1099
|
+
def place_complex_order(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {})
|
|
1100
|
+
_body = {}
|
|
1101
|
+
_body[:type] = type if type != SENTINEL
|
|
1102
|
+
_body[:orders] = orders if orders != SENTINEL
|
|
1103
|
+
_body[:client_order_id] = client_order_id if client_order_id != SENTINEL
|
|
1104
|
+
manual_trade_form_complex = _body
|
|
1105
|
+
data, _status_code, _headers = place_complex_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_complex, extra)
|
|
1106
|
+
data
|
|
1107
|
+
end
|
|
1108
|
+
|
|
1109
|
+
# Place complex order
|
|
1110
|
+
#
|
|
1111
|
+
# Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable.
|
|
1112
|
+
# Only supported on certain brokerages.
|
|
1113
|
+
#
|
|
1114
|
+
# - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled.
|
|
1115
|
+
# - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order.
|
|
1116
|
+
# - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
|
|
1117
|
+
#
|
|
1118
|
+
# @param type [ManualTradeFormComplexType] The complex order type. - `OCO`: One Cancels the Other — two peer orders. - `OTO`: One Triggers the Other — a trigger order and a conditional order. - `OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer orders.
|
|
1119
|
+
# @param orders [Array<ComplexOrderLeg>] The orders that make up the complex order. Required counts and roles per type: - `OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER` and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
|
|
1120
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
|
1121
|
+
# @param user_id [String]
|
|
1122
|
+
# @param user_secret [String]
|
|
1123
|
+
# @param client_order_id [String] An optional client-provided identifier for this complex order. Passed through to the brokerage and returned in the response.
|
|
1124
|
+
# @param body [ManualTradeFormComplex]
|
|
1125
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
1126
|
+
def place_complex_order_with_http_info(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {})
|
|
1127
|
+
_body = {}
|
|
1128
|
+
_body[:type] = type if type != SENTINEL
|
|
1129
|
+
_body[:orders] = orders if orders != SENTINEL
|
|
1130
|
+
_body[:client_order_id] = client_order_id if client_order_id != SENTINEL
|
|
1131
|
+
manual_trade_form_complex = _body
|
|
1132
|
+
place_complex_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_complex, extra)
|
|
1133
|
+
end
|
|
1134
|
+
|
|
1135
|
+
# Place complex order
|
|
1136
|
+
# Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable. Only supported on certain brokerages. - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled. - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order. - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
|
|
1137
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
|
1138
|
+
# @param user_id [String]
|
|
1139
|
+
# @param user_secret [String]
|
|
1140
|
+
# @param manual_trade_form_complex [ManualTradeFormComplex]
|
|
1141
|
+
# @param [Hash] opts the optional parameters
|
|
1142
|
+
# @return [ComplexOrderResponse]
|
|
1143
|
+
private def place_complex_order_impl(account_id, user_id, user_secret, manual_trade_form_complex, opts = {})
|
|
1144
|
+
data, _status_code, _headers = place_complex_order_with_http_info(account_id, user_id, user_secret, manual_trade_form_complex, opts)
|
|
1145
|
+
data
|
|
1146
|
+
end
|
|
1147
|
+
|
|
1148
|
+
# Place complex order
|
|
1149
|
+
# Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable. Only supported on certain brokerages. - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled. - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order. - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
|
|
1150
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
|
1151
|
+
# @param user_id [String]
|
|
1152
|
+
# @param user_secret [String]
|
|
1153
|
+
# @param manual_trade_form_complex [ManualTradeFormComplex]
|
|
1154
|
+
# @param [Hash] opts the optional parameters
|
|
1155
|
+
# @return [Array<(ComplexOrderResponse, Integer, Hash)>] ComplexOrderResponse data, response status code and response headers
|
|
1156
|
+
private def place_complex_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_complex, opts = {})
|
|
1157
|
+
if @api_client.config.debugging
|
|
1158
|
+
@api_client.config.logger.debug 'Calling API: TradingApi.place_complex_order ...'
|
|
1159
|
+
end
|
|
1160
|
+
# verify the required parameter 'account_id' is set
|
|
1161
|
+
if @api_client.config.client_side_validation && account_id.nil?
|
|
1162
|
+
fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.place_complex_order"
|
|
1163
|
+
end
|
|
1164
|
+
# verify the required parameter 'user_id' is set
|
|
1165
|
+
if @api_client.config.client_side_validation && user_id.nil?
|
|
1166
|
+
fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.place_complex_order"
|
|
1167
|
+
end
|
|
1168
|
+
# verify the required parameter 'user_secret' is set
|
|
1169
|
+
if @api_client.config.client_side_validation && user_secret.nil?
|
|
1170
|
+
fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.place_complex_order"
|
|
1171
|
+
end
|
|
1172
|
+
# verify the required parameter 'manual_trade_form_complex' is set
|
|
1173
|
+
if @api_client.config.client_side_validation && manual_trade_form_complex.nil?
|
|
1174
|
+
fail ArgumentError, "Missing the required parameter 'manual_trade_form_complex' when calling TradingApi.place_complex_order"
|
|
1175
|
+
end
|
|
1176
|
+
# resource path
|
|
1177
|
+
local_var_path = '/accounts/{accountId}/trading/complex'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
|
|
1178
|
+
|
|
1179
|
+
# query parameters
|
|
1180
|
+
query_params = opts[:query_params] || {}
|
|
1181
|
+
query_params[:'userId'] = user_id
|
|
1182
|
+
query_params[:'userSecret'] = user_secret
|
|
1183
|
+
|
|
1184
|
+
# header parameters
|
|
1185
|
+
header_params = opts[:header_params] || {}
|
|
1186
|
+
# HTTP header 'Accept' (if needed)
|
|
1187
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
|
1188
|
+
# HTTP header 'Content-Type'
|
|
1189
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
1190
|
+
if !content_type.nil?
|
|
1191
|
+
header_params['Content-Type'] = content_type
|
|
1192
|
+
end
|
|
1193
|
+
|
|
1194
|
+
# form parameters
|
|
1195
|
+
form_params = opts[:form_params] || {}
|
|
1196
|
+
|
|
1197
|
+
# http body (model)
|
|
1198
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(manual_trade_form_complex)
|
|
1199
|
+
|
|
1200
|
+
# return_type
|
|
1201
|
+
return_type = opts[:debug_return_type] || 'ComplexOrderResponse'
|
|
1202
|
+
|
|
1203
|
+
# auth_names
|
|
1204
|
+
auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
|
|
1205
|
+
|
|
1206
|
+
new_options = opts.merge(
|
|
1207
|
+
:operation => :"TradingApi.place_complex_order",
|
|
1208
|
+
:header_params => header_params,
|
|
1209
|
+
:query_params => query_params,
|
|
1210
|
+
:form_params => form_params,
|
|
1211
|
+
:body => post_body,
|
|
1212
|
+
:auth_names => auth_names,
|
|
1213
|
+
:return_type => return_type
|
|
1214
|
+
)
|
|
1215
|
+
|
|
1216
|
+
data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
|
|
1217
|
+
if @api_client.config.debugging
|
|
1218
|
+
@api_client.config.logger.debug "API called: TradingApi#place_complex_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
1219
|
+
end
|
|
1220
|
+
return data, status_code, headers, response
|
|
1221
|
+
end
|
|
1222
|
+
|
|
1223
|
+
|
|
1082
1224
|
# Place crypto order
|
|
1083
1225
|
#
|
|
1084
1226
|
# Places an order in the specified account.
|
|
@@ -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
|