snaptrade 2.0.87 → 2.0.88

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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +280 -285
  4. data/lib/snaptrade/api/trading_api.rb +653 -0
  5. data/lib/snaptrade/models/cryptocurrency_pair.rb +12 -2
  6. data/lib/snaptrade/models/{crypto_spot_quote.rb → cryptocurrency_pair_quote.rb} +3 -3
  7. data/lib/snaptrade/models/{crypto_spot_order_preview.rb → simple_order_preview.rb} +5 -5
  8. data/lib/snaptrade/models/{crypto_spot_order_preview_estimated_fee.rb → simple_order_preview_estimated_fee.rb} +3 -3
  9. data/lib/snaptrade/models/{crypto_spot_order_request_body_time_in_force.rb → simple_order_request_body_time_in_force.rb} +3 -3
  10. data/lib/snaptrade/models/{trading_crypto_spot_place_order_request.rb → trading_place_simple_order_request.rb} +14 -14
  11. data/lib/snaptrade/models/{trading_crypto_spot_symbols200_response.rb → trading_search_cryptocurrency_pair_instruments200_response.rb} +3 -3
  12. data/lib/snaptrade/version.rb +1 -1
  13. data/lib/snaptrade.rb +6 -10
  14. data/spec/api/trading_api_spec.rb +76 -0
  15. data/spec/models/{crypto_spot_quote_spec.rb → cryptocurrency_pair_quote_spec.rb} +6 -6
  16. data/spec/models/cryptocurrency_pair_spec.rb +6 -0
  17. data/spec/models/{crypto_spot_order_preview_estimated_fee_spec.rb → simple_order_preview_estimated_fee_spec.rb} +6 -6
  18. data/spec/models/{crypto_spot_order_preview_spec.rb → simple_order_preview_spec.rb} +6 -6
  19. data/spec/models/simple_order_request_body_time_in_force_spec.rb +23 -0
  20. data/spec/models/{trading_crypto_spot_place_order_request_spec.rb → trading_place_simple_order_request_spec.rb} +7 -7
  21. data/spec/models/trading_search_cryptocurrency_pair_instruments200_response_spec.rb +29 -0
  22. metadata +20 -26
  23. data/lib/snaptrade/api/crypto_spot_trading_api.rb +0 -698
  24. data/lib/snaptrade/models/trading_crypto_spot_cancel_order_request.rb +0 -222
  25. data/spec/api/crypto_spot_trading_api_spec.rb +0 -107
  26. data/spec/models/crypto_spot_order_request_body_time_in_force_spec.rb +0 -23
  27. data/spec/models/trading_crypto_spot_cancel_order_request_spec.rb +0 -29
  28. data/spec/models/trading_crypto_spot_symbols200_response_spec.rb +0 -29
@@ -17,6 +17,117 @@ module SnapTrade
17
17
  @api_client = api_client
18
18
  end
19
19
 
20
+ # Cancel an order.
21
+ #
22
+ # Cancels an order in the specified account.
23
+ #
24
+ # @param user_id [String]
25
+ # @param user_secret [String]
26
+ # @param account_id [String]
27
+ # @param brokerage_order_id [String]
28
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
29
+ def cancel_order(user_id:, user_secret:, account_id:, brokerage_order_id:, extra: {})
30
+ data, _status_code, _headers = cancel_order_with_http_info_impl(user_id, user_secret, account_id, brokerage_order_id, extra)
31
+ data
32
+ end
33
+
34
+ # Cancel an order.
35
+ #
36
+ # Cancels an order in the specified account.
37
+ #
38
+ # @param user_id [String]
39
+ # @param user_secret [String]
40
+ # @param account_id [String]
41
+ # @param brokerage_order_id [String]
42
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
43
+ def cancel_order_with_http_info(user_id:, user_secret:, account_id:, brokerage_order_id:, extra: {})
44
+ cancel_order_with_http_info_impl(user_id, user_secret, account_id, brokerage_order_id, extra)
45
+ end
46
+
47
+ # Cancel an order.
48
+ # Cancels an order in the specified account.
49
+ # @param user_id [String]
50
+ # @param user_secret [String]
51
+ # @param account_id [String]
52
+ # @param brokerage_order_id [String]
53
+ # @param [Hash] opts the optional parameters
54
+ # @return [OrderUpdatedResponse]
55
+ private def cancel_order_impl(user_id, user_secret, account_id, brokerage_order_id, opts = {})
56
+ data, _status_code, _headers = cancel_order_with_http_info(user_id, user_secret, account_id, brokerage_order_id, opts)
57
+ data
58
+ end
59
+
60
+ # Cancel an order.
61
+ # Cancels an order in the specified account.
62
+ # @param user_id [String]
63
+ # @param user_secret [String]
64
+ # @param account_id [String]
65
+ # @param brokerage_order_id [String]
66
+ # @param [Hash] opts the optional parameters
67
+ # @return [Array<(OrderUpdatedResponse, Integer, Hash)>] OrderUpdatedResponse data, response status code and response headers
68
+ private def cancel_order_with_http_info_impl(user_id, user_secret, account_id, brokerage_order_id, opts = {})
69
+ if @api_client.config.debugging
70
+ @api_client.config.logger.debug 'Calling API: TradingApi.cancel_order ...'
71
+ end
72
+ # verify the required parameter 'user_id' is set
73
+ if @api_client.config.client_side_validation && user_id.nil?
74
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.cancel_order"
75
+ end
76
+ # verify the required parameter 'user_secret' is set
77
+ if @api_client.config.client_side_validation && user_secret.nil?
78
+ fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.cancel_order"
79
+ end
80
+ # verify the required parameter 'account_id' is set
81
+ if @api_client.config.client_side_validation && account_id.nil?
82
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.cancel_order"
83
+ end
84
+ # verify the required parameter 'brokerage_order_id' is set
85
+ if @api_client.config.client_side_validation && brokerage_order_id.nil?
86
+ fail ArgumentError, "Missing the required parameter 'brokerage_order_id' when calling TradingApi.cancel_order"
87
+ end
88
+ # resource path
89
+ local_var_path = '/accounts/{accountId}/trading/simple/{brokerageOrderId}/cancel'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'brokerageOrderId' + '}', CGI.escape(brokerage_order_id.to_s))
90
+
91
+ # query parameters
92
+ query_params = opts[:query_params] || {}
93
+ query_params[:'userId'] = user_id
94
+ query_params[:'userSecret'] = user_secret
95
+
96
+ # header parameters
97
+ header_params = opts[:header_params] || {}
98
+ # HTTP header 'Accept' (if needed)
99
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
100
+
101
+ # form parameters
102
+ form_params = opts[:form_params] || {}
103
+
104
+ # http body (model)
105
+ post_body = opts[:debug_body]
106
+
107
+ # return_type
108
+ return_type = opts[:debug_return_type] || 'OrderUpdatedResponse'
109
+
110
+ # auth_names
111
+ auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
112
+
113
+ new_options = opts.merge(
114
+ :operation => :"TradingApi.cancel_order",
115
+ :header_params => header_params,
116
+ :query_params => query_params,
117
+ :form_params => form_params,
118
+ :body => post_body,
119
+ :auth_names => auth_names,
120
+ :return_type => return_type
121
+ )
122
+
123
+ data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
124
+ if @api_client.config.debugging
125
+ @api_client.config.logger.debug "API called: TradingApi#cancel_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
126
+ end
127
+ return data, status_code, headers, response
128
+ end
129
+
130
+
20
131
  # Cancel order
21
132
  #
22
133
  # Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected.
@@ -141,6 +252,117 @@ module SnapTrade
141
252
  end
142
253
 
143
254
 
255
+ # Get cryptocurrency pair quote
256
+ #
257
+ # Gets a quote for the specified account.
258
+ #
259
+ # @param user_id [String]
260
+ # @param user_secret [String]
261
+ # @param account_id [String]
262
+ # @param instrument_symbol [String]
263
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
264
+ def get_cryptocurrency_pair_quote(user_id:, user_secret:, account_id:, instrument_symbol:, extra: {})
265
+ data, _status_code, _headers = get_cryptocurrency_pair_quote_with_http_info_impl(user_id, user_secret, account_id, instrument_symbol, extra)
266
+ data
267
+ end
268
+
269
+ # Get cryptocurrency pair quote
270
+ #
271
+ # Gets a quote for the specified account.
272
+ #
273
+ # @param user_id [String]
274
+ # @param user_secret [String]
275
+ # @param account_id [String]
276
+ # @param instrument_symbol [String]
277
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
278
+ def get_cryptocurrency_pair_quote_with_http_info(user_id:, user_secret:, account_id:, instrument_symbol:, extra: {})
279
+ get_cryptocurrency_pair_quote_with_http_info_impl(user_id, user_secret, account_id, instrument_symbol, extra)
280
+ end
281
+
282
+ # Get cryptocurrency pair quote
283
+ # Gets a quote for the specified account.
284
+ # @param user_id [String]
285
+ # @param user_secret [String]
286
+ # @param account_id [String]
287
+ # @param instrument_symbol [String]
288
+ # @param [Hash] opts the optional parameters
289
+ # @return [CryptocurrencyPairQuote]
290
+ private def get_cryptocurrency_pair_quote_impl(user_id, user_secret, account_id, instrument_symbol, opts = {})
291
+ data, _status_code, _headers = get_cryptocurrency_pair_quote_with_http_info(user_id, user_secret, account_id, instrument_symbol, opts)
292
+ data
293
+ end
294
+
295
+ # Get cryptocurrency pair quote
296
+ # Gets a quote for the specified account.
297
+ # @param user_id [String]
298
+ # @param user_secret [String]
299
+ # @param account_id [String]
300
+ # @param instrument_symbol [String]
301
+ # @param [Hash] opts the optional parameters
302
+ # @return [Array<(CryptocurrencyPairQuote, Integer, Hash)>] CryptocurrencyPairQuote data, response status code and response headers
303
+ private def get_cryptocurrency_pair_quote_with_http_info_impl(user_id, user_secret, account_id, instrument_symbol, opts = {})
304
+ if @api_client.config.debugging
305
+ @api_client.config.logger.debug 'Calling API: TradingApi.get_cryptocurrency_pair_quote ...'
306
+ end
307
+ # verify the required parameter 'user_id' is set
308
+ if @api_client.config.client_side_validation && user_id.nil?
309
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.get_cryptocurrency_pair_quote"
310
+ end
311
+ # verify the required parameter 'user_secret' is set
312
+ if @api_client.config.client_side_validation && user_secret.nil?
313
+ fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.get_cryptocurrency_pair_quote"
314
+ end
315
+ # verify the required parameter 'account_id' is set
316
+ if @api_client.config.client_side_validation && account_id.nil?
317
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.get_cryptocurrency_pair_quote"
318
+ end
319
+ # verify the required parameter 'instrument_symbol' is set
320
+ if @api_client.config.client_side_validation && instrument_symbol.nil?
321
+ fail ArgumentError, "Missing the required parameter 'instrument_symbol' when calling TradingApi.get_cryptocurrency_pair_quote"
322
+ end
323
+ # resource path
324
+ local_var_path = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs/{instrumentSymbol}/quote'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'instrumentSymbol' + '}', CGI.escape(instrument_symbol.to_s))
325
+
326
+ # query parameters
327
+ query_params = opts[:query_params] || {}
328
+ query_params[:'userId'] = user_id
329
+ query_params[:'userSecret'] = user_secret
330
+
331
+ # header parameters
332
+ header_params = opts[:header_params] || {}
333
+ # HTTP header 'Accept' (if needed)
334
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
335
+
336
+ # form parameters
337
+ form_params = opts[:form_params] || {}
338
+
339
+ # http body (model)
340
+ post_body = opts[:debug_body]
341
+
342
+ # return_type
343
+ return_type = opts[:debug_return_type] || 'CryptocurrencyPairQuote'
344
+
345
+ # auth_names
346
+ auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
347
+
348
+ new_options = opts.merge(
349
+ :operation => :"TradingApi.get_cryptocurrency_pair_quote",
350
+ :header_params => header_params,
351
+ :query_params => query_params,
352
+ :form_params => form_params,
353
+ :body => post_body,
354
+ :auth_names => auth_names,
355
+ :return_type => return_type
356
+ )
357
+
358
+ data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
359
+ if @api_client.config.debugging
360
+ @api_client.config.logger.debug "API called: TradingApi#get_cryptocurrency_pair_quote\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
361
+ end
362
+ return data, status_code, headers, response
363
+ end
364
+
365
+
144
366
  # Check order impact
145
367
  #
146
368
  # Simulates an order and its impact on the account. This endpoint does not place the order with the brokerage. If successful, it returns a `Trade` object and the ID of the object can be used to place the order with the brokerage using the [place checked order endpoint](/reference/Trading/Trading_placeOrder). Please note that the `Trade` object returned expires after 5 minutes. Any order placed using an expired `Trade` will be rejected.
@@ -854,6 +1076,320 @@ module SnapTrade
854
1076
  end
855
1077
 
856
1078
 
1079
+ # Place order
1080
+ #
1081
+ # Places an order in the specified account.
1082
+ # This endpoint does not compute the impact to the account balance from the order before submitting the order.
1083
+ #
1084
+ # @param instrument [TradingInstrument]
1085
+ # @param side [ActionStrict] The action describes the intent or side of a trade. This is either `BUY` or `SELL`.
1086
+ # @param type [Type] The type of order to place.
1087
+ # @param time_in_force [SimpleOrderRequestBodyTimeInForce] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `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 the specified date.
1088
+ # @param amount [Float] The amount of the base currency to buy or sell.
1089
+ # @param user_id [String]
1090
+ # @param user_secret [String]
1091
+ # @param account_id [String]
1092
+ # @param limit_price [Float] The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.
1093
+ # @param stop_price [Float] The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.
1094
+ # @param post_only [Boolean] Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
1095
+ # @param expiration_date [Time] The expiration date of the order. Required if the time_in_force is GTD.
1096
+ # @param body [TradingPlaceSimpleOrderRequest]
1097
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
1098
+ def place_simple_order(instrument:, side:, type:, time_in_force:, amount:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, post_only: SENTINEL, expiration_date: SENTINEL, extra: {})
1099
+ _body = {}
1100
+ _body[:instrument] = instrument if instrument != SENTINEL
1101
+ _body[:side] = side if side != SENTINEL
1102
+ _body[:type] = type if type != SENTINEL
1103
+ _body[:time_in_force] = time_in_force if time_in_force != SENTINEL
1104
+ _body[:amount] = amount if amount != SENTINEL
1105
+ _body[:limit_price] = limit_price if limit_price != SENTINEL
1106
+ _body[:stop_price] = stop_price if stop_price != SENTINEL
1107
+ _body[:post_only] = post_only if post_only != SENTINEL
1108
+ _body[:expiration_date] = expiration_date if expiration_date != SENTINEL
1109
+ trading_place_simple_order_request = _body
1110
+ data, _status_code, _headers = place_simple_order_with_http_info_impl(user_id, user_secret, account_id, trading_place_simple_order_request, extra)
1111
+ data
1112
+ end
1113
+
1114
+ # Place order
1115
+ #
1116
+ # Places an order in the specified account.
1117
+ # This endpoint does not compute the impact to the account balance from the order before submitting the order.
1118
+ #
1119
+ # @param instrument [TradingInstrument]
1120
+ # @param side [ActionStrict] The action describes the intent or side of a trade. This is either `BUY` or `SELL`.
1121
+ # @param type [Type] The type of order to place.
1122
+ # @param time_in_force [SimpleOrderRequestBodyTimeInForce] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `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 the specified date.
1123
+ # @param amount [Float] The amount of the base currency to buy or sell.
1124
+ # @param user_id [String]
1125
+ # @param user_secret [String]
1126
+ # @param account_id [String]
1127
+ # @param limit_price [Float] The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.
1128
+ # @param stop_price [Float] The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.
1129
+ # @param post_only [Boolean] Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
1130
+ # @param expiration_date [Time] The expiration date of the order. Required if the time_in_force is GTD.
1131
+ # @param body [TradingPlaceSimpleOrderRequest]
1132
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
1133
+ def place_simple_order_with_http_info(instrument:, side:, type:, time_in_force:, amount:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, post_only: SENTINEL, expiration_date: SENTINEL, extra: {})
1134
+ _body = {}
1135
+ _body[:instrument] = instrument if instrument != SENTINEL
1136
+ _body[:side] = side if side != SENTINEL
1137
+ _body[:type] = type if type != SENTINEL
1138
+ _body[:time_in_force] = time_in_force if time_in_force != SENTINEL
1139
+ _body[:amount] = amount if amount != SENTINEL
1140
+ _body[:limit_price] = limit_price if limit_price != SENTINEL
1141
+ _body[:stop_price] = stop_price if stop_price != SENTINEL
1142
+ _body[:post_only] = post_only if post_only != SENTINEL
1143
+ _body[:expiration_date] = expiration_date if expiration_date != SENTINEL
1144
+ trading_place_simple_order_request = _body
1145
+ place_simple_order_with_http_info_impl(user_id, user_secret, account_id, trading_place_simple_order_request, extra)
1146
+ end
1147
+
1148
+ # Place order
1149
+ # Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order.
1150
+ # @param user_id [String]
1151
+ # @param user_secret [String]
1152
+ # @param account_id [String]
1153
+ # @param trading_place_simple_order_request [TradingPlaceSimpleOrderRequest]
1154
+ # @param [Hash] opts the optional parameters
1155
+ # @return [OrderUpdatedResponse]
1156
+ private def place_simple_order_impl(user_id, user_secret, account_id, trading_place_simple_order_request, opts = {})
1157
+ data, _status_code, _headers = place_simple_order_with_http_info(user_id, user_secret, account_id, trading_place_simple_order_request, opts)
1158
+ data
1159
+ end
1160
+
1161
+ # Place order
1162
+ # Places an order in the specified account. This endpoint does not compute the impact to the account balance from the order before submitting the order.
1163
+ # @param user_id [String]
1164
+ # @param user_secret [String]
1165
+ # @param account_id [String]
1166
+ # @param trading_place_simple_order_request [TradingPlaceSimpleOrderRequest]
1167
+ # @param [Hash] opts the optional parameters
1168
+ # @return [Array<(OrderUpdatedResponse, Integer, Hash)>] OrderUpdatedResponse data, response status code and response headers
1169
+ private def place_simple_order_with_http_info_impl(user_id, user_secret, account_id, trading_place_simple_order_request, opts = {})
1170
+ if @api_client.config.debugging
1171
+ @api_client.config.logger.debug 'Calling API: TradingApi.place_simple_order ...'
1172
+ end
1173
+ # verify the required parameter 'user_id' is set
1174
+ if @api_client.config.client_side_validation && user_id.nil?
1175
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.place_simple_order"
1176
+ end
1177
+ # verify the required parameter 'user_secret' is set
1178
+ if @api_client.config.client_side_validation && user_secret.nil?
1179
+ fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.place_simple_order"
1180
+ end
1181
+ # verify the required parameter 'account_id' is set
1182
+ if @api_client.config.client_side_validation && account_id.nil?
1183
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.place_simple_order"
1184
+ end
1185
+ # verify the required parameter 'trading_place_simple_order_request' is set
1186
+ if @api_client.config.client_side_validation && trading_place_simple_order_request.nil?
1187
+ fail ArgumentError, "Missing the required parameter 'trading_place_simple_order_request' when calling TradingApi.place_simple_order"
1188
+ end
1189
+ # resource path
1190
+ local_var_path = '/accounts/{accountId}/trading/simple'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
1191
+
1192
+ # query parameters
1193
+ query_params = opts[:query_params] || {}
1194
+ query_params[:'userId'] = user_id
1195
+ query_params[:'userSecret'] = user_secret
1196
+
1197
+ # header parameters
1198
+ header_params = opts[:header_params] || {}
1199
+ # HTTP header 'Accept' (if needed)
1200
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1201
+ # HTTP header 'Content-Type'
1202
+ content_type = @api_client.select_header_content_type(['application/json'])
1203
+ if !content_type.nil?
1204
+ header_params['Content-Type'] = content_type
1205
+ end
1206
+
1207
+ # form parameters
1208
+ form_params = opts[:form_params] || {}
1209
+
1210
+ # http body (model)
1211
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(trading_place_simple_order_request)
1212
+
1213
+ # return_type
1214
+ return_type = opts[:debug_return_type] || 'OrderUpdatedResponse'
1215
+
1216
+ # auth_names
1217
+ auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
1218
+
1219
+ new_options = opts.merge(
1220
+ :operation => :"TradingApi.place_simple_order",
1221
+ :header_params => header_params,
1222
+ :query_params => query_params,
1223
+ :form_params => form_params,
1224
+ :body => post_body,
1225
+ :auth_names => auth_names,
1226
+ :return_type => return_type
1227
+ )
1228
+
1229
+ data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
1230
+ if @api_client.config.debugging
1231
+ @api_client.config.logger.debug "API called: TradingApi#place_simple_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1232
+ end
1233
+ return data, status_code, headers, response
1234
+ end
1235
+
1236
+
1237
+ # Preview order
1238
+ #
1239
+ # Previews an order using the specified account.
1240
+ #
1241
+ # @param instrument [TradingInstrument]
1242
+ # @param side [ActionStrict] The action describes the intent or side of a trade. This is either `BUY` or `SELL`.
1243
+ # @param type [Type] The type of order to place.
1244
+ # @param time_in_force [SimpleOrderRequestBodyTimeInForce] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `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 the specified date.
1245
+ # @param amount [Float] The amount of the base currency to buy or sell.
1246
+ # @param user_id [String]
1247
+ # @param user_secret [String]
1248
+ # @param account_id [String]
1249
+ # @param limit_price [Float] The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.
1250
+ # @param stop_price [Float] The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.
1251
+ # @param post_only [Boolean] Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
1252
+ # @param expiration_date [Time] The expiration date of the order. Required if the time_in_force is GTD.
1253
+ # @param body [TradingPlaceSimpleOrderRequest]
1254
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
1255
+ def preview_simple_order(instrument:, side:, type:, time_in_force:, amount:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, post_only: SENTINEL, expiration_date: SENTINEL, extra: {})
1256
+ _body = {}
1257
+ _body[:instrument] = instrument if instrument != SENTINEL
1258
+ _body[:side] = side if side != SENTINEL
1259
+ _body[:type] = type if type != SENTINEL
1260
+ _body[:time_in_force] = time_in_force if time_in_force != SENTINEL
1261
+ _body[:amount] = amount if amount != SENTINEL
1262
+ _body[:limit_price] = limit_price if limit_price != SENTINEL
1263
+ _body[:stop_price] = stop_price if stop_price != SENTINEL
1264
+ _body[:post_only] = post_only if post_only != SENTINEL
1265
+ _body[:expiration_date] = expiration_date if expiration_date != SENTINEL
1266
+ trading_place_simple_order_request = _body
1267
+ data, _status_code, _headers = preview_simple_order_with_http_info_impl(user_id, user_secret, account_id, trading_place_simple_order_request, extra)
1268
+ data
1269
+ end
1270
+
1271
+ # Preview order
1272
+ #
1273
+ # Previews an order using the specified account.
1274
+ #
1275
+ # @param instrument [TradingInstrument]
1276
+ # @param side [ActionStrict] The action describes the intent or side of a trade. This is either `BUY` or `SELL`.
1277
+ # @param type [Type] The type of order to place.
1278
+ # @param time_in_force [SimpleOrderRequestBodyTimeInForce] The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `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 the specified date.
1279
+ # @param amount [Float] The amount of the base currency to buy or sell.
1280
+ # @param user_id [String]
1281
+ # @param user_secret [String]
1282
+ # @param account_id [String]
1283
+ # @param limit_price [Float] The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.
1284
+ # @param stop_price [Float] The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.
1285
+ # @param post_only [Boolean] Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.
1286
+ # @param expiration_date [Time] The expiration date of the order. Required if the time_in_force is GTD.
1287
+ # @param body [TradingPlaceSimpleOrderRequest]
1288
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
1289
+ def preview_simple_order_with_http_info(instrument:, side:, type:, time_in_force:, amount:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, post_only: SENTINEL, expiration_date: SENTINEL, extra: {})
1290
+ _body = {}
1291
+ _body[:instrument] = instrument if instrument != SENTINEL
1292
+ _body[:side] = side if side != SENTINEL
1293
+ _body[:type] = type if type != SENTINEL
1294
+ _body[:time_in_force] = time_in_force if time_in_force != SENTINEL
1295
+ _body[:amount] = amount if amount != SENTINEL
1296
+ _body[:limit_price] = limit_price if limit_price != SENTINEL
1297
+ _body[:stop_price] = stop_price if stop_price != SENTINEL
1298
+ _body[:post_only] = post_only if post_only != SENTINEL
1299
+ _body[:expiration_date] = expiration_date if expiration_date != SENTINEL
1300
+ trading_place_simple_order_request = _body
1301
+ preview_simple_order_with_http_info_impl(user_id, user_secret, account_id, trading_place_simple_order_request, extra)
1302
+ end
1303
+
1304
+ # Preview order
1305
+ # Previews an order using the specified account.
1306
+ # @param user_id [String]
1307
+ # @param user_secret [String]
1308
+ # @param account_id [String]
1309
+ # @param trading_place_simple_order_request [TradingPlaceSimpleOrderRequest]
1310
+ # @param [Hash] opts the optional parameters
1311
+ # @return [SimpleOrderPreview]
1312
+ private def preview_simple_order_impl(user_id, user_secret, account_id, trading_place_simple_order_request, opts = {})
1313
+ data, _status_code, _headers = preview_simple_order_with_http_info(user_id, user_secret, account_id, trading_place_simple_order_request, opts)
1314
+ data
1315
+ end
1316
+
1317
+ # Preview order
1318
+ # Previews an order using the specified account.
1319
+ # @param user_id [String]
1320
+ # @param user_secret [String]
1321
+ # @param account_id [String]
1322
+ # @param trading_place_simple_order_request [TradingPlaceSimpleOrderRequest]
1323
+ # @param [Hash] opts the optional parameters
1324
+ # @return [Array<(SimpleOrderPreview, Integer, Hash)>] SimpleOrderPreview data, response status code and response headers
1325
+ private def preview_simple_order_with_http_info_impl(user_id, user_secret, account_id, trading_place_simple_order_request, opts = {})
1326
+ if @api_client.config.debugging
1327
+ @api_client.config.logger.debug 'Calling API: TradingApi.preview_simple_order ...'
1328
+ end
1329
+ # verify the required parameter 'user_id' is set
1330
+ if @api_client.config.client_side_validation && user_id.nil?
1331
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.preview_simple_order"
1332
+ end
1333
+ # verify the required parameter 'user_secret' is set
1334
+ if @api_client.config.client_side_validation && user_secret.nil?
1335
+ fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.preview_simple_order"
1336
+ end
1337
+ # verify the required parameter 'account_id' is set
1338
+ if @api_client.config.client_side_validation && account_id.nil?
1339
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.preview_simple_order"
1340
+ end
1341
+ # verify the required parameter 'trading_place_simple_order_request' is set
1342
+ if @api_client.config.client_side_validation && trading_place_simple_order_request.nil?
1343
+ fail ArgumentError, "Missing the required parameter 'trading_place_simple_order_request' when calling TradingApi.preview_simple_order"
1344
+ end
1345
+ # resource path
1346
+ local_var_path = '/accounts/{accountId}/trading/simple/preview'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
1347
+
1348
+ # query parameters
1349
+ query_params = opts[:query_params] || {}
1350
+ query_params[:'userId'] = user_id
1351
+ query_params[:'userSecret'] = user_secret
1352
+
1353
+ # header parameters
1354
+ header_params = opts[:header_params] || {}
1355
+ # HTTP header 'Accept' (if needed)
1356
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1357
+ # HTTP header 'Content-Type'
1358
+ content_type = @api_client.select_header_content_type(['application/json'])
1359
+ if !content_type.nil?
1360
+ header_params['Content-Type'] = content_type
1361
+ end
1362
+
1363
+ # form parameters
1364
+ form_params = opts[:form_params] || {}
1365
+
1366
+ # http body (model)
1367
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(trading_place_simple_order_request)
1368
+
1369
+ # return_type
1370
+ return_type = opts[:debug_return_type] || 'SimpleOrderPreview'
1371
+
1372
+ # auth_names
1373
+ auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
1374
+
1375
+ new_options = opts.merge(
1376
+ :operation => :"TradingApi.preview_simple_order",
1377
+ :header_params => header_params,
1378
+ :query_params => query_params,
1379
+ :form_params => form_params,
1380
+ :body => post_body,
1381
+ :auth_names => auth_names,
1382
+ :return_type => return_type
1383
+ )
1384
+
1385
+ data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options)
1386
+ if @api_client.config.debugging
1387
+ @api_client.config.logger.debug "API called: TradingApi#preview_simple_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1388
+ end
1389
+ return data, status_code, headers, response
1390
+ end
1391
+
1392
+
857
1393
  # Replaces an order with a new one
858
1394
  #
859
1395
  # Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling
@@ -1008,6 +1544,123 @@ module SnapTrade
1008
1544
  end
1009
1545
  return data, status_code, headers, response
1010
1546
  end
1547
+
1548
+
1549
+ # Search cryptocurrency pairs instruments
1550
+ #
1551
+ # Searches cryptocurrency pairs instruments accessible to the specified account.
1552
+ #
1553
+ # @param user_id [String]
1554
+ # @param user_secret [String]
1555
+ # @param account_id [String]
1556
+ # @param base [String]
1557
+ # @param quote [String]
1558
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
1559
+ def search_cryptocurrency_pair_instruments(user_id:, user_secret:, account_id:, base: SENTINEL, quote: SENTINEL, extra: {})
1560
+ extra[:base] = base if base != SENTINEL
1561
+ extra[:quote] = quote if quote != SENTINEL
1562
+ data, _status_code, _headers = search_cryptocurrency_pair_instruments_with_http_info_impl(user_id, user_secret, account_id, extra)
1563
+ data
1564
+ end
1565
+
1566
+ # Search cryptocurrency pairs instruments
1567
+ #
1568
+ # Searches cryptocurrency pairs instruments accessible to the specified account.
1569
+ #
1570
+ # @param user_id [String]
1571
+ # @param user_secret [String]
1572
+ # @param account_id [String]
1573
+ # @param base [String]
1574
+ # @param quote [String]
1575
+ # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name
1576
+ def search_cryptocurrency_pair_instruments_with_http_info(user_id:, user_secret:, account_id:, base: SENTINEL, quote: SENTINEL, extra: {})
1577
+ extra[:base] = base if base != SENTINEL
1578
+ extra[:quote] = quote if quote != SENTINEL
1579
+ search_cryptocurrency_pair_instruments_with_http_info_impl(user_id, user_secret, account_id, extra)
1580
+ end
1581
+
1582
+ # Search cryptocurrency pairs instruments
1583
+ # Searches cryptocurrency pairs instruments accessible to the specified account.
1584
+ # @param user_id [String]
1585
+ # @param user_secret [String]
1586
+ # @param account_id [String]
1587
+ # @param [Hash] opts the optional parameters
1588
+ # @option opts [String] :base
1589
+ # @option opts [String] :quote
1590
+ # @return [TradingSearchCryptocurrencyPairInstruments200Response]
1591
+ private def search_cryptocurrency_pair_instruments_impl(user_id, user_secret, account_id, opts = {})
1592
+ data, _status_code, _headers = search_cryptocurrency_pair_instruments_with_http_info(user_id, user_secret, account_id, opts)
1593
+ data
1594
+ end
1595
+
1596
+ # Search cryptocurrency pairs instruments
1597
+ # Searches cryptocurrency pairs instruments accessible to the specified account.
1598
+ # @param user_id [String]
1599
+ # @param user_secret [String]
1600
+ # @param account_id [String]
1601
+ # @param [Hash] opts the optional parameters
1602
+ # @option opts [String] :base
1603
+ # @option opts [String] :quote
1604
+ # @return [Array<(TradingSearchCryptocurrencyPairInstruments200Response, Integer, Hash)>] TradingSearchCryptocurrencyPairInstruments200Response data, response status code and response headers
1605
+ private def search_cryptocurrency_pair_instruments_with_http_info_impl(user_id, user_secret, account_id, opts = {})
1606
+ if @api_client.config.debugging
1607
+ @api_client.config.logger.debug 'Calling API: TradingApi.search_cryptocurrency_pair_instruments ...'
1608
+ end
1609
+ # verify the required parameter 'user_id' is set
1610
+ if @api_client.config.client_side_validation && user_id.nil?
1611
+ fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.search_cryptocurrency_pair_instruments"
1612
+ end
1613
+ # verify the required parameter 'user_secret' is set
1614
+ if @api_client.config.client_side_validation && user_secret.nil?
1615
+ fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.search_cryptocurrency_pair_instruments"
1616
+ end
1617
+ # verify the required parameter 'account_id' is set
1618
+ if @api_client.config.client_side_validation && account_id.nil?
1619
+ fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.search_cryptocurrency_pair_instruments"
1620
+ end
1621
+ # resource path
1622
+ local_var_path = '/accounts/{accountId}/trading/instruments/cryptocurrencyPairs'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
1623
+
1624
+ # query parameters
1625
+ query_params = opts[:query_params] || {}
1626
+ query_params[:'userId'] = user_id
1627
+ query_params[:'userSecret'] = user_secret
1628
+ query_params[:'base'] = opts[:'base'] if !opts[:'base'].nil?
1629
+ query_params[:'quote'] = opts[:'quote'] if !opts[:'quote'].nil?
1630
+
1631
+ # header parameters
1632
+ header_params = opts[:header_params] || {}
1633
+ # HTTP header 'Accept' (if needed)
1634
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1635
+
1636
+ # form parameters
1637
+ form_params = opts[:form_params] || {}
1638
+
1639
+ # http body (model)
1640
+ post_body = opts[:debug_body]
1641
+
1642
+ # return_type
1643
+ return_type = opts[:debug_return_type] || 'TradingSearchCryptocurrencyPairInstruments200Response'
1644
+
1645
+ # auth_names
1646
+ auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp']
1647
+
1648
+ new_options = opts.merge(
1649
+ :operation => :"TradingApi.search_cryptocurrency_pair_instruments",
1650
+ :header_params => header_params,
1651
+ :query_params => query_params,
1652
+ :form_params => form_params,
1653
+ :body => post_body,
1654
+ :auth_names => auth_names,
1655
+ :return_type => return_type
1656
+ )
1657
+
1658
+ data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options)
1659
+ if @api_client.config.debugging
1660
+ @api_client.config.logger.debug "API called: TradingApi#search_cryptocurrency_pair_instruments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1661
+ end
1662
+ return data, status_code, headers, response
1663
+ end
1011
1664
  end
1012
1665
 
1013
1666
  # top-level client access to avoid having the user to insantiate their own API instances