Class: SnapTrade::TradingApi

Inherits:
Object
  • Object
show all
Defined in:
lib/snaptrade/api/trading_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_clientObject

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.

Parameters:

  • brokerage_order_id (String)

    Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • body (AccountInformationGetUserAccountOrderDetailRequest)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



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
   = _body
  data, _status_code, _headers = cancel_order_with_http_info_impl(user_id, user_secret, , , 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.

Parameters:

  • brokerage_order_id (String)

    Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • body (AccountInformationGetUserAccountOrderDetailRequest)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



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
   = _body
  cancel_order_with_http_info_impl(user_id, user_secret, , , 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.

Parameters:

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • instrument_symbol (String)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



153
154
155
156
# File 'lib/snaptrade/api/trading_api.rb', line 153

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, , 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.

Parameters:

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • instrument_symbol (String)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



167
168
169
# File 'lib/snaptrade/api/trading_api.rb', line 167

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, , 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 for more information on which brokerages support this endpoint.

Parameters:

  • order_type (MlegOrderTypeStrict)

    The type of order to place.

  • time_in_force (TimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - IOC - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.

  • legs (Array<MlegLeg>)
  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • limit_price (Float) (defaults to: SENTINEL)

    The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT.

  • stop_price (Float) (defaults to: SENTINEL)

    The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT.

  • price_effect (MlegPriceEffectStrict) (defaults to: SENTINEL)
  • body (MlegTradeForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/snaptrade/api/trading_api.rb', line 271

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, , 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 for more information on which brokerages support this endpoint.

Parameters:

  • order_type (MlegOrderTypeStrict)

    The type of order to place.

  • time_in_force (TimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - IOC - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.

  • legs (Array<MlegLeg>)
  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • limit_price (Float) (defaults to: SENTINEL)

    The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT.

  • stop_price (Float) (defaults to: SENTINEL)

    The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT.

  • price_effect (MlegPriceEffectStrict) (defaults to: SENTINEL)
  • body (MlegTradeForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



300
301
302
303
304
305
306
307
308
309
310
# File 'lib/snaptrade/api/trading_api.rb', line 300

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, , 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. Please note that the Trade object returned expires after 5 minutes. Any order placed using an expired Trade will be rejected.

Parameters:

  • account_id (String)

    Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.

  • action (ActionStrict)

    The action describes the intent or side of a trade. This is either BUY or SELL.

  • universal_symbol_id (String)

    Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls.

  • order_type (OrderTypeStrict)

    The type of order to place. - For Limit and StopLimit orders, the price field is required. - For Stop and StopLimit orders, the stop field is required.

  • time_in_force (TimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - IOC - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.

  • user_id (String)
  • user_secret (String)
  • price (Float) (defaults to: SENTINEL)

    The limit price for Limit and StopLimit orders.

  • stop (Float) (defaults to: SENTINEL)

    The price at which a stop order is triggered for Stop and StopLimit orders.

  • units (Float) (defaults to: SENTINEL)
  • notional_value (ManualTradeFormNotionalValue) (defaults to: SENTINEL)
  • body (ManualTradeForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/snaptrade/api/trading_api.rb', line 418

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] =  if  != 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. Please note that the Trade object returned expires after 5 minutes. Any order placed using an expired Trade will be rejected.

Parameters:

  • account_id (String)

    Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.

  • action (ActionStrict)

    The action describes the intent or side of a trade. This is either BUY or SELL.

  • universal_symbol_id (String)

    Unique identifier for the symbol within SnapTrade. This is the ID used to reference the symbol in SnapTrade API calls.

  • order_type (OrderTypeStrict)

    The type of order to place. - For Limit and StopLimit orders, the price field is required. - For Stop and StopLimit orders, the stop field is required.

  • time_in_force (TimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - IOC - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.

  • user_id (String)
  • user_secret (String)
  • price (Float) (defaults to: SENTINEL)

    The limit price for Limit and StopLimit orders.

  • stop (Float) (defaults to: SENTINEL)

    The price at which a stop order is triggered for Stop and StopLimit orders.

  • units (Float) (defaults to: SENTINEL)
  • notional_value (ManualTradeFormNotionalValue) (defaults to: SENTINEL)
  • body (ManualTradeForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/snaptrade/api/trading_api.rb', line 451

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] =  if  != 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 Note: These are derived values and are not suitable for trading purposes.

Parameters:

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • symbol (String)

    The OCC-formatted option symbol.

  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



559
560
561
562
# File 'lib/snaptrade/api/trading_api.rb', line 559

def (user_id:, user_secret:, account_id:, symbol:, extra: {})
  data, _status_code, _headers = (user_id, user_secret, , 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 Note: These are derived values and are not suitable for trading purposes.

Parameters:

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • symbol (String)

    The OCC-formatted option symbol.

  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



574
575
576
# File 'lib/snaptrade/api/trading_api.rb', line 574

def (user_id:, user_secret:, account_id:, symbol:, extra: {})
  (user_id, user_secret, , 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.

Parameters:

  • user_id (String)
  • user_secret (String)
  • symbols (String)

    List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator. Maximum of 10 values allowed

  • account_id (String)
  • use_ticker (Boolean) (defaults to: SENTINEL)

    Should be set to True if symbols are comprised of tickers. Defaults to False if not provided.

  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



679
680
681
682
683
# File 'lib/snaptrade/api/trading_api.rb', line 679

def (user_id:, user_secret:, symbols:, account_id:, use_ticker: SENTINEL, extra: {})
  extra[:use_ticker] = use_ticker if use_ticker != SENTINEL
  data, _status_code, _headers = (user_id, user_secret, symbols, , 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.

Parameters:

  • user_id (String)
  • user_secret (String)
  • symbols (String)

    List of Universal Symbol IDs or tickers to get quotes for. When providing multiple values, use a comma as separator. Maximum of 10 values allowed

  • account_id (String)
  • use_ticker (Boolean) (defaults to: SENTINEL)

    Should be set to True if symbols are comprised of tickers. Defaults to False if not provided.

  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



701
702
703
704
# File 'lib/snaptrade/api/trading_api.rb', line 701

def (user_id:, user_secret:, symbols:, account_id:, use_ticker: SENTINEL, extra: {})
  extra[:use_ticker] = use_ticker if use_ticker != SENTINEL
  (user_id, user_secret, symbols, , 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). Only supported on certain brokerages. Please refer to the brokerage trading support page 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.

Parameters:

  • type (ManualTradeFormComplexType)

    The complex order type. - OCO: One Cancels the Other — two peer orders. - OTO: One Triggers the Other — a trigger order and a conditional order. - OTOCO: One Triggers a One Cancels the Other — a trigger order and two peer orders.

  • orders (Array<ComplexOrderLeg>)

    The orders that make up the complex order. Required counts and roles per type: - OCO: exactly 2 orders, both PEER - OTO: exactly 2 orders, one TRIGGER and one CONDITIONAL - OTOCO: exactly 3 orders, one TRIGGER and two PEER

  • account_id (String)

    The ID of the account to execute the trade on.

  • user_id (String)
  • user_secret (String)
  • client_order_id (String) (defaults to: SENTINEL)
  • body (ManualTradeFormComplex)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



812
813
814
815
816
817
818
819
820
# File 'lib/snaptrade/api/trading_api.rb', line 812

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(, 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). Only supported on certain brokerages. Please refer to the brokerage trading support page 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.

Parameters:

  • type (ManualTradeFormComplexType)

    The complex order type. - OCO: One Cancels the Other — two peer orders. - OTO: One Triggers the Other — a trigger order and a conditional order. - OTOCO: One Triggers a One Cancels the Other — a trigger order and two peer orders.

  • orders (Array<ComplexOrderLeg>)

    The orders that make up the complex order. Required counts and roles per type: - OCO: exactly 2 orders, both PEER - OTO: exactly 2 orders, one TRIGGER and one CONDITIONAL - OTOCO: exactly 3 orders, one TRIGGER and two PEER

  • account_id (String)

    The ID of the account to execute the trade on.

  • user_id (String)
  • user_secret (String)
  • client_order_id (String) (defaults to: SENTINEL)
  • body (ManualTradeFormComplex)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



840
841
842
843
844
845
846
847
# File 'lib/snaptrade/api/trading_api.rb', line 840

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(, 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.

Parameters:

  • instrument (CryptoTradingInstrument)
  • side (ActionStrict)

    The action describes the intent or side of a trade. This is either BUY or SELL.

  • type (CryptoOrderFormType)

    The type of order to place.

  • time_in_force (CryptoOrderFormTimeInForce)

    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.

  • amount (Float)

    The amount of the base currency to buy or sell.

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • limit_price (Float) (defaults to: SENTINEL)

    The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.

  • stop_price (Float) (defaults to: SENTINEL)

    The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.

  • post_only (Boolean) (defaults to: SENTINEL)

    Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.

  • expiration_date (Time) (defaults to: SENTINEL)

    The expiration date of the order. Required if the time_in_force is GTD.

  • body (CryptoOrderForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
# File 'lib/snaptrade/api/trading_api.rb', line 957

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, , 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.

Parameters:

  • instrument (CryptoTradingInstrument)
  • side (ActionStrict)

    The action describes the intent or side of a trade. This is either BUY or SELL.

  • type (CryptoOrderFormType)

    The type of order to place.

  • time_in_force (CryptoOrderFormTimeInForce)

    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.

  • amount (Float)

    The amount of the base currency to buy or sell.

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • limit_price (Float) (defaults to: SENTINEL)

    The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.

  • stop_price (Float) (defaults to: SENTINEL)

    The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.

  • post_only (Boolean) (defaults to: SENTINEL)

    Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.

  • expiration_date (Time) (defaults to: SENTINEL)

    The expiration date of the order. Required if the time_in_force is GTD.

  • body (CryptoOrderForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
# File 'lib/snaptrade/api/trading_api.rb', line 992

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, , 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.

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 endpoint for this.

Parameters:

  • account_id (String)

    Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.

  • action (ActionStrictWithOptions)

    The action describes the intent or side of a trade. This is either BUY or SELL for Equity symbols or BUY_TO_OPEN, BUY_TO_CLOSE, SELL_TO_OPEN or SELL_TO_CLOSE for Options.

  • order_type (OrderTypeStrict)

    The type of order to place. - For Limit and StopLimit orders, the price field is required. - For Stop and StopLimit orders, the stop field is required.

  • time_in_force (ManualTradePlaceTimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - 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 expiry_date, which is required. Not available for market orders. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.

  • user_id (String)
  • user_secret (String)
  • universal_symbol_id (String) (defaults to: SENTINEL)

    The universal symbol ID of the security to trade. Must be 'null' if symbol is provided, otherwise must be provided.

  • symbol (String) (defaults to: SENTINEL)

    The security's trading ticker symbol. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'.

  • trading_session (TradingSession) (defaults to: 'REGULAR')

    The trading session for the order. This field indicates which market session the order will be placed in. This is only available for certain brokerages. Defaults to REGULAR. Here are the supported values: - REGULAR - Regular trading hours. - EXTENDED - Extended trading hours.

  • expiry_date (Time) (defaults to: SENTINEL)

    Timestamp in ISO 8601 format indicating when the order expires. Required when time_in_force is GTD. Include a timezone offset or Z for UTC; if no timezone is provided, UTC is assumed. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.

  • price (Float) (defaults to: SENTINEL)

    The limit price for Limit and StopLimit orders.

  • stop (Float) (defaults to: SENTINEL)

    The price at which a stop order is triggered for Stop and StopLimit orders.

  • units (Float) (defaults to: SENTINEL)

    For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be null if notional_value is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).

  • notional_value (ManualTradeFormNotionalValue) (defaults to: SENTINEL)
  • client_order_id (String) (defaults to: SENTINEL)
  • body (ManualTradeFormWithOptions)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
# File 'lib/snaptrade/api/trading_api.rb', line 1121

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] =  if  != 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
  manual_trade_form_with_options = _body
  data, _status_code, _headers = place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, 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.

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 endpoint for this.

Parameters:

  • account_id (String)

    Unique identifier for the connected brokerage account. This is the UUID used to reference the account in SnapTrade.

  • action (ActionStrictWithOptions)

    The action describes the intent or side of a trade. This is either BUY or SELL for Equity symbols or BUY_TO_OPEN, BUY_TO_CLOSE, SELL_TO_OPEN or SELL_TO_CLOSE for Options.

  • order_type (OrderTypeStrict)

    The type of order to place. - For Limit and StopLimit orders, the price field is required. - For Stop and StopLimit orders, the stop field is required.

  • time_in_force (ManualTradePlaceTimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - 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 expiry_date, which is required. Not available for market orders. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.

  • user_id (String)
  • user_secret (String)
  • universal_symbol_id (String) (defaults to: SENTINEL)

    The universal symbol ID of the security to trade. Must be 'null' if symbol is provided, otherwise must be provided.

  • symbol (String) (defaults to: SENTINEL)

    The security's trading ticker symbol. If 'symbol' is provided, then 'universal_symbol_id' must be 'null'.

  • trading_session (TradingSession) (defaults to: 'REGULAR')

    The trading session for the order. This field indicates which market session the order will be placed in. This is only available for certain brokerages. Defaults to REGULAR. Here are the supported values: - REGULAR - Regular trading hours. - EXTENDED - Extended trading hours.

  • expiry_date (Time) (defaults to: SENTINEL)

    Timestamp in ISO 8601 format indicating when the order expires. Required when time_in_force is GTD. Include a timezone offset or Z for UTC; if no timezone is provided, UTC is assumed. GTD orders are only available on certain brokerages. Visit https://support.snaptrade.com/brokerages for brokerage support.

  • price (Float) (defaults to: SENTINEL)

    The limit price for Limit and StopLimit orders.

  • stop (Float) (defaults to: SENTINEL)

    The price at which a stop order is triggered for Stop and StopLimit orders.

  • units (Float) (defaults to: SENTINEL)

    For Equity orders, this represents the number of shares for the order. This can be a decimal for fractional orders. Must be null if notional_value is provided. If placing an Option order, this field represents the number of contracts to buy or sell. (e.g., 1 contract = 100 shares).

  • notional_value (ManualTradeFormNotionalValue) (defaults to: SENTINEL)
  • client_order_id (String) (defaults to: SENTINEL)
  • body (ManualTradeFormWithOptions)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
# File 'lib/snaptrade/api/trading_api.rb', line 1166

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] =  if  != 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
  manual_trade_form_with_options = _body
  place_force_order_with_http_info_impl(user_id, user_secret, manual_trade_form_with_options, 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. https://support.snaptrade.com/brokerages has information on brokerage trading support

Parameters:

  • order_type (MlegOrderTypeStrict)

    The type of order to place.

  • time_in_force (TimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - IOC - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.

  • legs (Array<MlegLeg>)
  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • limit_price (Float) (defaults to: SENTINEL)

    The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT.

  • stop_price (Float) (defaults to: SENTINEL)

    The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT.

  • price_effect (MlegPriceEffectStrict) (defaults to: SENTINEL)
  • body (MlegTradeForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
# File 'lib/snaptrade/api/trading_api.rb', line 1283

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, , 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. https://support.snaptrade.com/brokerages has information on brokerage trading support

Parameters:

  • order_type (MlegOrderTypeStrict)

    The type of order to place.

  • time_in_force (TimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - IOC - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.

  • legs (Array<MlegLeg>)
  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • limit_price (Float) (defaults to: SENTINEL)

    The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT.

  • stop_price (Float) (defaults to: SENTINEL)

    The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT.

  • price_effect (MlegPriceEffectStrict) (defaults to: SENTINEL)
  • body (MlegTradeForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
# File 'lib/snaptrade/api/trading_api.rb', line 1311

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, , 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. If you prefer to place the order without checking for impact first, you can use the place order endpoint.

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 endpoint for this.

Parameters:

  • trade_id (String)

    Obtained from calling the check order impact endpoint

  • user_id (String)
  • user_secret (String)
  • wait_to_confirm (Boolean) (defaults to: SENTINEL)

    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.

  • body (ValidatedTradeBody)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1424
1425
1426
1427
1428
1429
1430
# File 'lib/snaptrade/api/trading_api.rb', line 1424

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. If you prefer to place the order without checking for impact first, you can use the place order endpoint.

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 endpoint for this.

Parameters:

  • trade_id (String)

    Obtained from calling the check order impact endpoint

  • user_id (String)
  • user_secret (String)
  • wait_to_confirm (Boolean) (defaults to: SENTINEL)

    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.

  • body (ValidatedTradeBody)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1444
1445
1446
1447
1448
1449
# File 'lib/snaptrade/api/trading_api.rb', line 1444

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.

Parameters:

  • instrument (CryptoTradingInstrument)
  • side (ActionStrict)

    The action describes the intent or side of a trade. This is either BUY or SELL.

  • type (CryptoOrderFormType)

    The type of order to place.

  • time_in_force (CryptoOrderFormTimeInForce)

    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.

  • amount (Float)

    The amount of the base currency to buy or sell.

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • limit_price (Float) (defaults to: SENTINEL)

    The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.

  • stop_price (Float) (defaults to: SENTINEL)

    The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.

  • post_only (Boolean) (defaults to: SENTINEL)

    Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.

  • expiration_date (Time) (defaults to: SENTINEL)

    The expiration date of the order. Required if the time_in_force is GTD.

  • body (CryptoOrderForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
# File 'lib/snaptrade/api/trading_api.rb', line 1554

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, , 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.

Parameters:

  • instrument (CryptoTradingInstrument)
  • side (ActionStrict)

    The action describes the intent or side of a trade. This is either BUY or SELL.

  • type (CryptoOrderFormType)

    The type of order to place.

  • time_in_force (CryptoOrderFormTimeInForce)

    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.

  • amount (Float)

    The amount of the base currency to buy or sell.

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • limit_price (Float) (defaults to: SENTINEL)

    The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT or TAKE_PROFIT_LIMIT.

  • stop_price (Float) (defaults to: SENTINEL)

    The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT, TAKE_PROFIT_MARKET or TAKE_PROFIT_LIMIT.

  • post_only (Boolean) (defaults to: SENTINEL)

    Valid and required only for order type LIMIT. If true orders that would be filled immediately are rejected to avoid incurring TAKER fees.

  • expiration_date (Time) (defaults to: SENTINEL)

    The expiration date of the order. Required if the time_in_force is GTD.

  • body (CryptoOrderForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
# File 'lib/snaptrade/api/trading_api.rb', line 1588

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, , 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

Parameters:

  • brokerage_order_id (String)

    Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.

  • action (ActionStrictWithOptions)

    The action describes the intent or side of a trade. This is either BUY or SELL for Equity symbols or BUY_TO_OPEN, BUY_TO_CLOSE, SELL_TO_OPEN or SELL_TO_CLOSE for Options.

  • order_type (OrderTypeStrict)

    The type of order to place. - For Limit and StopLimit orders, the price field is required. - For Stop and StopLimit orders, the stop field is required.

  • time_in_force (TimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - IOC - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.

  • account_id (String)

    The ID of the account to execute the trade on.

  • user_id (String)
  • user_secret (String)
  • price (Float) (defaults to: SENTINEL)

    The limit price for Limit and StopLimit orders.

  • symbol (String) (defaults to: SENTINEL)

    The security's trading ticker symbol. Use the OCC symbol to replace an option order.

  • stop (Float) (defaults to: SENTINEL)

    The price at which a stop order is triggered for Stop and StopLimit orders.

  • units (Float) (defaults to: SENTINEL)
  • body (ManualTradeReplaceForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
# File 'lib/snaptrade/api/trading_api.rb', line 1711

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(, 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

Parameters:

  • brokerage_order_id (String)

    Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.

  • action (ActionStrictWithOptions)

    The action describes the intent or side of a trade. This is either BUY or SELL for Equity symbols or BUY_TO_OPEN, BUY_TO_CLOSE, SELL_TO_OPEN or SELL_TO_CLOSE for Options.

  • order_type (OrderTypeStrict)

    The type of order to place. - For Limit and StopLimit orders, the price field is required. - For Stop and StopLimit orders, the stop field is required.

  • time_in_force (TimeInForceStrict)

    The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - Day - Day. The order is valid only for the trading day on which it is placed. - GTC - Good Til Canceled. The order is valid until it is executed or canceled. - FOK - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - IOC - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.

  • account_id (String)

    The ID of the account to execute the trade on.

  • user_id (String)
  • user_secret (String)
  • price (Float) (defaults to: SENTINEL)

    The limit price for Limit and StopLimit orders.

  • symbol (String) (defaults to: SENTINEL)

    The security's trading ticker symbol. Use the OCC symbol to replace an option order.

  • stop (Float) (defaults to: SENTINEL)

    The price at which a stop order is triggered for Stop and StopLimit orders.

  • units (Float) (defaults to: SENTINEL)
  • body (ManualTradeReplaceForm)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
# File 'lib/snaptrade/api/trading_api.rb', line 1745

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(, 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.

Parameters:

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • base (String) (defaults to: SENTINEL)
  • quote (String) (defaults to: SENTINEL)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1858
1859
1860
1861
1862
1863
# File 'lib/snaptrade/api/trading_api.rb', line 1858

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, , 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.

Parameters:

  • user_id (String)
  • user_secret (String)
  • account_id (String)
  • base (String) (defaults to: SENTINEL)
  • quote (String) (defaults to: SENTINEL)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



1875
1876
1877
1878
1879
# File 'lib/snaptrade/api/trading_api.rb', line 1875

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, , extra)
end