snaptrade 2.0.202 → 2.0.204
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 +24 -9
- data/lib/snaptrade/api/experimental_endpoints_api.rb +21 -17
- data/lib/snaptrade/api/trading_api.rb +14 -6
- data/lib/snaptrade/models/all_account_positions_response.rb +18 -4
- data/lib/snaptrade/models/all_account_positions_response_data_freshness.rb +223 -0
- data/lib/snaptrade/models/manual_trade_form_complex.rb +0 -1
- data/lib/snaptrade/models/manual_trade_form_with_options.rb +28 -7
- data/lib/snaptrade/models/manual_trade_place_time_in_force_strict.rb +40 -0
- data/lib/snaptrade/models/trade_detection_add_subscription_request.rb +38 -4
- data/lib/snaptrade/models/trade_detection_cancel_subscription_request.rb +222 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +3 -0
- data/spec/api/experimental_endpoints_api_spec.rb +1 -1
- data/spec/models/all_account_positions_response_data_freshness_spec.rb +29 -0
- data/spec/models/all_account_positions_response_spec.rb +6 -0
- data/spec/models/manual_trade_form_with_options_spec.rb +12 -0
- data/spec/models/manual_trade_place_time_in_force_strict_spec.rb +23 -0
- data/spec/models/trade_detection_add_subscription_request_spec.rb +6 -0
- data/spec/models/trade_detection_cancel_subscription_request_spec.rb +29 -0
- metadata +11 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d49d5c08cb9a40f52ea37f9329cf5617cab52c12683ac9a0536af8ab63b548a7
|
|
4
|
+
data.tar.gz: 8498700322066b21498f954120bf5287f11ba9929e782a4d1fdd5303f5670d7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ead930da246e29f36bdf30d97cd626e8318ecccb0a75c7c575b4c2304489199dbc8cd6ba96c5c656ba9490fd4d730d562be2adeed3afdcf8f22ecaf51d7f76be
|
|
7
|
+
data.tar.gz: 5ed9163deb7550bcb877a389e287d9ac7ed9738595824e7e417fdf09af3a92f0906489cc54e5c7113cef38317480bbac381dc4c005ec65629f57aee9ff484789
|
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.204)
|
|
10
10
|
[](https://snaptrade.com/)
|
|
11
11
|
|
|
12
12
|
</div>
|
|
@@ -94,7 +94,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
|
94
94
|
Add to Gemfile:
|
|
95
95
|
|
|
96
96
|
```ruby
|
|
97
|
-
gem 'snaptrade', '~> 2.0.
|
|
97
|
+
gem 'snaptrade', '~> 2.0.204'
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
## Getting Started<a id="getting-started"></a>
|
|
@@ -1349,6 +1349,7 @@ This endpoint requires `userId` and `userSecret` in addition to the partner sign
|
|
|
1349
1349
|
```ruby
|
|
1350
1350
|
result = snaptrade.experimental_endpoints.add_subscription(
|
|
1351
1351
|
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
1352
|
+
check_interval_seconds: 300,
|
|
1352
1353
|
user_id: "snaptrade-user-123",
|
|
1353
1354
|
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
1354
1355
|
)
|
|
@@ -1361,6 +1362,10 @@ p result
|
|
|
1361
1362
|
Unique identifier for the connected brokerage account. This is the UUID used to
|
|
1362
1363
|
reference the account in SnapTrade.
|
|
1363
1364
|
|
|
1365
|
+
##### check_interval_seconds: `Integer`<a id="check_interval_seconds-integer"></a>
|
|
1366
|
+
How often the subscribed account should be checked for new trades. Must match an
|
|
1367
|
+
active Trade Detection plan.
|
|
1368
|
+
|
|
1364
1369
|
##### user_id: `String`<a id="user_id-string"></a>
|
|
1365
1370
|
##### user_secret: `String`<a id="user_secret-string"></a>
|
|
1366
1371
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
@@ -2427,7 +2432,7 @@ result = snaptrade.trading.place_complex_order(
|
|
|
2427
2432
|
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
|
2428
2433
|
user_id: "snaptrade-user-123",
|
|
2429
2434
|
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
|
2430
|
-
client_order_id: "
|
|
2435
|
+
client_order_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
2431
2436
|
)
|
|
2432
2437
|
p result
|
|
2433
2438
|
```
|
|
@@ -2450,10 +2455,7 @@ The ID of the account to execute the trade on.
|
|
|
2450
2455
|
|
|
2451
2456
|
##### user_id: `String`<a id="user_id-string"></a>
|
|
2452
2457
|
##### user_secret: `String`<a id="user_secret-string"></a>
|
|
2453
|
-
##### client_order_id: `String
|
|
2454
|
-
An optional client-provided identifier for this complex order. Passed through to
|
|
2455
|
-
the brokerage and returned in the response.
|
|
2456
|
-
|
|
2458
|
+
##### client_order_id: [`String`](./lib/snaptrade/models/string.rb)<a id="client_order_id-stringlibsnaptrademodelsstringrb"></a>
|
|
2457
2459
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
2458
2460
|
|
|
2459
2461
|
[ComplexOrderResponse](./lib/snaptrade/models/complex_order_response.rb)
|
|
@@ -2571,10 +2573,12 @@ result = snaptrade.trading.place_force_order(
|
|
|
2571
2573
|
universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
|
|
2572
2574
|
symbol: "AAPL",
|
|
2573
2575
|
trading_session: "REGULAR",
|
|
2576
|
+
expiry_date: "2026-08-21T23:27:55.027Z",
|
|
2574
2577
|
price: 31.33,
|
|
2575
2578
|
stop: 31.33,
|
|
2576
2579
|
units: 10.5,
|
|
2577
2580
|
notional_value: None,
|
|
2581
|
+
client_order_id: "550e8400-e29b-41d4-a716-446655440000",
|
|
2578
2582
|
)
|
|
2579
2583
|
p result
|
|
2580
2584
|
```
|
|
@@ -2595,7 +2599,7 @@ The type of order to place. - For `Limit` and `StopLimit` orders, the `price`
|
|
|
2595
2599
|
field is required. - For `Stop` and `StopLimit` orders, the `stop` field is
|
|
2596
2600
|
required.
|
|
2597
2601
|
|
|
2598
|
-
##### time_in_force: [`
|
|
2602
|
+
##### time_in_force: [`ManualTradePlaceTimeInForceStrict`](./lib/snaptrade/models/manual_trade_place_time_in_force_strict.rb)<a id="time_in_force-manualtradeplacetimeinforcestrictlibsnaptrademodelsmanual_trade_place_time_in_force_strictrb"></a>
|
|
2599
2603
|
The Time in Force type for the order. This field indicates how long the order
|
|
2600
2604
|
will remain active before it is executed or expires. Here are the supported
|
|
2601
2605
|
values: - `Day` - Day. The order is valid only for the trading day on which it
|
|
@@ -2603,7 +2607,10 @@ is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed
|
|
|
2603
2607
|
or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety
|
|
2604
2608
|
immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order
|
|
2605
2609
|
must be executed immediately. Any portion of the order that cannot be filled
|
|
2606
|
-
immediately will be canceled.
|
|
2610
|
+
immediately will be canceled. - `GTD` - Good Til Date. The order is valid until
|
|
2611
|
+
`expiry_date`, which is required. Not available for market orders. GTD orders
|
|
2612
|
+
are only available on certain brokerages. Visit
|
|
2613
|
+
https://support.snaptrade.com/brokerages for brokerage support.
|
|
2607
2614
|
|
|
2608
2615
|
##### user_id: `String`<a id="user_id-string"></a>
|
|
2609
2616
|
##### user_secret: `String`<a id="user_secret-string"></a>
|
|
@@ -2621,6 +2628,13 @@ order will be placed in. This is only available for certain brokerages. Defaults
|
|
|
2621
2628
|
to REGULAR. Here are the supported values: - `REGULAR` - Regular trading hours.
|
|
2622
2629
|
- `EXTENDED` - Extended trading hours.
|
|
2623
2630
|
|
|
2631
|
+
##### expiry_date: `Time`<a id="expiry_date-time"></a>
|
|
2632
|
+
Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format
|
|
2633
|
+
indicating when the order expires. Required when `time_in_force` is `GTD`.
|
|
2634
|
+
Include a timezone offset or `Z` for UTC; if no timezone is provided, UTC is
|
|
2635
|
+
assumed. GTD orders are only available on certain brokerages. Visit
|
|
2636
|
+
https://support.snaptrade.com/brokerages for brokerage support.
|
|
2637
|
+
|
|
2624
2638
|
##### price: `Float`<a id="price-float"></a>
|
|
2625
2639
|
The limit price for `Limit` and `StopLimit` orders.
|
|
2626
2640
|
|
|
@@ -2634,6 +2648,7 @@ provided. If placing an Option order, this field represents the number of
|
|
|
2634
2648
|
contracts to buy or sell. (e.g., 1 contract = 100 shares).
|
|
2635
2649
|
|
|
2636
2650
|
##### notional_value: [`ManualTradeFormNotionalValue`](./lib/snaptrade/models/manual_trade_form_notional_value.rb)<a id="notional_value-manualtradeformnotionalvaluelibsnaptrademodelsmanual_trade_form_notional_valuerb"></a>
|
|
2651
|
+
##### client_order_id: [`String`](./lib/snaptrade/models/string.rb)<a id="client_order_id-stringlibsnaptrademodelsstringrb"></a>
|
|
2637
2652
|
#### 🔄 Return<a id="🔄-return"></a>
|
|
2638
2653
|
|
|
2639
2654
|
[AccountOrderRecord](./lib/snaptrade/models/account_order_record.rb)
|
|
@@ -23,13 +23,15 @@ module SnapTrade
|
|
|
23
23
|
# This endpoint requires `userId` and `userSecret` in addition to the partner signature.
|
|
24
24
|
#
|
|
25
25
|
# @param account_id [String] Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
|
26
|
+
# @param check_interval_seconds [Integer] How often the subscribed account should be checked for new trades. Must match an active Trade Detection plan.
|
|
26
27
|
# @param user_id [String]
|
|
27
28
|
# @param user_secret [String]
|
|
28
29
|
# @param body [TradeDetectionAddSubscriptionRequest]
|
|
29
30
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
30
|
-
def add_subscription(account_id:, user_id:, user_secret:, extra: {})
|
|
31
|
+
def add_subscription(account_id:, check_interval_seconds:, user_id:, user_secret:, extra: {})
|
|
31
32
|
_body = {}
|
|
32
33
|
_body[:account_id] = account_id if account_id != SENTINEL
|
|
34
|
+
_body[:check_interval_seconds] = check_interval_seconds if check_interval_seconds != SENTINEL
|
|
33
35
|
trade_detection_add_subscription_request = _body
|
|
34
36
|
data, _status_code, _headers = add_subscription_with_http_info_impl(user_id, user_secret, trade_detection_add_subscription_request, extra)
|
|
35
37
|
data
|
|
@@ -41,13 +43,15 @@ module SnapTrade
|
|
|
41
43
|
# This endpoint requires `userId` and `userSecret` in addition to the partner signature.
|
|
42
44
|
#
|
|
43
45
|
# @param account_id [String] Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
|
46
|
+
# @param check_interval_seconds [Integer] How often the subscribed account should be checked for new trades. Must match an active Trade Detection plan.
|
|
44
47
|
# @param user_id [String]
|
|
45
48
|
# @param user_secret [String]
|
|
46
49
|
# @param body [TradeDetectionAddSubscriptionRequest]
|
|
47
50
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
48
|
-
def add_subscription_with_http_info(account_id:, user_id:, user_secret:, extra: {})
|
|
51
|
+
def add_subscription_with_http_info(account_id:, check_interval_seconds:, user_id:, user_secret:, extra: {})
|
|
49
52
|
_body = {}
|
|
50
53
|
_body[:account_id] = account_id if account_id != SENTINEL
|
|
54
|
+
_body[:check_interval_seconds] = check_interval_seconds if check_interval_seconds != SENTINEL
|
|
51
55
|
trade_detection_add_subscription_request = _body
|
|
52
56
|
add_subscription_with_http_info_impl(user_id, user_secret, trade_detection_add_subscription_request, extra)
|
|
53
57
|
end
|
|
@@ -141,13 +145,13 @@ module SnapTrade
|
|
|
141
145
|
# This endpoint requires partner signature authentication only and does not require `userId` or `userSecret`.
|
|
142
146
|
#
|
|
143
147
|
# @param account_id [String] Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
|
144
|
-
# @param body [
|
|
148
|
+
# @param body [TradeDetectionCancelSubscriptionRequest]
|
|
145
149
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
146
150
|
def cancel_subscription(account_id:, extra: {})
|
|
147
151
|
_body = {}
|
|
148
152
|
_body[:account_id] = account_id if account_id != SENTINEL
|
|
149
|
-
|
|
150
|
-
data, _status_code, _headers = cancel_subscription_with_http_info_impl(
|
|
153
|
+
trade_detection_cancel_subscription_request = _body
|
|
154
|
+
data, _status_code, _headers = cancel_subscription_with_http_info_impl(trade_detection_cancel_subscription_request, extra)
|
|
151
155
|
data
|
|
152
156
|
end
|
|
153
157
|
|
|
@@ -157,37 +161,37 @@ module SnapTrade
|
|
|
157
161
|
# This endpoint requires partner signature authentication only and does not require `userId` or `userSecret`.
|
|
158
162
|
#
|
|
159
163
|
# @param account_id [String] Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
|
160
|
-
# @param body [
|
|
164
|
+
# @param body [TradeDetectionCancelSubscriptionRequest]
|
|
161
165
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
162
166
|
def cancel_subscription_with_http_info(account_id:, extra: {})
|
|
163
167
|
_body = {}
|
|
164
168
|
_body[:account_id] = account_id if account_id != SENTINEL
|
|
165
|
-
|
|
166
|
-
cancel_subscription_with_http_info_impl(
|
|
169
|
+
trade_detection_cancel_subscription_request = _body
|
|
170
|
+
cancel_subscription_with_http_info_impl(trade_detection_cancel_subscription_request, extra)
|
|
167
171
|
end
|
|
168
172
|
|
|
169
173
|
# Cancel a Trade Detection subscription
|
|
170
174
|
# Cancels a Trade Detection subscription for a connected brokerage account. This endpoint requires partner signature authentication only and does not require `userId` or `userSecret`.
|
|
171
|
-
# @param
|
|
175
|
+
# @param trade_detection_cancel_subscription_request [TradeDetectionCancelSubscriptionRequest]
|
|
172
176
|
# @param [Hash] opts the optional parameters
|
|
173
177
|
# @return [TradeDetectionCancelSubscriptionResponse]
|
|
174
|
-
private def cancel_subscription_impl(
|
|
175
|
-
data, _status_code, _headers = cancel_subscription_with_http_info(
|
|
178
|
+
private def cancel_subscription_impl(trade_detection_cancel_subscription_request, opts = {})
|
|
179
|
+
data, _status_code, _headers = cancel_subscription_with_http_info(trade_detection_cancel_subscription_request, opts)
|
|
176
180
|
data
|
|
177
181
|
end
|
|
178
182
|
|
|
179
183
|
# Cancel a Trade Detection subscription
|
|
180
184
|
# Cancels a Trade Detection subscription for a connected brokerage account. This endpoint requires partner signature authentication only and does not require `userId` or `userSecret`.
|
|
181
|
-
# @param
|
|
185
|
+
# @param trade_detection_cancel_subscription_request [TradeDetectionCancelSubscriptionRequest]
|
|
182
186
|
# @param [Hash] opts the optional parameters
|
|
183
187
|
# @return [Array<(TradeDetectionCancelSubscriptionResponse, Integer, Hash)>] TradeDetectionCancelSubscriptionResponse data, response status code and response headers
|
|
184
|
-
private def cancel_subscription_with_http_info_impl(
|
|
188
|
+
private def cancel_subscription_with_http_info_impl(trade_detection_cancel_subscription_request, opts = {})
|
|
185
189
|
if @api_client.config.debugging
|
|
186
190
|
@api_client.config.logger.debug 'Calling API: ExperimentalEndpointsApi.cancel_subscription ...'
|
|
187
191
|
end
|
|
188
|
-
# verify the required parameter '
|
|
189
|
-
if @api_client.config.client_side_validation &&
|
|
190
|
-
fail ArgumentError, "Missing the required parameter '
|
|
192
|
+
# verify the required parameter 'trade_detection_cancel_subscription_request' is set
|
|
193
|
+
if @api_client.config.client_side_validation && trade_detection_cancel_subscription_request.nil?
|
|
194
|
+
fail ArgumentError, "Missing the required parameter 'trade_detection_cancel_subscription_request' when calling ExperimentalEndpointsApi.cancel_subscription"
|
|
191
195
|
end
|
|
192
196
|
# resource path
|
|
193
197
|
local_var_path = '/snapTrade/tradeDetection/subscriptions/cancel'
|
|
@@ -209,7 +213,7 @@ module SnapTrade
|
|
|
209
213
|
form_params = opts[:form_params] || {}
|
|
210
214
|
|
|
211
215
|
# http body (model)
|
|
212
|
-
post_body = opts[:debug_body] || @api_client.object_to_http_body(
|
|
216
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(trade_detection_cancel_subscription_request)
|
|
213
217
|
|
|
214
218
|
# return_type
|
|
215
219
|
return_type = opts[:debug_return_type] || 'TradeDetectionCancelSubscriptionResponse'
|
|
@@ -1096,7 +1096,7 @@ module SnapTrade
|
|
|
1096
1096
|
# @param account_id [String] The ID of the account to execute the trade on.
|
|
1097
1097
|
# @param user_id [String]
|
|
1098
1098
|
# @param user_secret [String]
|
|
1099
|
-
# @param client_order_id [String]
|
|
1099
|
+
# @param client_order_id [String]
|
|
1100
1100
|
# @param body [ManualTradeFormComplex]
|
|
1101
1101
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
1102
1102
|
def place_complex_order(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {})
|
|
@@ -1124,7 +1124,7 @@ module SnapTrade
|
|
|
1124
1124
|
# @param account_id [String] The ID of the account to execute the trade on.
|
|
1125
1125
|
# @param user_id [String]
|
|
1126
1126
|
# @param user_secret [String]
|
|
1127
|
-
# @param client_order_id [String]
|
|
1127
|
+
# @param client_order_id [String]
|
|
1128
1128
|
# @param body [ManualTradeFormComplex]
|
|
1129
1129
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
1130
1130
|
def place_complex_order_with_http_info(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {})
|
|
@@ -1394,19 +1394,21 @@ module SnapTrade
|
|
|
1394
1394
|
# @param account_id [String] Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
|
1395
1395
|
# @param action [ActionStrictWithOptions] The action describes the intent or side of a trade. This is either `BUY` or `SELL` for Equity symbols or `BUY_TO_OPEN`, `BUY_TO_CLOSE`, `SELL_TO_OPEN` or `SELL_TO_CLOSE` for Options.
|
|
1396
1396
|
# @param order_type [OrderTypeStrict] The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
1397
|
-
# @param time_in_force [
|
|
1397
|
+
# @param time_in_force [ManualTradePlaceTimeInForceStrict] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until `expiry_date`, which is required. Not available for market orders. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.
|
|
1398
1398
|
# @param user_id [String]
|
|
1399
1399
|
# @param user_secret [String]
|
|
1400
1400
|
# @param universal_symbol_id [String] The universal symbol ID of the security to trade. Must be 'null' if `symbol` is provided, otherwise must be provided.
|
|
1401
1401
|
# @param symbol [String] The security's trading ticker symbol. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'.
|
|
1402
1402
|
# @param trading_session [TradingSession] The trading session for the order. This field indicates which market session the order will be placed in. This is only available for certain brokerages. Defaults to REGULAR. Here are the supported values: - `REGULAR` - Regular trading hours. - `EXTENDED` - Extended trading hours.
|
|
1403
|
+
# @param expiry_date [Time] Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the order expires. Required when `time_in_force` is `GTD`. Include a timezone offset or `Z` for UTC; if no timezone is provided, UTC is assumed. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.
|
|
1403
1404
|
# @param price [Float] The limit price for `Limit` and `StopLimit` orders.
|
|
1404
1405
|
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
|
1405
1406
|
# @param units [Float] For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).
|
|
1406
1407
|
# @param notional_value [ManualTradeFormNotionalValue]
|
|
1408
|
+
# @param client_order_id [String]
|
|
1407
1409
|
# @param body [ManualTradeFormWithOptions]
|
|
1408
1410
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
1409
|
-
def place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {})
|
|
1411
|
+
def place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', expiry_date: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, client_order_id: SENTINEL, extra: {})
|
|
1410
1412
|
_body = {}
|
|
1411
1413
|
_body[:account_id] = account_id if account_id != SENTINEL
|
|
1412
1414
|
_body[:action] = action if action != SENTINEL
|
|
@@ -1415,10 +1417,12 @@ module SnapTrade
|
|
|
1415
1417
|
_body[:order_type] = order_type if order_type != SENTINEL
|
|
1416
1418
|
_body[:time_in_force] = time_in_force if time_in_force != SENTINEL
|
|
1417
1419
|
_body[:trading_session] = trading_session if trading_session != SENTINEL
|
|
1420
|
+
_body[:expiry_date] = expiry_date if expiry_date != SENTINEL
|
|
1418
1421
|
_body[:price] = price if price != SENTINEL
|
|
1419
1422
|
_body[:stop] = stop if stop != SENTINEL
|
|
1420
1423
|
_body[:units] = units if units != SENTINEL
|
|
1421
1424
|
_body[:notional_value] = notional_value if notional_value != SENTINEL
|
|
1425
|
+
_body[:client_order_id] = client_order_id if client_order_id != SENTINEL
|
|
1422
1426
|
manual_trade_form_with_options = _body
|
|
1423
1427
|
data, _status_code, _headers = place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, extra)
|
|
1424
1428
|
data
|
|
@@ -1435,19 +1439,21 @@ module SnapTrade
|
|
|
1435
1439
|
# @param account_id [String] Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
|
1436
1440
|
# @param action [ActionStrictWithOptions] The action describes the intent or side of a trade. This is either `BUY` or `SELL` for Equity symbols or `BUY_TO_OPEN`, `BUY_TO_CLOSE`, `SELL_TO_OPEN` or `SELL_TO_CLOSE` for Options.
|
|
1437
1441
|
# @param order_type [OrderTypeStrict] The type of order to place. - For `Limit` and `StopLimit` orders, the `price` field is required. - For `Stop` and `StopLimit` orders, the `stop` field is required.
|
|
1438
|
-
# @param time_in_force [
|
|
1442
|
+
# @param time_in_force [ManualTradePlaceTimeInForceStrict] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until `expiry_date`, which is required. Not available for market orders. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.
|
|
1439
1443
|
# @param user_id [String]
|
|
1440
1444
|
# @param user_secret [String]
|
|
1441
1445
|
# @param universal_symbol_id [String] The universal symbol ID of the security to trade. Must be 'null' if `symbol` is provided, otherwise must be provided.
|
|
1442
1446
|
# @param symbol [String] The security's trading ticker symbol. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'.
|
|
1443
1447
|
# @param trading_session [TradingSession] The trading session for the order. This field indicates which market session the order will be placed in. This is only available for certain brokerages. Defaults to REGULAR. Here are the supported values: - `REGULAR` - Regular trading hours. - `EXTENDED` - Extended trading hours.
|
|
1448
|
+
# @param expiry_date [Time] Timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format indicating when the order expires. Required when `time_in_force` is `GTD`. Include a timezone offset or `Z` for UTC; if no timezone is provided, UTC is assumed. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.
|
|
1444
1449
|
# @param price [Float] The limit price for `Limit` and `StopLimit` orders.
|
|
1445
1450
|
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
|
1446
1451
|
# @param units [Float] For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).
|
|
1447
1452
|
# @param notional_value [ManualTradeFormNotionalValue]
|
|
1453
|
+
# @param client_order_id [String]
|
|
1448
1454
|
# @param body [ManualTradeFormWithOptions]
|
|
1449
1455
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
|
1450
|
-
def place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {})
|
|
1456
|
+
def place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', expiry_date: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, client_order_id: SENTINEL, extra: {})
|
|
1451
1457
|
_body = {}
|
|
1452
1458
|
_body[:account_id] = account_id if account_id != SENTINEL
|
|
1453
1459
|
_body[:action] = action if action != SENTINEL
|
|
@@ -1456,10 +1462,12 @@ module SnapTrade
|
|
|
1456
1462
|
_body[:order_type] = order_type if order_type != SENTINEL
|
|
1457
1463
|
_body[:time_in_force] = time_in_force if time_in_force != SENTINEL
|
|
1458
1464
|
_body[:trading_session] = trading_session if trading_session != SENTINEL
|
|
1465
|
+
_body[:expiry_date] = expiry_date if expiry_date != SENTINEL
|
|
1459
1466
|
_body[:price] = price if price != SENTINEL
|
|
1460
1467
|
_body[:stop] = stop if stop != SENTINEL
|
|
1461
1468
|
_body[:units] = units if units != SENTINEL
|
|
1462
1469
|
_body[:notional_value] = notional_value if notional_value != SENTINEL
|
|
1470
|
+
_body[:client_order_id] = client_order_id if client_order_id != SENTINEL
|
|
1463
1471
|
manual_trade_form_with_options = _body
|
|
1464
1472
|
place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, extra)
|
|
1465
1473
|
end
|
|
@@ -16,10 +16,13 @@ module SnapTrade
|
|
|
16
16
|
# Positions returned for the request.
|
|
17
17
|
attr_accessor :results
|
|
18
18
|
|
|
19
|
+
attr_accessor :data_freshness
|
|
20
|
+
|
|
19
21
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
20
22
|
def self.attribute_map
|
|
21
23
|
{
|
|
22
|
-
:'results' => :'results'
|
|
24
|
+
:'results' => :'results',
|
|
25
|
+
:'data_freshness' => :'data_freshness'
|
|
23
26
|
}
|
|
24
27
|
end
|
|
25
28
|
|
|
@@ -31,7 +34,8 @@ module SnapTrade
|
|
|
31
34
|
# Attribute type mapping.
|
|
32
35
|
def self.openapi_types
|
|
33
36
|
{
|
|
34
|
-
:'results' => :'Array<AccountPosition>'
|
|
37
|
+
:'results' => :'Array<AccountPosition>',
|
|
38
|
+
:'data_freshness' => :'AllAccountPositionsResponseDataFreshness'
|
|
35
39
|
}
|
|
36
40
|
end
|
|
37
41
|
|
|
@@ -61,6 +65,10 @@ module SnapTrade
|
|
|
61
65
|
self.results = value
|
|
62
66
|
end
|
|
63
67
|
end
|
|
68
|
+
|
|
69
|
+
if attributes.key?(:'data_freshness')
|
|
70
|
+
self.data_freshness = attributes[:'data_freshness']
|
|
71
|
+
end
|
|
64
72
|
end
|
|
65
73
|
|
|
66
74
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -71,6 +79,10 @@ module SnapTrade
|
|
|
71
79
|
invalid_properties.push('invalid value for "results", results cannot be nil.')
|
|
72
80
|
end
|
|
73
81
|
|
|
82
|
+
if @data_freshness.nil?
|
|
83
|
+
invalid_properties.push('invalid value for "data_freshness", data_freshness cannot be nil.')
|
|
84
|
+
end
|
|
85
|
+
|
|
74
86
|
invalid_properties
|
|
75
87
|
end
|
|
76
88
|
|
|
@@ -78,6 +90,7 @@ module SnapTrade
|
|
|
78
90
|
# @return true if the model is valid
|
|
79
91
|
def valid?
|
|
80
92
|
return false if @results.nil?
|
|
93
|
+
return false if @data_freshness.nil?
|
|
81
94
|
true
|
|
82
95
|
end
|
|
83
96
|
|
|
@@ -86,7 +99,8 @@ module SnapTrade
|
|
|
86
99
|
def ==(o)
|
|
87
100
|
return true if self.equal?(o)
|
|
88
101
|
self.class == o.class &&
|
|
89
|
-
results == o.results
|
|
102
|
+
results == o.results &&
|
|
103
|
+
data_freshness == o.data_freshness
|
|
90
104
|
end
|
|
91
105
|
|
|
92
106
|
# @see the `==` method
|
|
@@ -98,7 +112,7 @@ module SnapTrade
|
|
|
98
112
|
# Calculates hash code according to all attributes.
|
|
99
113
|
# @return [Integer] Hash code
|
|
100
114
|
def hash
|
|
101
|
-
[results].hash
|
|
115
|
+
[results, data_freshness].hash
|
|
102
116
|
end
|
|
103
117
|
|
|
104
118
|
# Builds the object from hash
|
|
@@ -0,0 +1,223 @@
|
|
|
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
|
+
# Metadata describing freshness of the returned positions data.
|
|
15
|
+
class AllAccountPositionsResponseDataFreshness
|
|
16
|
+
# The time the returned positions data was fetched from the brokerage.
|
|
17
|
+
attr_accessor :as_of
|
|
18
|
+
|
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
20
|
+
def self.attribute_map
|
|
21
|
+
{
|
|
22
|
+
:'as_of' => :'as_of'
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Returns all the JSON keys this model knows about
|
|
27
|
+
def self.acceptable_attributes
|
|
28
|
+
attribute_map.values
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Attribute type mapping.
|
|
32
|
+
def self.openapi_types
|
|
33
|
+
{
|
|
34
|
+
:'as_of' => :'Time'
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# List of attributes with nullable: true
|
|
39
|
+
def self.openapi_nullable
|
|
40
|
+
Set.new([
|
|
41
|
+
])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Initializes the object
|
|
45
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
46
|
+
def initialize(attributes = {})
|
|
47
|
+
if (!attributes.is_a?(Hash))
|
|
48
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SnapTrade::AllAccountPositionsResponseDataFreshness` initialize method"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
52
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
53
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
54
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SnapTrade::AllAccountPositionsResponseDataFreshness`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
55
|
+
end
|
|
56
|
+
h[k.to_sym] = v
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if attributes.key?(:'as_of')
|
|
60
|
+
self.as_of = attributes[:'as_of']
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
65
|
+
# @return Array for valid properties with the reasons
|
|
66
|
+
def list_invalid_properties
|
|
67
|
+
invalid_properties = Array.new
|
|
68
|
+
if @as_of.nil?
|
|
69
|
+
invalid_properties.push('invalid value for "as_of", as_of cannot be nil.')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
invalid_properties
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Check to see if the all the properties in the model are valid
|
|
76
|
+
# @return true if the model is valid
|
|
77
|
+
def valid?
|
|
78
|
+
return false if @as_of.nil?
|
|
79
|
+
true
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Checks equality by comparing each attribute.
|
|
83
|
+
# @param [Object] Object to be compared
|
|
84
|
+
def ==(o)
|
|
85
|
+
return true if self.equal?(o)
|
|
86
|
+
self.class == o.class &&
|
|
87
|
+
as_of == o.as_of
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# @see the `==` method
|
|
91
|
+
# @param [Object] Object to be compared
|
|
92
|
+
def eql?(o)
|
|
93
|
+
self == o
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Calculates hash code according to all attributes.
|
|
97
|
+
# @return [Integer] Hash code
|
|
98
|
+
def hash
|
|
99
|
+
[as_of].hash
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Builds the object from hash
|
|
103
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
104
|
+
# @return [Object] Returns the model itself
|
|
105
|
+
def self.build_from_hash(attributes)
|
|
106
|
+
new.build_from_hash(attributes)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Builds the object from hash
|
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
111
|
+
# @return [Object] Returns the model itself
|
|
112
|
+
def build_from_hash(attributes)
|
|
113
|
+
return nil unless attributes.is_a?(Hash)
|
|
114
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
115
|
+
self.class.openapi_types.each_pair do |key, type|
|
|
116
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
117
|
+
self.send("#{key}=", nil)
|
|
118
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
119
|
+
# check to ensure the input is an array given that the attribute
|
|
120
|
+
# is documented as an array but the input is not
|
|
121
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
122
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
|
123
|
+
end
|
|
124
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
125
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
self
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Deserializes the data based on type
|
|
133
|
+
# @param string type Data type
|
|
134
|
+
# @param string value Value to be deserialized
|
|
135
|
+
# @return [Object] Deserialized data
|
|
136
|
+
def _deserialize(type, value)
|
|
137
|
+
case type.to_sym
|
|
138
|
+
when :Time
|
|
139
|
+
Time.parse(value)
|
|
140
|
+
when :Date
|
|
141
|
+
Date.parse(value)
|
|
142
|
+
when :String
|
|
143
|
+
value.to_s
|
|
144
|
+
when :Integer
|
|
145
|
+
value.to_i
|
|
146
|
+
when :Float
|
|
147
|
+
value.to_f
|
|
148
|
+
when :Boolean
|
|
149
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
150
|
+
true
|
|
151
|
+
else
|
|
152
|
+
false
|
|
153
|
+
end
|
|
154
|
+
when :Object
|
|
155
|
+
# generic object (usually a Hash), return directly
|
|
156
|
+
value
|
|
157
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
158
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
159
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
160
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
161
|
+
k_type = Regexp.last_match[:k_type]
|
|
162
|
+
v_type = Regexp.last_match[:v_type]
|
|
163
|
+
{}.tap do |hash|
|
|
164
|
+
value.each do |k, v|
|
|
165
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
else # model
|
|
169
|
+
# models (e.g. Pet) or oneOf
|
|
170
|
+
klass = SnapTrade.const_get(type)
|
|
171
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# Returns the string representation of the object
|
|
176
|
+
# @return [String] String presentation of the object
|
|
177
|
+
def to_s
|
|
178
|
+
to_hash.to_s
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
|
183
|
+
def to_body
|
|
184
|
+
to_hash
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Returns the object in the form of hash
|
|
188
|
+
# @return [Hash] Returns the object in the form of hash
|
|
189
|
+
def to_hash
|
|
190
|
+
hash = {}
|
|
191
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
192
|
+
value = self.send(attr)
|
|
193
|
+
if value.nil?
|
|
194
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
195
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
hash[param] = _to_hash(value)
|
|
199
|
+
end
|
|
200
|
+
hash
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Outputs non-array value in the form of hash
|
|
204
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
205
|
+
# @param [Object] value Any valid value
|
|
206
|
+
# @return [Hash] Returns the value in the form of hash
|
|
207
|
+
def _to_hash(value)
|
|
208
|
+
if value.is_a?(Array)
|
|
209
|
+
value.compact.map { |v| _to_hash(v) }
|
|
210
|
+
elsif value.is_a?(Hash)
|
|
211
|
+
{}.tap do |hash|
|
|
212
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
213
|
+
end
|
|
214
|
+
elsif value.respond_to? :to_hash
|
|
215
|
+
value.to_hash
|
|
216
|
+
else
|
|
217
|
+
value
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
end
|
|
@@ -19,7 +19,6 @@ module SnapTrade
|
|
|
19
19
|
# 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`
|
|
20
20
|
attr_accessor :orders
|
|
21
21
|
|
|
22
|
-
# An optional client-provided identifier for this complex order. Passed through to the brokerage and returned in the response.
|
|
23
22
|
attr_accessor :client_order_id
|
|
24
23
|
|
|
25
24
|
# Attribute mapping from ruby-style variable name to JSON key.
|