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

tradeid - multiple strategies on same symbol



  • i have a broker that is utilizing multiple strategies and multiple symbols. Some of these strategies might also utilize the same symbols to trade.

    The question is if while using tradeid when I open the trade clearly i need to have a buy order such as :
    self.buy(data=data-4-this-order, size=size, tradeid=current_id)

    what is not clear, when I close the trade using self.close do I need to also include the data? IE
    self.close(data=data-4-this-order, tradeid=current_id)

    am I incorrect in thinking that I should be able to use self.close() with just those two bits of info and no mater how many shares on on that particular symbol from other strategies, it will close just the shares for the strategy that is placing the order for that matching tradeid?


  • administrators

    This was already answered in another post and your assumption is nowhere to be found that things are separated by strategy.

    The broker is a single account broker. Anything you do, you do it on a single account. Positions will be closed on that account and tradeid is just a marker for the separation of an artificial thing which is a Trade (a collection of operations)

    @blonc said in tradeid - multiple strategies on same symbol:

    do I need to also include the data?

    If you don't, the 1st data in the system will be used. This is in the documentation.


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.