snaptrade 2.0.183 → 2.0.185

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6044ea642fe201ec74afdaae8b90e08138098c8b826812434bbcf63641b3c8e
4
- data.tar.gz: 52abfeed0137df479dfcdab2f83d010a7cc149e9ef439a6043feec2d6be4c124
3
+ metadata.gz: c6e6686611e26579a7f5b299263c6f9473fc12564d388730380a0b14f992d01e
4
+ data.tar.gz: 72ccb9a03f1230f0de97978d4d09c549ee38c45b120990ecb3df75ed6874da93
5
5
  SHA512:
6
- metadata.gz: '0973d9fecbc6ca4cb1ebec7767ba3be33bbc502470f136624755455a6e2f78a1034fadcefbbe61d97b2b6ce20833ce688b427fe6a1ce31e384809ef05d5e3c65'
7
- data.tar.gz: d6caf7f0481d8a5c21e7d68232d535d3dc5dc5bc37237b6c7d09b0b1a11dc4c78146de07247d78d543d88818c74943a86b53e91fe2de4ab3f7eb959f347fc748
6
+ metadata.gz: cd9ec841ef44d08d5e4d2315937a3cd13dd99c49a7da6ee2a470e6151f684c20d78c47f21e79083f270c3e8b95ce17a9d076b97074a8055780f9085b195681ea
7
+ data.tar.gz: a8fb0e2f6ef2feb2369036a668643fcc0c11a208bbd604649e2687ced70a4a3db0e67f92f4ed5412246f46fa08dd95ca01fa52406a3bc8fe5f4ac7b8859b9d7f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- snaptrade (2.0.183)
4
+ snaptrade (2.0.185)
5
5
  faraday (>= 1.0.1, < 3.0)
6
6
  faraday-multipart (~> 1.0, >= 1.0.4)
7
7
 
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
- [![npm](https://img.shields.io/badge/gem-v2.0.183-blue)](https://rubygems.org/gems/snaptrade/versions/2.0.183)
9
+ [![npm](https://img.shields.io/badge/gem-v2.0.185-blue)](https://rubygems.org/gems/snaptrade/versions/2.0.185)
10
10
  [![More Info](https://img.shields.io/badge/More%20Info-Click%20Here-orange)](https://snaptrade.com/)
11
11
 
12
12
  </div>
@@ -71,6 +71,7 @@ Connect brokerage accounts to your app for live positions and trading
71
71
  * [`snaptrade.trading.get_user_account_option_quotes`](#snaptradetradingget_user_account_option_quotes)
72
72
  * [`snaptrade.trading.get_user_account_quotes`](#snaptradetradingget_user_account_quotes)
73
73
  * [`snaptrade.trading.place_bracket_order`](#snaptradetradingplace_bracket_order)
74
+ * [`snaptrade.trading.place_complex_order`](#snaptradetradingplace_complex_order)
74
75
  * [`snaptrade.trading.place_crypto_order`](#snaptradetradingplace_crypto_order)
75
76
  * [`snaptrade.trading.place_force_order`](#snaptradetradingplace_force_order)
76
77
  * [`snaptrade.trading.place_mleg_order`](#snaptradetradingplace_mleg_order)
@@ -88,7 +89,7 @@ Connect brokerage accounts to your app for live positions and trading
88
89
  Add to Gemfile:
89
90
 
90
91
  ```ruby
91
- gem 'snaptrade', '~> 2.0.183'
92
+ gem 'snaptrade', '~> 2.0.185'
92
93
  ```
93
94
 
94
95
  ## Getting Started<a id="getting-started"></a>
@@ -2205,6 +2206,79 @@ Must be `null` if `notional_value` is provided.
2205
2206
  ---
2206
2207
 
2207
2208
 
2209
+ ### `snaptrade.trading.place_complex_order`<a id="snaptradetradingplace_complex_order"></a>
2210
+
2211
+ Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable.
2212
+ Only supported on certain brokerages.
2213
+
2214
+ - **OCO** (One Cancels the Other): Two peer orders; when one fills the other is cancelled.
2215
+ - **OTO** (One Triggers the Other): A trigger order that, when filled, activates a conditional order.
2216
+ - **OTOCO** (One Triggers a One Cancels the Other): A trigger order that, when filled, activates an OCO pair of two peer orders.
2217
+
2218
+
2219
+ #### 🛠️ Usage<a id="🛠️-usage"></a>
2220
+
2221
+ ```ruby
2222
+ result = snaptrade.trading.place_complex_order(
2223
+ type: "OTO",
2224
+ orders: [
2225
+ {
2226
+ "order_role" => "TRIGGER",
2227
+ "action" => "BUY",
2228
+ "instrument" => {
2229
+ "symbol" => "AAPL",
2230
+ "type" => "EQUITY",
2231
+ },
2232
+ "order_type" => "Market",
2233
+ "units" => 10.5,
2234
+ "time_in_force" => "Day",
2235
+ "price" => 31.33,
2236
+ "stop" => 29.5,
2237
+ }
2238
+ ],
2239
+ account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
2240
+ user_id: "snaptrade-user-123",
2241
+ user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
2242
+ client_order_id: "my-order-123",
2243
+ )
2244
+ p result
2245
+ ```
2246
+
2247
+ #### ⚙️ Parameters<a id="⚙️-parameters"></a>
2248
+
2249
+ ##### type: [`ManualTradeFormComplexType`](./lib/snaptrade/models/manual_trade_form_complex_type.rb)<a id="type-manualtradeformcomplextypelibsnaptrademodelsmanual_trade_form_complex_typerb"></a>
2250
+ The complex order type. - `OCO`: One Cancels the Other — two peer orders. -
2251
+ `OTO`: One Triggers the Other — a trigger order and a conditional order. -
2252
+ `OTOCO`: One Triggers a One Cancels the Other — a trigger order and two peer
2253
+ orders.
2254
+
2255
+ ##### orders: Array<[`ComplexOrderLeg`](./lib/snaptrade/models/complex_order_leg.rb)><a id="orders-array"></a>
2256
+ The orders that make up the complex order. Required counts and roles per type: -
2257
+ `OCO`: exactly 2 orders, both `PEER` - `OTO`: exactly 2 orders, one `TRIGGER`
2258
+ and one `CONDITIONAL` - `OTOCO`: exactly 3 orders, one `TRIGGER` and two `PEER`
2259
+
2260
+ ##### account_id: `String`<a id="account_id-string"></a>
2261
+ The ID of the account to execute the trade on.
2262
+
2263
+ ##### user_id: `String`<a id="user_id-string"></a>
2264
+ ##### user_secret: `String`<a id="user_secret-string"></a>
2265
+ ##### client_order_id: `String`<a id="client_order_id-string"></a>
2266
+ An optional client-provided identifier for this complex order. Passed through to
2267
+ the brokerage and returned in the response.
2268
+
2269
+ #### 🔄 Return<a id="🔄-return"></a>
2270
+
2271
+ [ComplexOrderResponse](./lib/snaptrade/models/complex_order_response.rb)
2272
+
2273
+ #### 🌐 Endpoint<a id="🌐-endpoint"></a>
2274
+
2275
+ `/accounts/{accountId}/trading/complex` `POST`
2276
+
2277
+ [🔙 **Back to Table of Contents**](#table-of-contents)
2278
+
2279
+ ---
2280
+
2281
+
2208
2282
  ### `snaptrade.trading.place_crypto_order`<a id="snaptradetradingplace_crypto_order"></a>
2209
2283
 
2210
2284
  Places an order in the specified account.
@@ -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.
@@ -50,6 +50,9 @@ module SnapTrade
50
50
  # The account type as provided by the brokerage
51
51
  attr_accessor :raw_type
52
52
 
53
+ # The category of the account, normalized across institutions. Returns `null` if the category could not be determined. Use this field to filter out non-investment accounts if your integration only supports trading / holdings flows. See [Filtering Accounts by Category](https://docs.snaptrade.com/docs/filtering-accounts-by-category) for more information. - `INVESTMENT`: A brokerage / investment account (equities, options, crypto, etc.). - `DEPOSIT`: A bank deposit account (checking, savings). - `LOC`: A line of credit account.
54
+ attr_accessor :account_category
55
+
53
56
  # Additional information about the account, such as account type, status, etc. This information is specific to the brokerage and there's no standard format for this data. This field is deprecated and subject to removal in a future version.
54
57
  attr_accessor :meta
55
58
 
@@ -78,6 +81,7 @@ module SnapTrade
78
81
  :'balance' => :'balance',
79
82
  :'status' => :'status',
80
83
  :'raw_type' => :'raw_type',
84
+ :'account_category' => :'account_category',
81
85
  :'meta' => :'meta',
82
86
  :'portfolio_group' => :'portfolio_group',
83
87
  :'cash_restrictions' => :'cash_restrictions',
@@ -106,6 +110,7 @@ module SnapTrade
106
110
  :'balance' => :'AccountBalance',
107
111
  :'status' => :'AccountStatus',
108
112
  :'raw_type' => :'String',
113
+ :'account_category' => :'AccountCategory',
109
114
  :'meta' => :'Hash<String, Object>',
110
115
  :'portfolio_group' => :'String',
111
116
  :'cash_restrictions' => :'Array<String>',
@@ -122,6 +127,7 @@ module SnapTrade
122
127
  :'opening_date',
123
128
  :'status',
124
129
  :'raw_type',
130
+ :'account_category',
125
131
  ])
126
132
  end
127
133
 
@@ -192,6 +198,10 @@ module SnapTrade
192
198
  self.raw_type = attributes[:'raw_type']
193
199
  end
194
200
 
201
+ if attributes.key?(:'account_category')
202
+ self.account_category = attributes[:'account_category']
203
+ end
204
+
195
205
  if attributes.key?(:'meta')
196
206
  if (value = attributes[:'meta']).is_a?(Hash)
197
207
  self.meta = value
@@ -284,6 +294,7 @@ module SnapTrade
284
294
  balance == o.balance &&
285
295
  status == o.status &&
286
296
  raw_type == o.raw_type &&
297
+ account_category == o.account_category &&
287
298
  meta == o.meta &&
288
299
  portfolio_group == o.portfolio_group &&
289
300
  cash_restrictions == o.cash_restrictions &&
@@ -299,7 +310,7 @@ module SnapTrade
299
310
  # Calculates hash code according to all attributes.
300
311
  # @return [Integer] Hash code
301
312
  def hash
302
- [id, brokerage_authorization, name, number, institution_account_id, institution_name, created_date, funding_date, opening_date, sync_status, balance, status, raw_type, meta, portfolio_group, cash_restrictions, is_paper].hash
313
+ [id, brokerage_authorization, name, number, institution_account_id, institution_name, created_date, funding_date, opening_date, sync_status, balance, status, raw_type, account_category, meta, portfolio_group, cash_restrictions, is_paper].hash
303
314
  end
304
315
 
305
316
  # Builds the object from hash
@@ -0,0 +1,38 @@
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
+ class AccountCategory
15
+ INVESTMENT = "INVESTMENT".freeze
16
+ DEPOSIT = "DEPOSIT".freeze
17
+ LOC = "LOC".freeze
18
+
19
+ def self.all_vars
20
+ @all_vars ||= [INVESTMENT, DEPOSIT, LOC].freeze
21
+ end
22
+
23
+ # Builds the enum from string
24
+ # @param [String] The enum value in the form of the string
25
+ # @return [String] The enum value
26
+ def self.build_from_hash(value)
27
+ new.build_from_hash(value)
28
+ end
29
+
30
+ # Builds the enum from string
31
+ # @param [String] The enum value in the form of the string
32
+ # @return [String] The enum value
33
+ def build_from_hash(value)
34
+ return value if AccountCategory.all_vars.include?(value)
35
+ raise "Invalid ENUM value #{value} for class #AccountCategory"
36
+ end
37
+ end
38
+ end