trade29.sc.SCBridge.submit_order#

SCBridge.submit_order(key: str, is_buy: bool, quantity: float, order_type: OrderType = OrderType.MARKET, time_in_force: TimeInForce = TimeInForce.DAY, price1: float = 0, price2: float = 0, attach_orders_sc_trade_window: bool = False, ocos: list[AttachedOrder] = None) SubmitOrderResponse#

Submits an order.

This method submits an order to Sierra Chart.

Parameters:
keystr

The key matching the key given to the SC-dX custom study in Sierra Chart.

is_buybool

If true, order is a buy order, if false, this is a sell order.

quantityfloat

Quantity to buy/sell.

order_typeOrderType, default MARKET

The type of order to submit.

time_in_forceTimeInForce, default DAY

The time in force setting for the order (and attached orders).

price1float, default 0

Refer to documentation for OrderType for what (if anything) needs to be supplied for price1.

price2float, default 0

Refer to documentation for OrderType for what (if anything) needs to be supplied for price2.

attach_orders_sc_trade_windowbool, default False

Whether or not to use the Sierra Chart Trade Window’s attached orders.

ocoslist of :class:`~trade29.sc.AttachedOrder`s , default None

List of orders to attach this this order. The list cannot be longer than 5. Note that the quantities of all attached order groups must add up to the quantity of the parent order. If they dont add up, their quantities will be set to equal parts of the parent order quantity.

Returns:
SubmitOrderResponse

A response containing all order groups created in the request.

Warning

Sierra Chart has a maximum position that has to be set through ACSIL. Any orders that would result in exceeding this maximum position will be rejected by Sierra Chart. Users can set this maximum position through the study settings.

Examples

>>> from trade29.sc import SCBridge, AttachedOrder, constants
>>> bridge = SCBridge()
# Place a market order to buy 10 shares
>>> ret = bridge.submit_order('xx', True, 10)
# Get the order ID
>>> ret.order_groups[0].parent_id
40
# Now place a limit order to sell 5 shares with a limit of 10
>>> ret = bridge.submit_order('xx', False, 5, order_type = constants.OrderType.LIMIT, price1=10)
# Get the order ID
>>> ret.order_groups[0].parent_id
41
>>> bridge.flatten_and_cancel('xx')
# Now place a market order with a stop offset by 10
>>> ret = bridge.submit_order('xx', True, 10, ocos=[AttachedOrder(quantity=10, stop_offset=10)])
# Print the info on the order group
>>> print(ret.order_groups[0])
Parent ID: 42
No limit order child
Stop ID: 43