Class: SnapTrade::TradingApi
- Inherits:
-
Object
- Object
- SnapTrade::TradingApi
- Defined in:
- lib/snaptrade/api/trading_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#cancel_order(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) ⇒ Object
Cancel order.
-
#cancel_order_with_http_info(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) ⇒ Object
Cancel order.
-
#cancel_user_account_order(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) ⇒ Object
Cancel equity order.
-
#cancel_user_account_order_with_http_info(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) ⇒ Object
Cancel equity order.
-
#get_cryptocurrency_pair_quote(user_id:, user_secret:, account_id:, instrument_symbol:, extra: {}) ⇒ Object
Get crypto pair quote.
-
#get_cryptocurrency_pair_quote_with_http_info(user_id:, user_secret:, account_id:, instrument_symbol:, extra: {}) ⇒ Object
Get crypto pair quote.
-
#get_option_impact(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) ⇒ Object
Get option order impact.
-
#get_option_impact_with_http_info(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) ⇒ Object
Get option order impact.
-
#get_order_impact(account_id:, action:, universal_symbol_id:, order_type:, time_in_force:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {}) ⇒ Object
Check equity order impact.
-
#get_order_impact_with_http_info(account_id:, action:, universal_symbol_id:, order_type:, time_in_force:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {}) ⇒ Object
Check equity order impact.
-
#get_user_account_option_quotes(user_id:, user_secret:, account_id:, symbol:, extra: {}) ⇒ Object
Get option quote.
-
#get_user_account_option_quotes_with_http_info(user_id:, user_secret:, account_id:, symbol:, extra: {}) ⇒ Object
Get option quote.
-
#get_user_account_quotes(user_id:, user_secret:, symbols:, account_id:, use_ticker: SENTINEL, extra: {}) ⇒ Object
Get equity symbol quotes.
-
#get_user_account_quotes_with_http_info(user_id:, user_secret:, symbols:, account_id:, use_ticker: SENTINEL, extra: {}) ⇒ Object
Get equity symbol quotes.
-
#initialize(api_client = ApiClient.default) ⇒ TradingApi
constructor
A new instance of TradingApi.
-
#place_bracket_order(action:, instrument:, order_type:, time_in_force:, stop_loss:, take_profit:, account_id:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) ⇒ Object
Place bracket order.
-
#place_bracket_order_with_http_info(action:, instrument:, order_type:, time_in_force:, stop_loss:, take_profit:, account_id:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) ⇒ Object
Place bracket order.
-
#place_complex_order(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {}) ⇒ Object
Place complex order.
-
#place_complex_order_with_http_info(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {}) ⇒ Object
Place complex order.
-
#place_crypto_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: {}) ⇒ Object
Place crypto order.
-
#place_crypto_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: {}) ⇒ Object
Place crypto order.
-
#place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', expiry_date: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, client_order_id: SENTINEL, extra: {}) ⇒ Object
Place equity order.
-
#place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', expiry_date: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, client_order_id: SENTINEL, extra: {}) ⇒ Object
Place equity order.
-
#place_mleg_order(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) ⇒ Object
Place option order.
-
#place_mleg_order_with_http_info(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) ⇒ Object
Place option order.
-
#place_order(trade_id:, user_id:, user_secret:, wait_to_confirm: SENTINEL, extra: {}) ⇒ Object
Place checked equity order.
-
#place_order_with_http_info(trade_id:, user_id:, user_secret:, wait_to_confirm: SENTINEL, extra: {}) ⇒ Object
Place checked equity order.
-
#preview_crypto_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: {}) ⇒ Object
Preview crypto order.
-
#preview_crypto_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: {}) ⇒ Object
Preview crypto order.
-
#replace_order(brokerage_order_id:, action:, order_type:, time_in_force:, account_id:, user_id:, user_secret:, price: SENTINEL, symbol: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) ⇒ Object
Replace order.
-
#replace_order_with_http_info(brokerage_order_id:, action:, order_type:, time_in_force:, account_id:, user_id:, user_secret:, price: SENTINEL, symbol: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) ⇒ Object
Replace order.
-
#search_cryptocurrency_pair_instruments(user_id:, user_secret:, account_id:, base: SENTINEL, quote: SENTINEL, extra: {}) ⇒ Object
Get crypto pairs.
-
#search_cryptocurrency_pair_instruments_with_http_info(user_id:, user_secret:, account_id:, base: SENTINEL, quote: SENTINEL, extra: {}) ⇒ Object
Get crypto pairs.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ TradingApi
Returns a new instance of TradingApi.
16 17 18 |
# File 'lib/snaptrade/api/trading_api.rb', line 16 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
14 15 16 |
# File 'lib/snaptrade/api/trading_api.rb', line 14 def api_client @api_client end |
Instance Method Details
#cancel_order(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) ⇒ Object
Cancel order
Cancels an order in the specified account. Accepts order IDs for all asset types.
30 31 32 33 34 35 36 |
# File 'lib/snaptrade/api/trading_api.rb', line 30 def cancel_order(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) _body = {} _body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL account_information_get_user_account_order_detail_request = _body data, _status_code, _headers = cancel_order_with_http_info_impl(user_id, user_secret, account_id, account_information_get_user_account_order_detail_request, extra) data end |
#cancel_order_with_http_info(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) ⇒ Object
Cancel order
Cancels an order in the specified account. Accepts order IDs for all asset types.
48 49 50 51 52 53 |
# File 'lib/snaptrade/api/trading_api.rb', line 48 def cancel_order_with_http_info(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) _body = {} _body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL account_information_get_user_account_order_detail_request = _body cancel_order_with_http_info_impl(user_id, user_secret, account_id, account_information_get_user_account_order_detail_request, extra) end |
#cancel_user_account_order(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) ⇒ Object
Cancel equity order
**This endpoint is deprecated. Please switch to [the new cancel order endpoint](/reference/Trading/Trading_cancelOrder) ** Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected.
155 156 157 158 159 160 161 |
# File 'lib/snaptrade/api/trading_api.rb', line 155 def cancel_user_account_order(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) _body = {} _body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL account_information_get_user_account_order_detail_request = _body data, _status_code, _headers = cancel_user_account_order_with_http_info_impl(user_id, user_secret, account_id, account_information_get_user_account_order_detail_request, extra) data end |
#cancel_user_account_order_with_http_info(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) ⇒ Object
Cancel equity order
**This endpoint is deprecated. Please switch to [the new cancel order endpoint](/reference/Trading/Trading_cancelOrder) ** Attempts to cancel an open order with the brokerage. If the order is no longer cancellable, the request will be rejected.
174 175 176 177 178 179 |
# File 'lib/snaptrade/api/trading_api.rb', line 174 def cancel_user_account_order_with_http_info(brokerage_order_id:, user_id:, user_secret:, account_id:, extra: {}) _body = {} _body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL account_information_get_user_account_order_detail_request = _body cancel_user_account_order_with_http_info_impl(user_id, user_secret, account_id, account_information_get_user_account_order_detail_request, extra) end |
#get_cryptocurrency_pair_quote(user_id:, user_secret:, account_id:, instrument_symbol:, extra: {}) ⇒ Object
Get crypto pair quote
Gets a quote for the specified account.
279 280 281 282 |
# File 'lib/snaptrade/api/trading_api.rb', line 279 def get_cryptocurrency_pair_quote(user_id:, user_secret:, account_id:, instrument_symbol:, extra: {}) data, _status_code, _headers = get_cryptocurrency_pair_quote_with_http_info_impl(user_id, user_secret, account_id, instrument_symbol, extra) data end |
#get_cryptocurrency_pair_quote_with_http_info(user_id:, user_secret:, account_id:, instrument_symbol:, extra: {}) ⇒ Object
Get crypto pair quote
Gets a quote for the specified account.
293 294 295 |
# File 'lib/snaptrade/api/trading_api.rb', line 293 def get_cryptocurrency_pair_quote_with_http_info(user_id:, user_secret:, account_id:, instrument_symbol:, extra: {}) get_cryptocurrency_pair_quote_with_http_info_impl(user_id, user_secret, account_id, instrument_symbol, extra) end |
#get_option_impact(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) ⇒ Object
Get option order impact
Simulates an option order with up to 4 legs and returns the estimated cost and transaction fees without placing it. Only supported for certain enabled brokerages. Please refer to the [brokerage trading support page](support.snaptrade.com/brokerages) for more information on which brokerages support this endpoint.
397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/snaptrade/api/trading_api.rb', line 397 def get_option_impact(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) _body = {} _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:limit_price] = limit_price if limit_price != SENTINEL _body[:stop_price] = stop_price if stop_price != SENTINEL _body[:price_effect] = price_effect if price_effect != SENTINEL _body[:legs] = legs if legs != SENTINEL mleg_trade_form = _body data, _status_code, _headers = get_option_impact_with_http_info_impl(user_id, user_secret, account_id, mleg_trade_form, extra) data end |
#get_option_impact_with_http_info(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) ⇒ Object
Get option order impact
Simulates an option order with up to 4 legs and returns the estimated cost and transaction fees without placing it. Only supported for certain enabled brokerages. Please refer to the [brokerage trading support page](support.snaptrade.com/brokerages) for more information on which brokerages support this endpoint.
426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/snaptrade/api/trading_api.rb', line 426 def get_option_impact_with_http_info(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) _body = {} _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:limit_price] = limit_price if limit_price != SENTINEL _body[:stop_price] = stop_price if stop_price != SENTINEL _body[:price_effect] = price_effect if price_effect != SENTINEL _body[:legs] = legs if legs != SENTINEL mleg_trade_form = _body get_option_impact_with_http_info_impl(user_id, user_secret, account_id, mleg_trade_form, extra) end |
#get_order_impact(account_id:, action:, universal_symbol_id:, order_type:, time_in_force:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {}) ⇒ Object
Check equity order impact
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.
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
# File 'lib/snaptrade/api/trading_api.rb', line 544 def get_order_impact(account_id:, action:, universal_symbol_id:, order_type:, time_in_force:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {}) _body = {} _body[:account_id] = account_id if account_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:universal_symbol_id] = universal_symbol_id if universal_symbol_id != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:units] = units if units != 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 |
#get_order_impact_with_http_info(account_id:, action:, universal_symbol_id:, order_type:, time_in_force:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {}) ⇒ Object
Check equity order impact
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.
577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
# File 'lib/snaptrade/api/trading_api.rb', line 577 def get_order_impact_with_http_info(account_id:, action:, universal_symbol_id:, order_type:, time_in_force:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, extra: {}) _body = {} _body[:account_id] = account_id if account_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:universal_symbol_id] = universal_symbol_id if universal_symbol_id != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:units] = units if units != 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 |
#get_user_account_option_quotes(user_id:, user_secret:, account_id:, symbol:, extra: {}) ⇒ Object
Get option quote
Returns a quote for a single option contract. The option contract is specified using in the 21 character OCC format. For example ‘AAPL 251114C00240000` represents a call option on AAPL expiring on 2025-11-14 with a strike price of $240. For more information on the OCC format, see [here](en.wikipedia.org/wiki/Option_symbol#OCC_format) Note: These are derived values and are not suitable for trading purposes.
685 686 687 688 |
# File 'lib/snaptrade/api/trading_api.rb', line 685 def get_user_account_option_quotes(user_id:, user_secret:, account_id:, symbol:, extra: {}) data, _status_code, _headers = get_user_account_option_quotes_with_http_info_impl(user_id, user_secret, account_id, symbol, extra) data end |
#get_user_account_option_quotes_with_http_info(user_id:, user_secret:, account_id:, symbol:, extra: {}) ⇒ Object
Get option quote
Returns a quote for a single option contract. The option contract is specified using in the 21 character OCC format. For example ‘AAPL 251114C00240000` represents a call option on AAPL expiring on 2025-11-14 with a strike price of $240. For more information on the OCC format, see [here](en.wikipedia.org/wiki/Option_symbol#OCC_format) Note: These are derived values and are not suitable for trading purposes.
700 701 702 |
# File 'lib/snaptrade/api/trading_api.rb', line 700 def get_user_account_option_quotes_with_http_info(user_id:, user_secret:, account_id:, symbol:, extra: {}) get_user_account_option_quotes_with_http_info_impl(user_id, user_secret, account_id, symbol, extra) end |
#get_user_account_quotes(user_id:, user_secret:, symbols:, account_id:, use_ticker: SENTINEL, extra: {}) ⇒ Object
Get equity symbol quotes
Returns a maximum of 10 quotes from the brokerage for the specified symbols and account.
The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint.
**This endpoint is not a substitute for a market data provider. Frequent polling of this endpoint may result in the disabling of your keys**
This endpoint does not work for options quotes.
This endpoint is disabled for free plans by default. Please contact support to enable this endpoint if needed.
807 808 809 810 811 |
# File 'lib/snaptrade/api/trading_api.rb', line 807 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_user_account_quotes_with_http_info(user_id:, user_secret:, symbols:, account_id:, use_ticker: SENTINEL, extra: {}) ⇒ Object
Get equity symbol quotes
Returns a maximum of 10 quotes from the brokerage for the specified symbols and account.
The quotes returned can be delayed depending on the brokerage the account belongs to. It is highly recommended that you use your own market data provider for real-time quotes instead of relying on this endpoint.
**This endpoint is not a substitute for a market data provider. Frequent polling of this endpoint may result in the disabling of your keys**
This endpoint does not work for options quotes.
This endpoint is disabled for free plans by default. Please contact support to enable this endpoint if needed.
831 832 833 834 |
# File 'lib/snaptrade/api/trading_api.rb', line 831 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 |
#place_bracket_order(action:, instrument:, order_type:, time_in_force:, stop_loss:, take_profit:, account_id:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) ⇒ Object
Place bracket order
**This endpoint is deprecated. Please switch to [the new complex order endpoint](/reference/Trading/Trading_placeComplexOrder) ** Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 |
# File 'lib/snaptrade/api/trading_api.rb', line 944 def place_bracket_order(action:, instrument:, order_type:, time_in_force:, stop_loss:, take_profit:, account_id:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) _body = {} _body[:action] = action if action != SENTINEL _body[:instrument] = instrument if instrument != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:units] = units if units != SENTINEL _body[:stop_loss] = stop_loss if stop_loss != SENTINEL _body[:take_profit] = take_profit if take_profit != SENTINEL manual_trade_form_bracket = _body data, _status_code, _headers = place_bracket_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_bracket, extra) data end |
#place_bracket_order_with_http_info(action:, instrument:, order_type:, time_in_force:, stop_loss:, take_profit:, account_id:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) ⇒ Object
Place bracket order
**This endpoint is deprecated. Please switch to [the new complex order endpoint](/reference/Trading/Trading_placeComplexOrder) ** Places a bracket order (entry order + OCO of stop loss and take profit). Disabled by default please contact support for use. Only supported on certain brokerages
980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
# File 'lib/snaptrade/api/trading_api.rb', line 980 def place_bracket_order_with_http_info(action:, instrument:, order_type:, time_in_force:, stop_loss:, take_profit:, account_id:, user_id:, user_secret:, price: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) _body = {} _body[:action] = action if action != SENTINEL _body[:instrument] = instrument if instrument != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:units] = units if units != SENTINEL _body[:stop_loss] = stop_loss if stop_loss != SENTINEL _body[:take_profit] = take_profit if take_profit != SENTINEL manual_trade_form_bracket = _body place_bracket_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_bracket, extra) end |
#place_complex_order(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {}) ⇒ Object
Place complex order
Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable. Only supported on certain brokerages. Please refer to the [brokerage trading support page](support.snaptrade.com/brokerages) for details on which brokerages support complex orders and which types they support.
-
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.
1102 1103 1104 1105 1106 1107 1108 1109 1110 |
# File 'lib/snaptrade/api/trading_api.rb', line 1102 def place_complex_order(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {}) _body = {} _body[:type] = type if type != SENTINEL _body[:orders] = orders if orders != SENTINEL _body[:client_order_id] = client_order_id if client_order_id != SENTINEL manual_trade_form_complex = _body data, _status_code, _headers = place_complex_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_complex, extra) data end |
#place_complex_order_with_http_info(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {}) ⇒ Object
Place complex order
Places a complex conditional order (OCO, OTO, or OTOCO). Disabled by default — contact support to enable. Only supported on certain brokerages. Please refer to the [brokerage trading support page](support.snaptrade.com/brokerages) for details on which brokerages support complex orders and which types they support.
-
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.
1130 1131 1132 1133 1134 1135 1136 1137 |
# File 'lib/snaptrade/api/trading_api.rb', line 1130 def place_complex_order_with_http_info(type:, orders:, account_id:, user_id:, user_secret:, client_order_id: SENTINEL, extra: {}) _body = {} _body[:type] = type if type != SENTINEL _body[:orders] = orders if orders != SENTINEL _body[:client_order_id] = client_order_id if client_order_id != SENTINEL manual_trade_form_complex = _body place_complex_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_form_complex, extra) end |
#place_crypto_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: {}) ⇒ Object
Place crypto order
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.
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 |
# File 'lib/snaptrade/api/trading_api.rb', line 1247 def place_crypto_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: {}) _body = {} _body[:instrument] = instrument if instrument != SENTINEL _body[:side] = side if side != SENTINEL _body[:type] = type if type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:amount] = amount if amount != SENTINEL _body[:limit_price] = limit_price if limit_price != SENTINEL _body[:stop_price] = stop_price if stop_price != SENTINEL _body[:post_only] = post_only if post_only != SENTINEL _body[:expiration_date] = expiration_date if expiration_date != SENTINEL crypto_order_form = _body data, _status_code, _headers = place_crypto_order_with_http_info_impl(user_id, user_secret, account_id, crypto_order_form, extra) data end |
#place_crypto_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: {}) ⇒ Object
Place crypto order
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.
1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 |
# File 'lib/snaptrade/api/trading_api.rb', line 1282 def place_crypto_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: {}) _body = {} _body[:instrument] = instrument if instrument != SENTINEL _body[:side] = side if side != SENTINEL _body[:type] = type if type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:amount] = amount if amount != SENTINEL _body[:limit_price] = limit_price if limit_price != SENTINEL _body[:stop_price] = stop_price if stop_price != SENTINEL _body[:post_only] = post_only if post_only != SENTINEL _body[:expiration_date] = expiration_date if expiration_date != SENTINEL crypto_order_form = _body place_crypto_order_with_http_info_impl(user_id, user_secret, account_id, crypto_order_form, extra) end |
#place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', expiry_date: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, client_order_id: SENTINEL, extra: {}) ⇒ Object
Place equity order
Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds.
This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact).
It’s recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this.
1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 |
# File 'lib/snaptrade/api/trading_api.rb', line 1411 def place_force_order(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', expiry_date: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, client_order_id: SENTINEL, extra: {}) _body = {} _body[:account_id] = account_id if account_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:universal_symbol_id] = universal_symbol_id if universal_symbol_id != SENTINEL _body[:symbol] = symbol if symbol != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:trading_session] = trading_session if trading_session != SENTINEL _body[:expiry_date] = expiry_date if expiry_date != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:units] = units if units != SENTINEL _body[:notional_value] = notional_value if notional_value != SENTINEL _body[:client_order_id] = client_order_id if client_order_id != SENTINEL = _body data, _status_code, _headers = place_force_order_with_http_info_impl(user_id, user_secret, , extra) data end |
#place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', expiry_date: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, client_order_id: SENTINEL, extra: {}) ⇒ Object
Place equity order
Places a brokerage order in the specified account. The order could be rejected by the brokerage if it is invalid or if the account does not have sufficient funds.
This endpoint does not compute the impact to the account balance from the order and any potential commissions before submitting the order to the brokerage. If that is desired, you can use the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact).
It’s recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this.
1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 |
# File 'lib/snaptrade/api/trading_api.rb', line 1456 def place_force_order_with_http_info(account_id:, action:, order_type:, time_in_force:, user_id:, user_secret:, universal_symbol_id: SENTINEL, symbol: SENTINEL, trading_session: 'REGULAR', expiry_date: SENTINEL, price: SENTINEL, stop: SENTINEL, units: SENTINEL, notional_value: SENTINEL, client_order_id: SENTINEL, extra: {}) _body = {} _body[:account_id] = account_id if account_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:universal_symbol_id] = universal_symbol_id if universal_symbol_id != SENTINEL _body[:symbol] = symbol if symbol != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:trading_session] = trading_session if trading_session != SENTINEL _body[:expiry_date] = expiry_date if expiry_date != SENTINEL _body[:price] = price if price != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:units] = units if units != SENTINEL _body[:notional_value] = notional_value if notional_value != SENTINEL _body[:client_order_id] = client_order_id if client_order_id != SENTINEL = _body place_force_order_with_http_info_impl(user_id, user_secret, , extra) end |
#place_mleg_order(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) ⇒ Object
Place option order
Places a multi-leg option order. Only supported on certain option trading brokerages. support.snaptrade.com/brokerages has information on brokerage trading support
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 |
# File 'lib/snaptrade/api/trading_api.rb', line 1573 def place_mleg_order(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) _body = {} _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:limit_price] = limit_price if limit_price != SENTINEL _body[:stop_price] = stop_price if stop_price != SENTINEL _body[:price_effect] = price_effect if price_effect != SENTINEL _body[:legs] = legs if legs != SENTINEL mleg_trade_form = _body data, _status_code, _headers = place_mleg_order_with_http_info_impl(user_id, user_secret, account_id, mleg_trade_form, extra) data end |
#place_mleg_order_with_http_info(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) ⇒ Object
Place option order
Places a multi-leg option order. Only supported on certain option trading brokerages. support.snaptrade.com/brokerages has information on brokerage trading support
1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 |
# File 'lib/snaptrade/api/trading_api.rb', line 1601 def place_mleg_order_with_http_info(order_type:, time_in_force:, legs:, user_id:, user_secret:, account_id:, limit_price: SENTINEL, stop_price: SENTINEL, price_effect: SENTINEL, extra: {}) _body = {} _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:limit_price] = limit_price if limit_price != SENTINEL _body[:stop_price] = stop_price if stop_price != SENTINEL _body[:price_effect] = price_effect if price_effect != SENTINEL _body[:legs] = legs if legs != SENTINEL mleg_trade_form = _body place_mleg_order_with_http_info_impl(user_id, user_secret, account_id, mleg_trade_form, extra) end |
#place_order(trade_id:, user_id:, user_secret:, wait_to_confirm: SENTINEL, extra: {}) ⇒ Object
Place checked equity order
Places the previously checked order with the brokerage. The ‘tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder).
It’s recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this.
1714 1715 1716 1717 1718 1719 1720 |
# File 'lib/snaptrade/api/trading_api.rb', line 1714 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_with_http_info(trade_id:, user_id:, user_secret:, wait_to_confirm: SENTINEL, extra: {}) ⇒ Object
Place checked equity order
Places the previously checked order with the brokerage. The ‘tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder).
It’s recommended to trigger a manual refresh of the account after placing an order to ensure the account is up to date. You can use the [manual refresh](/reference/Connections/Connections_refreshBrokerageAuthorization) endpoint for this.
1734 1735 1736 1737 1738 1739 |
# File 'lib/snaptrade/api/trading_api.rb', line 1734 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 |
#preview_crypto_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: {}) ⇒ Object
Preview crypto order
Previews an order using the specified account.
1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 |
# File 'lib/snaptrade/api/trading_api.rb', line 1844 def preview_crypto_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: {}) _body = {} _body[:instrument] = instrument if instrument != SENTINEL _body[:side] = side if side != SENTINEL _body[:type] = type if type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:amount] = amount if amount != SENTINEL _body[:limit_price] = limit_price if limit_price != SENTINEL _body[:stop_price] = stop_price if stop_price != SENTINEL _body[:post_only] = post_only if post_only != SENTINEL _body[:expiration_date] = expiration_date if expiration_date != SENTINEL crypto_order_form = _body data, _status_code, _headers = preview_crypto_order_with_http_info_impl(user_id, user_secret, account_id, crypto_order_form, extra) data end |
#preview_crypto_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: {}) ⇒ Object
Preview crypto order
Previews an order using the specified account.
1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 |
# File 'lib/snaptrade/api/trading_api.rb', line 1878 def preview_crypto_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: {}) _body = {} _body[:instrument] = instrument if instrument != SENTINEL _body[:side] = side if side != SENTINEL _body[:type] = type if type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:amount] = amount if amount != SENTINEL _body[:limit_price] = limit_price if limit_price != SENTINEL _body[:stop_price] = stop_price if stop_price != SENTINEL _body[:post_only] = post_only if post_only != SENTINEL _body[:expiration_date] = expiration_date if expiration_date != SENTINEL crypto_order_form = _body preview_crypto_order_with_http_info_impl(user_id, user_secret, account_id, crypto_order_form, extra) end |
#replace_order(brokerage_order_id:, action:, order_type:, time_in_force:, account_id:, user_id:, user_secret:, price: SENTINEL, symbol: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) ⇒ Object
Replace order
Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order’s brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 |
# File 'lib/snaptrade/api/trading_api.rb', line 2001 def replace_order(brokerage_order_id:, action:, order_type:, time_in_force:, account_id:, user_id:, user_secret:, price: SENTINEL, symbol: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) _body = {} _body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:price] = price if price != SENTINEL _body[:symbol] = symbol if symbol != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:units] = units if units != SENTINEL manual_trade_replace_form = _body data, _status_code, _headers = replace_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_replace_form, extra) data end |
#replace_order_with_http_info(brokerage_order_id:, action:, order_type:, time_in_force:, account_id:, user_id:, user_secret:, price: SENTINEL, symbol: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) ⇒ Object
Replace order
Replaces an existing pending order with a new one. The way this works is brokerage dependent, but usually involves cancelling the existing order and placing a new one. The order’s brokerage_order_id may or may not change, be sure to use the one returned in the response going forward. Only supported on some brokerages
2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 |
# File 'lib/snaptrade/api/trading_api.rb', line 2035 def replace_order_with_http_info(brokerage_order_id:, action:, order_type:, time_in_force:, account_id:, user_id:, user_secret:, price: SENTINEL, symbol: SENTINEL, stop: SENTINEL, units: SENTINEL, extra: {}) _body = {} _body[:brokerage_order_id] = brokerage_order_id if brokerage_order_id != SENTINEL _body[:action] = action if action != SENTINEL _body[:order_type] = order_type if order_type != SENTINEL _body[:time_in_force] = time_in_force if time_in_force != SENTINEL _body[:price] = price if price != SENTINEL _body[:symbol] = symbol if symbol != SENTINEL _body[:stop] = stop if stop != SENTINEL _body[:units] = units if units != SENTINEL manual_trade_replace_form = _body replace_order_with_http_info_impl(account_id, user_id, user_secret, manual_trade_replace_form, extra) end |
#search_cryptocurrency_pair_instruments(user_id:, user_secret:, account_id:, base: SENTINEL, quote: SENTINEL, extra: {}) ⇒ Object
Get crypto pairs
Searches cryptocurrency pairs instruments accessible to the specified account. Both ‘base` and `quote` are optional. Omit both for a full list of cryptocurrency pairs.
2148 2149 2150 2151 2152 2153 |
# File 'lib/snaptrade/api/trading_api.rb', line 2148 def search_cryptocurrency_pair_instruments(user_id:, user_secret:, account_id:, base: SENTINEL, quote: SENTINEL, extra: {}) extra[:base] = base if base != SENTINEL extra[:quote] = quote if quote != SENTINEL data, _status_code, _headers = search_cryptocurrency_pair_instruments_with_http_info_impl(user_id, user_secret, account_id, extra) data end |
#search_cryptocurrency_pair_instruments_with_http_info(user_id:, user_secret:, account_id:, base: SENTINEL, quote: SENTINEL, extra: {}) ⇒ Object
Get crypto pairs
Searches cryptocurrency pairs instruments accessible to the specified account. Both ‘base` and `quote` are optional. Omit both for a full list of cryptocurrency pairs.
2165 2166 2167 2168 2169 |
# File 'lib/snaptrade/api/trading_api.rb', line 2165 def search_cryptocurrency_pair_instruments_with_http_info(user_id:, user_secret:, account_id:, base: SENTINEL, quote: SENTINEL, extra: {}) extra[:base] = base if base != SENTINEL extra[:quote] = quote if quote != SENTINEL search_cryptocurrency_pair_instruments_with_http_info_impl(user_id, user_secret, account_id, extra) end |