trade29.sc.SCBridge.flatten_and_cancel#
- SCBridge.flatten_and_cancel(key: str) FlattenAndCancelResponse #
Flattens position and cancels all active orders for chart with given key.
- Parameters:
- keystr
The key matching the key given to the SC-dX custom study in Sierra Chart.
- Returns:
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) # 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)] # Now flatten and cancel position >>> bridge.flatten_and_cancel('xx') # You can verify that the position is flat and the open limit order is now closed in Sierra Chart