-1

Does someone know if it's possible to open multiple positions with only a single data feed? I am trying to do a second buy whilst in a position, which doesn't seem to be possible.

Nobody seems to adress this issue. Does anyone have any experience with Backtrader and have any input?

yebowo
  • 3
  • 1
  • Are you referring to position hedging (e.g. long and short at the same time)? This is not possible, as the [Position Class](https://www.backtrader.com/docu/position/) doesn't offer a direction attribute. – Joël Brigate Nov 07 '21 at 20:29

1 Answers1

1

If you are just trying to buy more stock to add to your position, then yes, you should be able to do this and if you cannot recheck your strategy code in next.

If you are trying to track two separate positions of the same data...

One cannot have two separate positions in the same data feed. You may trade additional positions if you like but they will be combined in Backtrader. Even if you use two strategies you will still have one combined broker.

The reason for this is to simulate as near as possible real world conditions. If you have a brokerage account you most likely would have just one postion. (I know there are exceptions)

One solution would be to track your trading manually in a dictionary trades that result from different signals/sub-strategies. It's a bit more tedious to develop but very doable.

run-out
  • 3,114
  • 1
  • 9
  • 25
  • I would like to create a hedge strategy using multiple accounts where a long and a short position can exist at the same time. Is there a way to test this with backtrader? You mentioned keeping dictionary trades but I don't quite understand how I could code this. An example would be awesome! Thanks in advance – AGI_rev Apr 12 '22 at 03:24
  • @run-out I can't help but wonder what you mean by "one cannot have 2 seperate positions in the same data feed." Then what is the `MultiTrade` example? https://www.backtrader.com/blog/posts/2015-10-05-multitrades/multitrades/ – LeggoMaEggo Dec 16 '22 at 09:40
  • 1
    @LeggoMaEggo The question is about hedging. ie. Having both long and short positions at the same time, I see in the multi-trades example, you cannot have both long and short positions but multiple trades in the same direction. In the example, the short position is closed before opening the long position and vice versa. – Sumeet Jul 07 '23 at 10:47