For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Questions on tradeid



  • Hi
    I have read the tradeid mentioned in live trading but I do not fully understand.
    The aim is to trade live using IB. And I am trying to implement a dynamic change of stop loss.
    I sent the order in using a parent order with stop loss and limit. Then I want to change the stoploss and limit later as the trade goes on.

    I have not been able to successfully do this as cancelling the old stoploss and then adding a new one, does not tag it to the open trade. The stop loss is like a whole new order on its own.

    I have searched through the forum and find maybe I can do a tradeid = tradeid in:

    self.cancel(self.long_stoploss)
    self.long_stoploss = self.sell(tradeid=tradeid, exectype=bt.Order.StopTrail, size=self.position.size, trailpercent=0.0005, transmit=False, valid=None)
    
    self.long_stoplimit = self.sell(exectype=bt.Order.StopTrailLimit, size=self.position.size, trailpercent=0.0005, plimit=plimit, parent=self.long_stoploss, transmit=True, valid=None)
    

    But can this be taken to live trading in IB as something that was mentioned in the docs about tradeid?



  • Re: Questions on tradeid

    this is the docs: What I want to do is to tag the new stop loss to the open position. If there are other ways of implementation, kindly share with me! Thanks!

    IBBroker - Trading Live
    Note

    Following a request a tradeid functionality was implemented in the broker simulation available in backtrader. This allows to keep track of trades being executed in paralled on the same asset correctly allocating commissions to the appropriate tradeid

    Such notion is not supported in this live broker because commissions are reported by the broker at times at which it would be impossible to separate them for the different tradeid values.

    tradeid can still be specified but it makes no longer sense.


Log in to reply
 

});