Does vectorbt support for pairs trading

Viewed 20

I'd like to use vectorbt to backtest pairs trading strategies and need a way for an Indicator/Signal to go long on one pair and short on the other when the Indicator/Signal is true. From what I've seen the portfolio opens up a position for both pairs (i.e. both go long) when I need equal and opposite positions to be opened.

Example flow:

  1. Start portfolio with two pairs BTCUSD & ETHUSD
  2. The two pairs diverge beyond a given threshold. At this point the Indicator/Signal fires
  3. What I'd like is to create a SHORT position on BTCUSD & a LONG position on ETHUSD at the same time. From what I've seen by default vectorbt will either open a LONG on both pairs or a SHORT on both pairs.
  4. When the pairs converge close both positions

lose both positions.

It's step 3 above where I'm asking for help/guidance on what to do. I'm hoping there's an callback I can hook into or a way to target a given position direction at a given pair.

Thanks

1 Answers
Related