For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Trace max float profit of long/short order before it's closed
A Former User last edited by
hi all, I want to trace the max float profit of a long/short order since it's completed until it is closed. As long order for example, the long order is created as mainside, and there are lowside sell StopTrail order and highside sell Limit order. How can I trace the float profit history of the long order. And the float profit =(current_bar_price - executed_price) x executed_size. I need a clean and elegant manner to realize it. Thx!
if long_signal: if self.position.size < 0: self.order = self.close() else: mainside = self.buy(size = default_size,transmit=False) lowside = self.sell(size=lowside_sell_size,exectype=bt.Order.StopTrail,transmit=False, parent=mainside,trailpercent=0.05) highside = self.sell(price=highside_sell_price, size=highside_sell_size, exectype=bt.Order.Limit, transmit=True, parent=mainside)