trade29.sc.SCBridge.get_flat_to_flat_trade_list#
- SCBridge.get_flat_to_flat_trade_list(key: str) FlatToFlatTradeListResponse #
Gets a list of flat to flat trades.
Gets a list of flat to flat trades. That is, a list of time periods that start and end with flat positions. The list of trades returned depends on the account the chart is set to (that can be viewed in the Trade Window) and whether or not Trade Simulation is turned on (see the Sierra Chart docs for more). The data is fetched is similar to what is seen in Sierra Chart’s
Trade Activity Log
’s Trades tab.- Parameters:
- keystr
The key matching the key given to the SC-dX custom study in Sierra Chart.
- Returns:
Examples
NOTE: This example had
Support Reversals
set toFalse
andAllow Same Entries in Same Direction
set toTrue
in study settings.>>> from trade29.sc import SCBridge, constants >>> bridge = SCBridge() running bridge v0.17.0--------2024/08/07 18:55:04 connecting to sc starting receiver starting sender sc version: 2666, scdx version 208, connection: t29scdx2, keys: xx,signal >>> bridge.submit_order(key = "xx", is_buy = False, quantity = 4, order_type = constants.OrderType.MARKET) >>> # There is now one flat to flat trade ope >>> ret = bridge.get_flat_to_flat_trade_list(key = "xx") >>> ret.as_df() OpenDateTime CloseDateTime TradeType TradeQuantity ... Commission IsTradeClosed Note 0 2024-08-07 18:57:25.733687 1970-01-01 -1 4.0 ... 0.0 1 >>> bridge.submit_order(key = "xx", is_buy = False, quantity = 3, order_type = constants.OrderType.MARKET) >>> # Even after submitting another order, there is not a new flat to flat trade, >>> # as the position has not gone flat yet, instead the old trade's quantity has changed >>> ret = bridge.get_flat_to_flat_trade_list(key = "xx") >>> ret.as_df() OpenDateTime CloseDateTime TradeType TradeQuantity ... Commission IsTradeClosed Note 0 2024-08-07 18:57:25.733687 1970-01-01 -1 7.0 ... 0.0 1 >>> bridge.flatten_and_cancel(key = "xx") >>> # After flattening, the CloseDateTime field is now filled >>> ret = bridge.get_flat_to_flat_trade_list(key = "xx") >>> ret.as_df() OpenDateTime CloseDateTime TradeType ... Commission IsTradeClosed Note 0 2024-08-07 18:57:25.733687 2024-08-07 19:00:11.118950 -1 ... 0.0 1 >>> bridge.submit_order(key = "xx", is_buy = True, quantity = 3, order_type = constants.OrderType.MARKET) >>> # Now when a new position is entered from flat, a new flat to flat trade is on the list >>> ret = bridge.get_flat_to_flat_trade_list(key = "xx") >>> ret.as_df() OpenDateTime CloseDateTime TradeType ... Commission IsTradeClosed Note 0 2024-08-07 18:57:25.733687 2024-08-07 19:00:11.118950 -1 ... 0.0 1 1 2024-08-07 19:02:40.301567 1970-01-01 00:00:00.000000 1 ... 0.0 1 >>> bridge.flatten_and_cancel(key = "xx") >>> ret = bridge.get_flat_to_flat_trade_list(key = "xx") >>> ret.as_df() OpenDateTime CloseDateTime TradeType ... Commission IsTradeClosed Note 0 2024-08-07 18:57:25.733687 2024-08-07 19:00:11.118950 -1 ... 0.0 1 1 2024-08-07 19:02:40.301567 2024-08-07 19:02:55.333461 1 ... 0.0 1