trade29.sc.SCBridge.get_position_status#
- SCBridge.get_position_status(key: str) PositionUpdateResponse #
Gets the status of the account position; including quantity, average price, and open profit/loss.
Given a key, this method gets information on the account position from the same chart on which the SC-dX study with the matching key is applied.
- Parameters:
- keystr
The key matching the key given to the SC-dX custom study in Sierra Chart.
- Returns:
Examples
>>> from trade29.sc import SCBridge >>> bridge = SCBridge() running bridge v0.17.0--------2024/08/07 16:16:34 connecting to sc starting receiver starting sender sc version: 2666, scdx version 208, connection: t29scdx2, keys: xx,signal >>> ret = bridge.get_position_status(key = "xx") >>> ret.position_quantity 10.0 >>> ret.average_price 2395.900035701692 >>> ret.open_profit_loss -5.499380454421043 >>> bridge.flatten_and_cancel(key = "xx") # Check that position is now flat >>> ret = bridge.get_position_status(key = "xx") >>> ret.position_quantity 0.0 >>> ret.average_price 0.0 >>> ret.open_profit_loss 0.0