=begin #SnapTrade #Connect brokerage accounts to your app for live positions and trading The version of the OpenAPI document: 1.0.0 Contact: api@snaptrade.com =end require 'cgi' module SnapTrade class TradingApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Cancel open order in account # # Sends a signal to the brokerage to cancel the specified order. # This will only work if the order has not yet been executed. # # @param user_id [String] # @param user_secret [String] # @param account_id [String] The ID of the account to cancel the order in. # @param brokerage_order_id [String] # @param body [TradingCancelUserAccountOrderRequest] # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def cancel_user_account_order(user_id:, user_secret:, account_id:, brokerage_order_id: SENTINEL, extra: {}) _body = {} _body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL trading_cancel_user_account_order_request = _body data, _status_code, _headers = cancel_user_account_order_with_http_info_impl(user_id, user_secret, account_id, trading_cancel_user_account_order_request, extra) data end # Cancel open order in account # # Sends a signal to the brokerage to cancel the specified order. # This will only work if the order has not yet been executed. # # @param user_id [String] # @param user_secret [String] # @param account_id [String] The ID of the account to cancel the order in. # @param brokerage_order_id [String] # @param body [TradingCancelUserAccountOrderRequest] # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def cancel_user_account_order_with_http_info(user_id:, user_secret:, account_id:, brokerage_order_id: SENTINEL, extra: {}) _body = {} _body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL trading_cancel_user_account_order_request = _body cancel_user_account_order_with_http_info_impl(user_id, user_secret, account_id, trading_cancel_user_account_order_request, extra) end # Cancel open order in account # Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. # @param user_id [String] # @param user_secret [String] # @param account_id [String] The ID of the account to cancel the order in. # @param trading_cancel_user_account_order_request [TradingCancelUserAccountOrderRequest] The Order ID to be canceled # @param [Hash] opts the optional parameters # @return [AccountOrderRecord] private def cancel_user_account_order_impl(user_id, user_secret, account_id, trading_cancel_user_account_order_request, opts = {}) data, _status_code, _headers = cancel_user_account_order_with_http_info(user_id, user_secret, account_id, trading_cancel_user_account_order_request, opts) data end # Cancel open order in account # Sends a signal to the brokerage to cancel the specified order. This will only work if the order has not yet been executed. # @param user_id [String] # @param user_secret [String] # @param account_id [String] The ID of the account to cancel the order in. # @param trading_cancel_user_account_order_request [TradingCancelUserAccountOrderRequest] The Order ID to be canceled # @param [Hash] opts the optional parameters # @return [Array<(AccountOrderRecord, Integer, Hash)>] AccountOrderRecord data, response status code and response headers private def cancel_user_account_order_with_http_info_impl(user_id, user_secret, account_id, trading_cancel_user_account_order_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TradingApi.cancel_user_account_order ...' end # verify the required parameter 'user_id' is set if @api_client.config.client_side_validation && user_id.nil? fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.cancel_user_account_order" end # verify the required parameter 'user_secret' is set if @api_client.config.client_side_validation && user_secret.nil? fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.cancel_user_account_order" end # verify the required parameter 'account_id' is set if @api_client.config.client_side_validation && account_id.nil? fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.cancel_user_account_order" end # verify the required parameter 'trading_cancel_user_account_order_request' is set if @api_client.config.client_side_validation && trading_cancel_user_account_order_request.nil? fail ArgumentError, "Missing the required parameter 'trading_cancel_user_account_order_request' when calling TradingApi.cancel_user_account_order" end # resource path local_var_path = '/accounts/{accountId}/orders/cancel'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'userId'] = user_id query_params[:'userSecret'] = user_secret # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(trading_cancel_user_account_order_request) # return_type return_type = opts[:debug_return_type] || 'AccountOrderRecord' # auth_names auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp'] new_options = opts.merge( :operation => :"TradingApi.cancel_user_account_order", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: TradingApi#cancel_user_account_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers, response end # Check the impact of a trade on an account # # Return the trade object and it's impact on the account for the specified order. # # @param user_id [String] # @param user_secret [String] # @param account_id [String] # @param action [ActionStrict] Trade Action # @param order_type [OrderTypeStrict] Order Type # @param price [Float] Trade Price if limit or stop limit order # @param stop [Float] Stop Price. If stop loss or stop limit order, the price to trigger the stop # @param time_in_force [TimeInForceStrict] Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled # @param units [Float] # @param universal_symbol_id [String] # @param notional_value [ManualTradeFormNotionalValue] # @param body [ManualTradeForm] # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def get_order_impact(user_id:, user_secret:, account_id: SENTINEL, action: SENTINEL, order_type: SENTINEL, price: SENTINEL, stop: SENTINEL, time_in_force: SENTINEL, units: SENTINEL, universal_symbol_id: SENTINEL, notional_value: SENTINEL, extra: {}) _body = {} _body[:account_id] = account_id if account_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:units] = units if units != SENTINEL _body[:universal_symbol_id] = universal_symbol_id if universal_symbol_id != SENTINEL _body[:notional_value] = notional_value if notional_value != SENTINEL manual_trade_form = _body data, _status_code, _headers = get_order_impact_with_http_info_impl(user_id, user_secret, manual_trade_form, extra) data end # Check the impact of a trade on an account # # Return the trade object and it's impact on the account for the specified order. # # @param user_id [String] # @param user_secret [String] # @param account_id [String] # @param action [ActionStrict] Trade Action # @param order_type [OrderTypeStrict] Order Type # @param price [Float] Trade Price if limit or stop limit order # @param stop [Float] Stop Price. If stop loss or stop limit order, the price to trigger the stop # @param time_in_force [TimeInForceStrict] Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled # @param units [Float] # @param universal_symbol_id [String] # @param notional_value [ManualTradeFormNotionalValue] # @param body [ManualTradeForm] # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def get_order_impact_with_http_info(user_id:, user_secret:, account_id: SENTINEL, action: SENTINEL, order_type: SENTINEL, price: SENTINEL, stop: SENTINEL, time_in_force: SENTINEL, units: SENTINEL, universal_symbol_id: SENTINEL, notional_value: SENTINEL, extra: {}) _body = {} _body[:account_id] = account_id if account_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:units] = units if units != SENTINEL _body[:universal_symbol_id] = universal_symbol_id if universal_symbol_id != SENTINEL _body[:notional_value] = notional_value if notional_value != SENTINEL manual_trade_form = _body get_order_impact_with_http_info_impl(user_id, user_secret, manual_trade_form, extra) end # Check the impact of a trade on an account # Return the trade object and it's impact on the account for the specified order. # @param user_id [String] # @param user_secret [String] # @param manual_trade_form [ManualTradeForm] # @param [Hash] opts the optional parameters # @return [ManualTradeAndImpact] private def get_order_impact_impl(user_id, user_secret, manual_trade_form, opts = {}) data, _status_code, _headers = get_order_impact_with_http_info(user_id, user_secret, manual_trade_form, opts) data end # Check the impact of a trade on an account # Return the trade object and it's impact on the account for the specified order. # @param user_id [String] # @param user_secret [String] # @param manual_trade_form [ManualTradeForm] # @param [Hash] opts the optional parameters # @return [Array<(ManualTradeAndImpact, Integer, Hash)>] ManualTradeAndImpact data, response status code and response headers private def get_order_impact_with_http_info_impl(user_id, user_secret, manual_trade_form, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TradingApi.get_order_impact ...' end # verify the required parameter 'user_id' is set if @api_client.config.client_side_validation && user_id.nil? fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.get_order_impact" end # verify the required parameter 'user_secret' is set if @api_client.config.client_side_validation && user_secret.nil? fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.get_order_impact" end # verify the required parameter 'manual_trade_form' is set if @api_client.config.client_side_validation && manual_trade_form.nil? fail ArgumentError, "Missing the required parameter 'manual_trade_form' when calling TradingApi.get_order_impact" end # resource path local_var_path = '/trade/impact' # query parameters query_params = opts[:query_params] || {} query_params[:'userId'] = user_id query_params[:'userSecret'] = user_secret # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(manual_trade_form) # return_type return_type = opts[:debug_return_type] || 'ManualTradeAndImpact' # auth_names auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp'] new_options = opts.merge( :operation => :"TradingApi.get_order_impact", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: TradingApi#get_order_impact\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers, response end # Get symbol quotes # # Returns live quote(s) from the brokerage for the specified symbol(s). # # @param user_id [String] # @param user_secret [String] # @param symbols [String] List of universal_symbol_id or tickers to get quotes for. # @param account_id [String] The ID of the account to get quotes. # @param use_ticker [Boolean] Should be set to True if providing tickers. # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def get_user_account_quotes(user_id:, user_secret:, symbols:, account_id:, use_ticker: SENTINEL, extra: {}) extra[:use_ticker] = use_ticker if use_ticker != SENTINEL data, _status_code, _headers = get_user_account_quotes_with_http_info_impl(user_id, user_secret, symbols, account_id, extra) data end # Get symbol quotes # # Returns live quote(s) from the brokerage for the specified symbol(s). # # @param user_id [String] # @param user_secret [String] # @param symbols [String] List of universal_symbol_id or tickers to get quotes for. # @param account_id [String] The ID of the account to get quotes. # @param use_ticker [Boolean] Should be set to True if providing tickers. # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def get_user_account_quotes_with_http_info(user_id:, user_secret:, symbols:, account_id:, use_ticker: SENTINEL, extra: {}) extra[:use_ticker] = use_ticker if use_ticker != SENTINEL get_user_account_quotes_with_http_info_impl(user_id, user_secret, symbols, account_id, extra) end # Get symbol quotes # Returns live quote(s) from the brokerage for the specified symbol(s). # @param user_id [String] # @param user_secret [String] # @param symbols [String] List of universal_symbol_id or tickers to get quotes for. # @param account_id [String] The ID of the account to get quotes. # @param [Hash] opts the optional parameters # @option opts [Boolean] :use_ticker Should be set to True if providing tickers. # @return [Array] private def get_user_account_quotes_impl(user_id, user_secret, symbols, account_id, opts = {}) data, _status_code, _headers = get_user_account_quotes_with_http_info(user_id, user_secret, symbols, account_id, opts) data end # Get symbol quotes # Returns live quote(s) from the brokerage for the specified symbol(s). # @param user_id [String] # @param user_secret [String] # @param symbols [String] List of universal_symbol_id or tickers to get quotes for. # @param account_id [String] The ID of the account to get quotes. # @param [Hash] opts the optional parameters # @option opts [Boolean] :use_ticker Should be set to True if providing tickers. # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers private def get_user_account_quotes_with_http_info_impl(user_id, user_secret, symbols, account_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TradingApi.get_user_account_quotes ...' end # verify the required parameter 'user_id' is set if @api_client.config.client_side_validation && user_id.nil? fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.get_user_account_quotes" end # verify the required parameter 'user_secret' is set if @api_client.config.client_side_validation && user_secret.nil? fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.get_user_account_quotes" end # verify the required parameter 'symbols' is set if @api_client.config.client_side_validation && symbols.nil? fail ArgumentError, "Missing the required parameter 'symbols' when calling TradingApi.get_user_account_quotes" end # verify the required parameter 'account_id' is set if @api_client.config.client_side_validation && account_id.nil? fail ArgumentError, "Missing the required parameter 'account_id' when calling TradingApi.get_user_account_quotes" end # resource path local_var_path = '/accounts/{accountId}/quotes'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'userId'] = user_id query_params[:'userSecret'] = user_secret query_params[:'symbols'] = symbols query_params[:'use_ticker'] = opts[:'use_ticker'] if !opts[:'use_ticker'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Array' # auth_names auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp'] new_options = opts.merge( :operation => :"TradingApi.get_user_account_quotes", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers, response = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: TradingApi#get_user_account_quotes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers, response end # Place a trade with NO validation. # # Places a specified trade in the specified account. # # @param user_id [String] # @param user_secret [String] # @param account_id [String] # @param action [ActionStrict] Trade Action # @param order_type [OrderTypeStrict] Order Type # @param price [Float] Trade Price if limit or stop limit order # @param stop [Float] Stop Price. If stop loss or stop limit order, the price to trigger the stop # @param time_in_force [TimeInForceStrict] Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled # @param units [Float] # @param universal_symbol_id [String] # @param notional_value [ManualTradeFormNotionalValue] # @param body [ManualTradeForm] # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def place_force_order(user_id:, user_secret:, account_id: SENTINEL, action: SENTINEL, order_type: SENTINEL, price: SENTINEL, stop: SENTINEL, time_in_force: SENTINEL, units: SENTINEL, universal_symbol_id: SENTINEL, notional_value: SENTINEL, extra: {}) _body = {} _body[:account_id] = account_id if account_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:units] = units if units != SENTINEL _body[:universal_symbol_id] = universal_symbol_id if universal_symbol_id != SENTINEL _body[:notional_value] = notional_value if notional_value != SENTINEL manual_trade_form = _body data, _status_code, _headers = place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form, extra) data end # Place a trade with NO validation. # # Places a specified trade in the specified account. # # @param user_id [String] # @param user_secret [String] # @param account_id [String] # @param action [ActionStrict] Trade Action # @param order_type [OrderTypeStrict] Order Type # @param price [Float] Trade Price if limit or stop limit order # @param stop [Float] Stop Price. If stop loss or stop limit order, the price to trigger the stop # @param time_in_force [TimeInForceStrict] Trade time in force examples: * FOK - Fill Or Kill * Day - Day * GTC - Good Til Canceled # @param units [Float] # @param universal_symbol_id [String] # @param notional_value [ManualTradeFormNotionalValue] # @param body [ManualTradeForm] # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def place_force_order_with_http_info(user_id:, user_secret:, account_id: SENTINEL, action: SENTINEL, order_type: SENTINEL, price: SENTINEL, stop: SENTINEL, time_in_force: SENTINEL, units: SENTINEL, universal_symbol_id: SENTINEL, notional_value: SENTINEL, extra: {}) _body = {} _body[:account_id] = account_id if account_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:units] = units if units != SENTINEL _body[:universal_symbol_id] = universal_symbol_id if universal_symbol_id != SENTINEL _body[:notional_value] = notional_value if notional_value != SENTINEL manual_trade_form = _body place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form, extra) end # Place a trade with NO validation. # Places a specified trade in the specified account. # @param user_id [String] # @param user_secret [String] # @param manual_trade_form [ManualTradeForm] # @param [Hash] opts the optional parameters # @return [AccountOrderRecord] private def place_force_order_impl(user_id, user_secret, manual_trade_form, opts = {}) data, _status_code, _headers = place_force_order_with_http_info(user_id, user_secret, manual_trade_form, opts) data end # Place a trade with NO validation. # Places a specified trade in the specified account. # @param user_id [String] # @param user_secret [String] # @param manual_trade_form [ManualTradeForm] # @param [Hash] opts the optional parameters # @return [Array<(AccountOrderRecord, Integer, Hash)>] AccountOrderRecord data, response status code and response headers private def place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TradingApi.place_force_order ...' end # verify the required parameter 'user_id' is set if @api_client.config.client_side_validation && user_id.nil? fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.place_force_order" end # verify the required parameter 'user_secret' is set if @api_client.config.client_side_validation && user_secret.nil? fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.place_force_order" end # verify the required parameter 'manual_trade_form' is set if @api_client.config.client_side_validation && manual_trade_form.nil? fail ArgumentError, "Missing the required parameter 'manual_trade_form' when calling TradingApi.place_force_order" end # resource path local_var_path = '/trade/place' # query parameters query_params = opts[:query_params] || {} query_params[:'userId'] = user_id query_params[:'userSecret'] = user_secret # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(manual_trade_form) # return_type return_type = opts[:debug_return_type] || 'AccountOrderRecord' # auth_names auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp'] new_options = opts.merge( :operation => :"TradingApi.place_force_order", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: TradingApi#place_force_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers, response end # Place order # # Places the specified trade object. This places the order in the account and # returns the status of the order from the brokerage. # # @param trade_id [String] The ID of trade object obtained from trade/impact endpoint # @param user_id [String] # @param user_secret [String] # @param wait_to_confirm [Boolean] Optional, defaults to true. Determines if a wait is performed to check on order status. If false, latency will be reduced but orders returned will be more likely to be of status PENDING as we will not wait to check on the status before responding to the request # @param body [ValidatedTradeBody] # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def place_order(trade_id:, user_id:, user_secret:, wait_to_confirm: SENTINEL, extra: {}) _body = {} _body[:wait_to_confirm] = wait_to_confirm if wait_to_confirm != SENTINEL extra[:validated_trade_body] = _body if !_body.empty? data, _status_code, _headers = place_order_with_http_info_impl(trade_id, user_id, user_secret, extra) data end # Place order # # Places the specified trade object. This places the order in the account and # returns the status of the order from the brokerage. # # @param trade_id [String] The ID of trade object obtained from trade/impact endpoint # @param user_id [String] # @param user_secret [String] # @param wait_to_confirm [Boolean] Optional, defaults to true. Determines if a wait is performed to check on order status. If false, latency will be reduced but orders returned will be more likely to be of status PENDING as we will not wait to check on the status before responding to the request # @param body [ValidatedTradeBody] # @param [Hash] extra additional parameters to pass along through :header_params, :query_params, or parameter name def place_order_with_http_info(trade_id:, user_id:, user_secret:, wait_to_confirm: SENTINEL, extra: {}) _body = {} _body[:wait_to_confirm] = wait_to_confirm if wait_to_confirm != SENTINEL extra[:validated_trade_body] = _body if !_body.empty? place_order_with_http_info_impl(trade_id, user_id, user_secret, extra) end # Place order # Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. # @param trade_id [String] The ID of trade object obtained from trade/impact endpoint # @param user_id [String] # @param user_secret [String] # @param [Hash] opts the optional parameters # @option opts [ValidatedTradeBody] :validated_trade_body # @return [AccountOrderRecord] private def place_order_impl(trade_id, user_id, user_secret, opts = {}) data, _status_code, _headers = place_order_with_http_info(trade_id, user_id, user_secret, opts) data end # Place order # Places the specified trade object. This places the order in the account and returns the status of the order from the brokerage. # @param trade_id [String] The ID of trade object obtained from trade/impact endpoint # @param user_id [String] # @param user_secret [String] # @param [Hash] opts the optional parameters # @option opts [ValidatedTradeBody] :validated_trade_body # @return [Array<(AccountOrderRecord, Integer, Hash)>] AccountOrderRecord data, response status code and response headers private def place_order_with_http_info_impl(trade_id, user_id, user_secret, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TradingApi.place_order ...' end # verify the required parameter 'trade_id' is set if @api_client.config.client_side_validation && trade_id.nil? fail ArgumentError, "Missing the required parameter 'trade_id' when calling TradingApi.place_order" end # verify the required parameter 'user_id' is set if @api_client.config.client_side_validation && user_id.nil? fail ArgumentError, "Missing the required parameter 'user_id' when calling TradingApi.place_order" end # verify the required parameter 'user_secret' is set if @api_client.config.client_side_validation && user_secret.nil? fail ArgumentError, "Missing the required parameter 'user_secret' when calling TradingApi.place_order" end # resource path local_var_path = '/trade/{tradeId}'.sub('{' + 'tradeId' + '}', CGI.escape(trade_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'userId'] = user_id query_params[:'userSecret'] = user_secret # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'validated_trade_body']) # return_type return_type = opts[:debug_return_type] || 'AccountOrderRecord' # auth_names auth_names = opts[:debug_auth_names] || ['PartnerClientId', 'PartnerSignature', 'PartnerTimestamp'] new_options = opts.merge( :operation => :"TradingApi.place_order", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers, response = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: TradingApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers, response end end # top-level client access to avoid having the user to insantiate their own API instances Trading = TradingApi::new end