snaptrade 2.0.86 → 2.0.87
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 +89 -12
- data/lib/snaptrade/api/trading_api.rb +178 -14
- data/lib/snaptrade/models/manual_trade_form_bracket.rb +13 -19
- data/lib/snaptrade/models/manual_trade_replace_form.rb +285 -0
- data/lib/snaptrade/models/trading_instrument.rb +227 -0
- data/lib/snaptrade/models/trading_instrument_type.rb +38 -0
- data/lib/snaptrade/version.rb +1 -1
- data/lib/snaptrade.rb +3 -0
- data/spec/api/trading_api_spec.rb +17 -0
- data/spec/models/manual_trade_form_bracket_spec.rb +3 -3
- data/spec/models/manual_trade_replace_form_spec.rb +59 -0
- data/spec/models/trading_instrument_spec.rb +35 -0
- data/spec/models/trading_instrument_type_spec.rb +23 -0
- metadata +10 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b2590e38f7ba11a0ccb94cbf5cb4cb24e4a2502655b1edfea44f901837b6b0a
|
4
|
+
data.tar.gz: cfe4b4d60b89e088a9cb8dc2e69e896be576c662be22b7da3a5f9aee657c209f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4986f689bc118d12c1d0ed5d0c20868534696718af0519b56ea597da9f9001f4b438403e3c20d17c432325e9fd1daefc711867d6c6df9ee1978dd84e56906f22
|
7
|
+
data.tar.gz: 369e05e50fdf925edb184af4ea00ddc22e138a1123a1f618ddaad84f79351c21bced84065f9e641c85b8d6cc2286af1017d65efa8426b2b4c8c73c5163b703f9
|
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.87)
|
10
10
|
[](https://snaptrade.com/)
|
11
11
|
|
12
12
|
</div>
|
@@ -70,6 +70,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
70
70
|
* [`snaptrade.trading.place_bracket_order`](#snaptradetradingplace_bracket_order)
|
71
71
|
* [`snaptrade.trading.place_force_order`](#snaptradetradingplace_force_order)
|
72
72
|
* [`snaptrade.trading.place_order`](#snaptradetradingplace_order)
|
73
|
+
* [`snaptrade.trading.replace_order`](#snaptradetradingreplace_order)
|
73
74
|
* [`snaptrade.transactions_and_reporting.get_activities`](#snaptradetransactions_and_reportingget_activities)
|
74
75
|
* [`snaptrade.transactions_and_reporting.get_reporting_custom_range`](#snaptradetransactions_and_reportingget_reporting_custom_range)
|
75
76
|
|
@@ -80,7 +81,7 @@ Connect brokerage accounts to your app for live positions and trading
|
|
80
81
|
Add to Gemfile:
|
81
82
|
|
82
83
|
```ruby
|
83
|
-
gem 'snaptrade', '~> 2.0.
|
84
|
+
gem 'snaptrade', '~> 2.0.87'
|
84
85
|
```
|
85
86
|
|
86
87
|
## Getting Started<a id="getting-started"></a>
|
@@ -2019,9 +2020,11 @@ use. Only supported on certain brokerages
|
|
2019
2020
|
|
2020
2021
|
```ruby
|
2021
2022
|
result = snaptrade.trading.place_bracket_order(
|
2022
|
-
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
2023
2023
|
action: "BUY",
|
2024
|
-
|
2024
|
+
instrument: {
|
2025
|
+
"symbol" => "AAPL",
|
2026
|
+
"type" => "EQUITY",
|
2027
|
+
},
|
2025
2028
|
order_type: "Market",
|
2026
2029
|
time_in_force: "FOK",
|
2027
2030
|
stop_loss: {
|
@@ -2031,8 +2034,10 @@ result = snaptrade.trading.place_bracket_order(
|
|
2031
2034
|
take_profit: {
|
2032
2035
|
"limit_price" => "49.95",
|
2033
2036
|
},
|
2037
|
+
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
|
2034
2038
|
user_id: "snaptrade-user-123",
|
2035
2039
|
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
2040
|
+
symbol: "AAPL",
|
2036
2041
|
price: 31.33,
|
2037
2042
|
stop: 31.33,
|
2038
2043
|
units: 10.5,
|
@@ -2042,18 +2047,12 @@ p result
|
|
2042
2047
|
|
2043
2048
|
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
2044
2049
|
|
2045
|
-
##### account_id: `String`<a id="account_id-string"></a>
|
2046
|
-
Unique identifier for the connected brokerage account. This is the UUID used to
|
2047
|
-
reference the account in SnapTrade.
|
2048
|
-
|
2049
2050
|
##### action: [`ActionStrictWithOptions`](./lib/snaptrade/models/action_strict_with_options.rb)<a id="action-actionstrictwithoptionslibsnaptrademodelsaction_strict_with_optionsrb"></a>
|
2050
2051
|
The action describes the intent or side of a trade. This is either `BUY` or
|
2051
2052
|
`SELL` for Equity symbols or `BUY_TO_OPEN`, `BUY_TO_CLOSE`, `SELL_TO_OPEN` or
|
2052
2053
|
`SELL_TO_CLOSE` for Options.
|
2053
2054
|
|
2054
|
-
#####
|
2055
|
-
The security's trading ticker symbol.
|
2056
|
-
|
2055
|
+
##### instrument: [`TradingInstrument`](./lib/snaptrade/models/trading_instrument.rb)<a id="instrument-tradinginstrumentlibsnaptrademodelstrading_instrumentrb"></a>
|
2057
2056
|
##### order_type: [`OrderTypeStrict`](./lib/snaptrade/models/order_type_strict.rb)<a id="order_type-ordertypestrictlibsnaptrademodelsorder_type_strictrb"></a>
|
2058
2057
|
The type of order to place. - For `Limit` and `StopLimit` orders, the `price`
|
2059
2058
|
field is required. - For `Stop` and `StopLimit` orders, the `stop` field is
|
@@ -2069,8 +2068,14 @@ immediately or be canceled completely.
|
|
2069
2068
|
|
2070
2069
|
##### stop_loss: [`StopLoss`](./lib/snaptrade/models/stop_loss.rb)<a id="stop_loss-stoplosslibsnaptrademodelsstop_lossrb"></a>
|
2071
2070
|
##### take_profit: [`TakeProfit`](./lib/snaptrade/models/take_profit.rb)<a id="take_profit-takeprofitlibsnaptrademodelstake_profitrb"></a>
|
2071
|
+
##### account_id: `String`<a id="account_id-string"></a>
|
2072
|
+
The ID of the account to execute the trade on.
|
2073
|
+
|
2072
2074
|
##### user_id: `String`<a id="user_id-string"></a>
|
2073
2075
|
##### user_secret: `String`<a id="user_secret-string"></a>
|
2076
|
+
##### symbol: `String`<a id="symbol-string"></a>
|
2077
|
+
The security's trading ticker symbol.
|
2078
|
+
|
2074
2079
|
##### price: `Float`<a id="price-float"></a>
|
2075
2080
|
The limit price for `Limit` and `StopLimit` orders.
|
2076
2081
|
|
@@ -2087,7 +2092,7 @@ Must be `null` if `notional_value` is provided.
|
|
2087
2092
|
|
2088
2093
|
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
2089
2094
|
|
2090
|
-
`/
|
2095
|
+
`/accounts/{accountId}/trading/bracket` `POST`
|
2091
2096
|
|
2092
2097
|
[🔙 **Back to Table of Contents**](#table-of-contents)
|
2093
2098
|
|
@@ -2233,6 +2238,78 @@ before responding to the request.
|
|
2233
2238
|
---
|
2234
2239
|
|
2235
2240
|
|
2241
|
+
### `snaptrade.trading.replace_order`<a id="snaptradetradingreplace_order"></a>
|
2242
|
+
|
2243
|
+
Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling
|
2244
|
+
the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one
|
2245
|
+
returned in the response going forward. Only supported on some brokerages
|
2246
|
+
|
2247
|
+
|
2248
|
+
#### 🛠️ Usage<a id="🛠️-usage"></a>
|
2249
|
+
|
2250
|
+
```ruby
|
2251
|
+
result = snaptrade.trading.replace_order(
|
2252
|
+
action: "BUY",
|
2253
|
+
order_type: "Market",
|
2254
|
+
time_in_force: "FOK",
|
2255
|
+
account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
|
2256
|
+
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
|
2257
|
+
user_id: "snaptrade-user-123",
|
2258
|
+
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
|
2259
|
+
price: 31.33,
|
2260
|
+
stop: 31.33,
|
2261
|
+
units: 10.5,
|
2262
|
+
)
|
2263
|
+
p result
|
2264
|
+
```
|
2265
|
+
|
2266
|
+
#### ⚙️ Parameters<a id="⚙️-parameters"></a>
|
2267
|
+
|
2268
|
+
##### action: [`ActionStrict`](./lib/snaptrade/models/action_strict.rb)<a id="action-actionstrictlibsnaptrademodelsaction_strictrb"></a>
|
2269
|
+
The action describes the intent or side of a trade. This is either `BUY` or
|
2270
|
+
`SELL`.
|
2271
|
+
|
2272
|
+
##### order_type: [`OrderTypeStrict`](./lib/snaptrade/models/order_type_strict.rb)<a id="order_type-ordertypestrictlibsnaptrademodelsorder_type_strictrb"></a>
|
2273
|
+
The type of order to place. - For `Limit` and `StopLimit` orders, the `price`
|
2274
|
+
field is required. - For `Stop` and `StopLimit` orders, the `stop` field is
|
2275
|
+
required.
|
2276
|
+
|
2277
|
+
##### time_in_force: [`TimeInForceStrict`](./lib/snaptrade/models/time_in_force_strict.rb)<a id="time_in_force-timeinforcestrictlibsnaptrademodelstime_in_force_strictrb"></a>
|
2278
|
+
The Time in Force type for the order. This field indicates how long the order
|
2279
|
+
will remain active before it is executed or expires. Here are the supported
|
2280
|
+
values: - `Day` - Day. The order is valid only for the trading day on which it
|
2281
|
+
is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed
|
2282
|
+
or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety
|
2283
|
+
immediately or be canceled completely.
|
2284
|
+
|
2285
|
+
##### account_id: `String`<a id="account_id-string"></a>
|
2286
|
+
The ID of the account to execute the trade on.
|
2287
|
+
|
2288
|
+
##### brokerage_order_id: `String`<a id="brokerage_order_id-string"></a>
|
2289
|
+
The Brokerage Order ID of the order to replace.
|
2290
|
+
|
2291
|
+
##### user_id: `String`<a id="user_id-string"></a>
|
2292
|
+
##### user_secret: `String`<a id="user_secret-string"></a>
|
2293
|
+
##### price: `Float`<a id="price-float"></a>
|
2294
|
+
The limit price for `Limit` and `StopLimit` orders.
|
2295
|
+
|
2296
|
+
##### stop: `Float`<a id="stop-float"></a>
|
2297
|
+
The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
2298
|
+
|
2299
|
+
##### units: [`Float`](./lib/snaptrade/models/float.rb)<a id="units-floatlibsnaptrademodelsfloatrb"></a>
|
2300
|
+
#### 🔄 Return<a id="🔄-return"></a>
|
2301
|
+
|
2302
|
+
[AccountOrderRecord](./lib/snaptrade/models/account_order_record.rb)
|
2303
|
+
|
2304
|
+
#### 🌐 Endpoint<a id="🌐-endpoint"></a>
|
2305
|
+
|
2306
|
+
`/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace` `PATCH`
|
2307
|
+
|
2308
|
+
[🔙 **Back to Table of Contents**](#table-of-contents)
|
2309
|
+
|
2310
|
+
---
|
2311
|
+
|
2312
|
+
|
2236
2313
|
### `snaptrade.transactions_and_reporting.get_activities`<a id="snaptradetransactions_and_reportingget_activities"></a>
|
2237
2314
|

|
2238
2315
|
|
@@ -413,25 +413,26 @@ module SnapTrade
|
|
413
413
|
# Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for
|
414
414
|
# use. Only supported on certain brokerages
|
415
415
|
#
|
416
|
-
# @param account_id [String] Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
417
416
|
# @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.
|
418
|
-
# @param
|
417
|
+
# @param instrument [TradingInstrument]
|
419
418
|
# @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.
|
420
419
|
# @param time_in_force [TimeInForceStrict] 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.
|
421
420
|
# @param stop_loss [StopLoss]
|
422
421
|
# @param take_profit [TakeProfit]
|
422
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
423
423
|
# @param user_id [String]
|
424
424
|
# @param user_secret [String]
|
425
|
+
# @param symbol [String] The security's trading ticker symbol.
|
425
426
|
# @param price [Float] The limit price for `Limit` and `StopLimit` orders.
|
426
427
|
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
427
428
|
# @param units [Float] Number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided.
|
428
429
|
# @param body [ManualTradeFormBracket]
|
429
430
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
430
|
-
def place_bracket_order(
|
431
|
+
def place_bracket_order(action:, instrument:, order_type:, time_in_force:, stop_loss:, take_profit:, account_id:, user_id:, user_secret:, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {})
|
431
432
|
_body = {}
|
432
|
-
_body[:account_id] = account_id if account_id != SENTINEL
|
433
433
|
_body[:action] = action if action != SENTINEL
|
434
434
|
_body[:symbol] = symbol if symbol != SENTINEL
|
435
|
+
_body[:instrument] = instrument if instrument != SENTINEL
|
435
436
|
_body[:order_type] = order_type if order_type != SENTINEL
|
436
437
|
_body[:time_in_force] = time_in_force if time_in_force != SENTINEL
|
437
438
|
_body[:price] = price if price != SENTINEL
|
@@ -440,7 +441,7 @@ module SnapTrade
|
|
440
441
|
_body[:stop_loss] = stop_loss if stop_loss != SENTINEL
|
441
442
|
_body[:take_profit] = take_profit if take_profit != SENTINEL
|
442
443
|
manual_trade_form_bracket = _body
|
443
|
-
data, _status_code, _headers = place_bracket_order_with_http_info_impl(user_id, user_secret, manual_trade_form_bracket, extra)
|
444
|
+
data, _status_code, _headers = place_bracket_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_bracket, extra)
|
444
445
|
data
|
445
446
|
end
|
446
447
|
|
@@ -449,25 +450,26 @@ module SnapTrade
|
|
449
450
|
# Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for
|
450
451
|
# use. Only supported on certain brokerages
|
451
452
|
#
|
452
|
-
# @param account_id [String] Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
453
453
|
# @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.
|
454
|
-
# @param
|
454
|
+
# @param instrument [TradingInstrument]
|
455
455
|
# @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.
|
456
456
|
# @param time_in_force [TimeInForceStrict] 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.
|
457
457
|
# @param stop_loss [StopLoss]
|
458
458
|
# @param take_profit [TakeProfit]
|
459
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
459
460
|
# @param user_id [String]
|
460
461
|
# @param user_secret [String]
|
462
|
+
# @param symbol [String] The security's trading ticker symbol.
|
461
463
|
# @param price [Float] The limit price for `Limit` and `StopLimit` orders.
|
462
464
|
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
463
465
|
# @param units [Float] Number of shares for the order. This can be a decimal for fractional orders. Must be `null` if `notional_value` is provided.
|
464
466
|
# @param body [ManualTradeFormBracket]
|
465
467
|
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
466
|
-
def place_bracket_order_with_http_info(
|
468
|
+
def place_bracket_order_with_http_info(action:, instrument:, order_type:, time_in_force:, stop_loss:, take_profit:, account_id:, user_id:, user_secret:, symbol: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {})
|
467
469
|
_body = {}
|
468
|
-
_body[:account_id] = account_id if account_id != SENTINEL
|
469
470
|
_body[:action] = action if action != SENTINEL
|
470
471
|
_body[:symbol] = symbol if symbol != SENTINEL
|
472
|
+
_body[:instrument] = instrument if instrument != SENTINEL
|
471
473
|
_body[:order_type] = order_type if order_type != SENTINEL
|
472
474
|
_body[:time_in_force] = time_in_force if time_in_force != SENTINEL
|
473
475
|
_body[:price] = price if price != SENTINEL
|
@@ -476,32 +478,38 @@ module SnapTrade
|
|
476
478
|
_body[:stop_loss] = stop_loss if stop_loss != SENTINEL
|
477
479
|
_body[:take_profit] = take_profit if take_profit != SENTINEL
|
478
480
|
manual_trade_form_bracket = _body
|
479
|
-
place_bracket_order_with_http_info_impl(user_id, user_secret, manual_trade_form_bracket, extra)
|
481
|
+
place_bracket_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_bracket, extra)
|
480
482
|
end
|
481
483
|
|
482
484
|
# Place a Bracket Order
|
483
485
|
# Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages
|
486
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
484
487
|
# @param user_id [String]
|
485
488
|
# @param user_secret [String]
|
486
489
|
# @param manual_trade_form_bracket [ManualTradeFormBracket]
|
487
490
|
# @param [Hash] opts the optional parameters
|
488
491
|
# @return [AccountOrderRecord]
|
489
|
-
private def place_bracket_order_impl(user_id, user_secret, manual_trade_form_bracket, opts = {})
|
490
|
-
data, _status_code, _headers = place_bracket_order_with_http_info(user_id, user_secret, manual_trade_form_bracket, opts)
|
492
|
+
private def place_bracket_order_impl(account_id, user_id, user_secret, manual_trade_form_bracket, opts = {})
|
493
|
+
data, _status_code, _headers = place_bracket_order_with_http_info(account_id, user_id, user_secret, manual_trade_form_bracket, opts)
|
491
494
|
data
|
492
495
|
end
|
493
496
|
|
494
497
|
# Place a Bracket Order
|
495
498
|
# Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages
|
499
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
496
500
|
# @param user_id [String]
|
497
501
|
# @param user_secret [String]
|
498
502
|
# @param manual_trade_form_bracket [ManualTradeFormBracket]
|
499
503
|
# @param [Hash] opts the optional parameters
|
500
504
|
# @return [Array<(AccountOrderRecord, Integer, Hash)>] AccountOrderRecord data, response status code and response headers
|
501
|
-
private def place_bracket_order_with_http_info_impl(user_id, user_secret, manual_trade_form_bracket, opts = {})
|
505
|
+
private def place_bracket_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_bracket, opts = {})
|
502
506
|
if @api_client.config.debugging
|
503
507
|
@api_client.config.logger.debug 'Calling API: TradingApi.place_bracket_order ...'
|
504
508
|
end
|
509
|
+
# verify the required parameter 'account_id' is set
|
510
|
+
if @api_client.config.client_side_validation && account_id.nil?
|
511
|
+
fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.place_bracket_order"
|
512
|
+
end
|
505
513
|
# verify the required parameter 'user_id' is set
|
506
514
|
if @api_client.config.client_side_validation && user_id.nil?
|
507
515
|
fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.place_bracket_order"
|
@@ -515,7 +523,7 @@ module SnapTrade
|
|
515
523
|
fail ArgumentError, "Missing the required parameter 'manual_trade_form_bracket' when calling TradingApi.place_bracket_order"
|
516
524
|
end
|
517
525
|
# resource path
|
518
|
-
local_var_path = '/
|
526
|
+
local_var_path = '/accounts/{accountId}/trading/bracket'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
|
519
527
|
|
520
528
|
# query parameters
|
521
529
|
query_params = opts[:query_params] || {}
|
@@ -844,6 +852,162 @@ module SnapTrade
|
|
844
852
|
end
|
845
853
|
return data, status_code, headers, response
|
846
854
|
end
|
855
|
+
|
856
|
+
|
857
|
+
# Replaces an order with a new one
|
858
|
+
#
|
859
|
+
# Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling
|
860
|
+
# the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one
|
861
|
+
# returned in the response going forward. Only supported on some brokerages
|
862
|
+
#
|
863
|
+
# @param action [ActionStrict] The action describes the intent or side of a trade. This is either `BUY` or `SELL`.
|
864
|
+
# @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.
|
865
|
+
# @param time_in_force [TimeInForceStrict] 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.
|
866
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
867
|
+
# @param brokerage_order_id [String] The Brokerage Order ID of the order to replace.
|
868
|
+
# @param user_id [String]
|
869
|
+
# @param user_secret [String]
|
870
|
+
# @param price [Float] The limit price for `Limit` and `StopLimit` orders.
|
871
|
+
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
872
|
+
# @param units [Float]
|
873
|
+
# @param body [ManualTradeReplaceForm]
|
874
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
875
|
+
def replace_order(action:, order_type:, time_in_force:, account_id:, brokerage_order_id:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {})
|
876
|
+
_body = {}
|
877
|
+
_body[:action] = action if action != SENTINEL
|
878
|
+
_body[:order_type] = order_type if order_type != SENTINEL
|
879
|
+
_body[:time_in_force] = time_in_force if time_in_force != SENTINEL
|
880
|
+
_body[:price] = price if price != SENTINEL
|
881
|
+
_body[:stop] = stop if stop != SENTINEL
|
882
|
+
_body[:units] = units if units != SENTINEL
|
883
|
+
manual_trade_replace_form = _body
|
884
|
+
data, _status_code, _headers = replace_order_with_http_info_impl(account_id, brokerage_order_id, user_id, user_secret, manual_trade_replace_form, extra)
|
885
|
+
data
|
886
|
+
end
|
887
|
+
|
888
|
+
# Replaces an order with a new one
|
889
|
+
#
|
890
|
+
# Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling
|
891
|
+
# the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one
|
892
|
+
# returned in the response going forward. Only supported on some brokerages
|
893
|
+
#
|
894
|
+
# @param action [ActionStrict] The action describes the intent or side of a trade. This is either `BUY` or `SELL`.
|
895
|
+
# @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.
|
896
|
+
# @param time_in_force [TimeInForceStrict] 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.
|
897
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
898
|
+
# @param brokerage_order_id [String] The Brokerage Order ID of the order to replace.
|
899
|
+
# @param user_id [String]
|
900
|
+
# @param user_secret [String]
|
901
|
+
# @param price [Float] The limit price for `Limit` and `StopLimit` orders.
|
902
|
+
# @param stop [Float] The price at which a stop order is triggered for `Stop` and `StopLimit` orders.
|
903
|
+
# @param units [Float]
|
904
|
+
# @param body [ManualTradeReplaceForm]
|
905
|
+
# @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
|
906
|
+
def replace_order_with_http_info(action:, order_type:, time_in_force:, account_id:, brokerage_order_id:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {})
|
907
|
+
_body = {}
|
908
|
+
_body[:action] = action if action != SENTINEL
|
909
|
+
_body[:order_type] = order_type if order_type != SENTINEL
|
910
|
+
_body[:time_in_force] = time_in_force if time_in_force != SENTINEL
|
911
|
+
_body[:price] = price if price != SENTINEL
|
912
|
+
_body[:stop] = stop if stop != SENTINEL
|
913
|
+
_body[:units] = units if units != SENTINEL
|
914
|
+
manual_trade_replace_form = _body
|
915
|
+
replace_order_with_http_info_impl(account_id, brokerage_order_id, user_id, user_secret, manual_trade_replace_form, extra)
|
916
|
+
end
|
917
|
+
|
918
|
+
# Replaces an order with a new one
|
919
|
+
# Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages
|
920
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
921
|
+
# @param brokerage_order_id [String] The Brokerage Order ID of the order to replace.
|
922
|
+
# @param user_id [String]
|
923
|
+
# @param user_secret [String]
|
924
|
+
# @param manual_trade_replace_form [ManualTradeReplaceForm]
|
925
|
+
# @param [Hash] opts the optional parameters
|
926
|
+
# @return [AccountOrderRecord]
|
927
|
+
private def replace_order_impl(account_id, brokerage_order_id, user_id, user_secret, manual_trade_replace_form, opts = {})
|
928
|
+
data, _status_code, _headers = replace_order_with_http_info(account_id, brokerage_order_id, user_id, user_secret, manual_trade_replace_form, opts)
|
929
|
+
data
|
930
|
+
end
|
931
|
+
|
932
|
+
# Replaces an order with a new one
|
933
|
+
# Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order's brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages
|
934
|
+
# @param account_id [String] The ID of the account to execute the trade on.
|
935
|
+
# @param brokerage_order_id [String] The Brokerage Order ID of the order to replace.
|
936
|
+
# @param user_id [String]
|
937
|
+
# @param user_secret [String]
|
938
|
+
# @param manual_trade_replace_form [ManualTradeReplaceForm]
|
939
|
+
# @param [Hash] opts the optional parameters
|
940
|
+
# @return [Array<(AccountOrderRecord, Integer, Hash)>] AccountOrderRecord data, response status code and response headers
|
941
|
+
private def replace_order_with_http_info_impl(account_id, brokerage_order_id, user_id, user_secret, manual_trade_replace_form, opts = {})
|
942
|
+
if @api_client.config.debugging
|
943
|
+
@api_client.config.logger.debug 'Calling API: TradingApi.replace_order ...'
|
944
|
+
end
|
945
|
+
# verify the required parameter 'account_id' is set
|
946
|
+
if @api_client.config.client_side_validation && account_id.nil?
|
947
|
+
fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.replace_order"
|
948
|
+
end
|
949
|
+
# verify the required parameter 'brokerage_order_id' is set
|
950
|
+
if @api_client.config.client_side_validation && brokerage_order_id.nil?
|
951
|
+
fail ArgumentError, "Missing the required parameter 'brokerage_order_id' when calling TradingApi.replace_order"
|
952
|
+
end
|
953
|
+
# verify the required parameter 'user_id' is set
|
954
|
+
if @api_client.config.client_side_validation && user_id.nil?
|
955
|
+
fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.replace_order"
|
956
|
+
end
|
957
|
+
# verify the required parameter 'user_secret' is set
|
958
|
+
if @api_client.config.client_side_validation && user_secret.nil?
|
959
|
+
fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.replace_order"
|
960
|
+
end
|
961
|
+
# verify the required parameter 'manual_trade_replace_form' is set
|
962
|
+
if @api_client.config.client_side_validation && manual_trade_replace_form.nil?
|
963
|
+
fail ArgumentError, "Missing the required parameter 'manual_trade_replace_form' when calling TradingApi.replace_order"
|
964
|
+
end
|
965
|
+
# resource path
|
966
|
+
local_var_path = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/replace'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'brokerageOrderId' + '}', CGI.escape(brokerage_order_id.to_s))
|
967
|
+
|
968
|
+
# query parameters
|
969
|
+
query_params = opts[:query_params] || {}
|
970
|
+
query_params[:'userId'] = user_id
|
971
|
+
query_params[:'userSecret'] = user_secret
|
972
|
+
|
973
|
+
# header parameters
|
974
|
+
header_params = opts[:header_params] || {}
|
975
|
+
# HTTP header 'Accept' (if needed)
|
976
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
977
|
+
# HTTP header 'Content-Type'
|
978
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
979
|
+
if !content_type.nil?
|
980
|
+
header_params['Content-Type'] = content_type
|
981
|
+
end
|
982
|
+
|
983
|
+
# form parameters
|
984
|
+
form_params = opts[:form_params] || {}
|
985
|
+
|
986
|
+
# http body (model)
|
987
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(manual_trade_replace_form)
|
988
|
+
|
989
|
+
# return_type
|
990
|
+
return_type = opts[:debug_return_type] || 'AccountOrderRecord'
|
991
|
+
|
992
|
+
# auth_names
|
993
|
+
auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
|
994
|
+
|
995
|
+
new_options = opts.merge(
|
996
|
+
:operation => :"TradingApi.replace_order",
|
997
|
+
:header_params => header_params,
|
998
|
+
:query_params => query_params,
|
999
|
+
:form_params => form_params,
|
1000
|
+
:body => post_body,
|
1001
|
+
:auth_names => auth_names,
|
1002
|
+
:return_type => return_type
|
1003
|
+
)
|
1004
|
+
|
1005
|
+
data, status_code, headers, response = @api_client.call_api(:PATCH, local_var_path, new_options)
|
1006
|
+
if @api_client.config.debugging
|
1007
|
+
@api_client.config.logger.debug "API called: TradingApi#replace_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
1008
|
+
end
|
1009
|
+
return data, status_code, headers, response
|
1010
|
+
end
|
847
1011
|
end
|
848
1012
|
|
849
1013
|
# top-level client access to avoid having the user to insantiate their own API instances
|
@@ -13,15 +13,14 @@ require 'time'
|
|
13
13
|
module SnapTrade
|
14
14
|
# Inputs for placing an order with the brokerage.
|
15
15
|
class ManualTradeFormBracket
|
16
|
-
# Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.
|
17
|
-
attr_accessor :account_id
|
18
|
-
|
19
16
|
# 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.
|
20
17
|
attr_accessor :action
|
21
18
|
|
22
19
|
# The security's trading ticker symbol.
|
23
20
|
attr_accessor :symbol
|
24
21
|
|
22
|
+
attr_accessor :instrument
|
23
|
+
|
25
24
|
# 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.
|
26
25
|
attr_accessor :order_type
|
27
26
|
|
@@ -44,9 +43,9 @@ module SnapTrade
|
|
44
43
|
# Attribute mapping from ruby-style variable name to JSON key.
|
45
44
|
def self.attribute_map
|
46
45
|
{
|
47
|
-
:'account_id' => :'account_id',
|
48
46
|
:'action' => :'action',
|
49
47
|
:'symbol' => :'symbol',
|
48
|
+
:'instrument' => :'instrument',
|
50
49
|
:'order_type' => :'order_type',
|
51
50
|
:'time_in_force' => :'time_in_force',
|
52
51
|
:'price' => :'price',
|
@@ -65,9 +64,9 @@ module SnapTrade
|
|
65
64
|
# Attribute type mapping.
|
66
65
|
def self.openapi_types
|
67
66
|
{
|
68
|
-
:'account_id' => :'String',
|
69
67
|
:'action' => :'ActionStrictWithOptions',
|
70
68
|
:'symbol' => :'String',
|
69
|
+
:'instrument' => :'TradingInstrument',
|
71
70
|
:'order_type' => :'OrderTypeStrict',
|
72
71
|
:'time_in_force' => :'TimeInForceStrict',
|
73
72
|
:'price' => :'Float',
|
@@ -101,10 +100,6 @@ module SnapTrade
|
|
101
100
|
h[k.to_sym] = v
|
102
101
|
}
|
103
102
|
|
104
|
-
if attributes.key?(:'account_id')
|
105
|
-
self.account_id = attributes[:'account_id']
|
106
|
-
end
|
107
|
-
|
108
103
|
if attributes.key?(:'action')
|
109
104
|
self.action = attributes[:'action']
|
110
105
|
end
|
@@ -113,6 +108,10 @@ module SnapTrade
|
|
113
108
|
self.symbol = attributes[:'symbol']
|
114
109
|
end
|
115
110
|
|
111
|
+
if attributes.key?(:'instrument')
|
112
|
+
self.instrument = attributes[:'instrument']
|
113
|
+
end
|
114
|
+
|
116
115
|
if attributes.key?(:'order_type')
|
117
116
|
self.order_type = attributes[:'order_type']
|
118
117
|
end
|
@@ -146,16 +145,12 @@ module SnapTrade
|
|
146
145
|
# @return Array for valid properties with the reasons
|
147
146
|
def list_invalid_properties
|
148
147
|
invalid_properties = Array.new
|
149
|
-
if @account_id.nil?
|
150
|
-
invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
|
151
|
-
end
|
152
|
-
|
153
148
|
if @action.nil?
|
154
149
|
invalid_properties.push('invalid value for "action", action cannot be nil.')
|
155
150
|
end
|
156
151
|
|
157
|
-
if @
|
158
|
-
invalid_properties.push('invalid value for "
|
152
|
+
if @instrument.nil?
|
153
|
+
invalid_properties.push('invalid value for "instrument", instrument cannot be nil.')
|
159
154
|
end
|
160
155
|
|
161
156
|
if @order_type.nil?
|
@@ -180,9 +175,8 @@ module SnapTrade
|
|
180
175
|
# Check to see if the all the properties in the model are valid
|
181
176
|
# @return true if the model is valid
|
182
177
|
def valid?
|
183
|
-
return false if @account_id.nil?
|
184
178
|
return false if @action.nil?
|
185
|
-
return false if @
|
179
|
+
return false if @instrument.nil?
|
186
180
|
return false if @order_type.nil?
|
187
181
|
return false if @time_in_force.nil?
|
188
182
|
return false if @stop_loss.nil?
|
@@ -195,9 +189,9 @@ module SnapTrade
|
|
195
189
|
def ==(o)
|
196
190
|
return true if self.equal?(o)
|
197
191
|
self.class == o.class &&
|
198
|
-
account_id == o.account_id &&
|
199
192
|
action == o.action &&
|
200
193
|
symbol == o.symbol &&
|
194
|
+
instrument == o.instrument &&
|
201
195
|
order_type == o.order_type &&
|
202
196
|
time_in_force == o.time_in_force &&
|
203
197
|
price == o.price &&
|
@@ -216,7 +210,7 @@ module SnapTrade
|
|
216
210
|
# Calculates hash code according to all attributes.
|
217
211
|
# @return [Integer] Hash code
|
218
212
|
def hash
|
219
|
-
[
|
213
|
+
[action, symbol, instrument, order_type, time_in_force, price, stop, units, stop_loss, take_profit].hash
|
220
214
|
end
|
221
215
|
|
222
216
|
# Builds the object from hash
|