This one is different from the previous entries. Instead of a long-only portfolio with different allocation rules, notebook 4 implements a proper dollar-neutral pair trade: long Texas Instruments (TXN), short Kenvue (KVUE), with the position sizes adjusted to neutralise the dollar exposure.
I will be upfront — this strategy lost money in the backtest. But the code pattern is genuinely useful.
The Strategy
A dollar-neutral pair trade means your long and short positions are equal in dollar value. You make money when the long outperforms the short, regardless of market direction — at least in theory.
TXN and KVUE were chosen because they have an OLS regression-derived hedge ratio of 1.135. That means for every $1 long in TXN, you short $1.135 in KVUE to keep the book neutral.
long = ti.Portfolio("long_txn", [
ti.Select.All(), ti.Weigh.Equally(), ti.Action.Rebalance(),
], ["TXN"])
short = ti.Portfolio("short_kvue", [
ti.Select.All(), ti.Weigh.Equally(short=True), ti.Action.Rebalance(),
], ["KVUE"])
RATIO = 1.135
long_book = 1.0 / (1.0 + RATIO) # ~46.8%
short_book = RATIO / (1.0 + RATIO) # ~53.2%
dollar_neutral = ti.Portfolio("dollar_neutral", [
ti.Signal.Monthly(),
ti.Select.All(),
ti.Weigh.Ratio(weights={"long_txn": long_book, "short_kvue": short_book}),
ti.Action.Rebalance(),
], [long, short])
Weigh.Equally(short=True) makes the weights negative for the short leg. The parent portfolio then controls what fraction of capital goes to each child.
Results (Sep 2023–Dec 2024)
sharpe -0.326
calmar 0.147
sortino -0.435
max_drawdown -0.190
cagr -0.028
total_return -0.037
final_value 9631.559
total_fee 2.567
rebalance_count 15
The portfolio lost about 3.7% over 15 months. Compared to the baselines:
dollar_neutral txn_only txn_bil_5050
sharpe -0.326 0.379 0.585
max_drawdown -0.190 -0.165 -0.083
cagr -0.028 0.110 0.112
final_value 9631.559 11486.969 11514.611
total_fee 2.567 0.222 0.452
Just holding TXN outperformed. Even a simple 50/50 TXN + BIL portfolio did better.
Why It Failed
KVUE was only listed in September 2023 (it was spun off from Johnson & Johnson), so the backtest window is very short — only 15 months. A hedge ratio derived from OLS on 15 months of data is not reliable.
Also, KVUE underperformed significantly over this period — its price fell while TXN held relatively steady. In a short position that should help, but the hedge ratio was calibrated wrong. Instead of profiting from KVUE's weakness, the short position's sizing worked against the pair.
Pair trading is one of those strategies that looks elegant on paper but has a lot of hidden complexity: finding pairs that are actually cointegrated, maintaining the hedge ratio as relationships change, dealing with borrow costs for the short. The backtest does not include borrow costs, which would make the results even worse.
What I Found Useful
Even though the strategy lost money, the parent/child portfolio architecture in TiPortfolio is clean for this pattern. You define the long and short legs independently, then the parent decides the capital split. It is easy to extend — you could have multiple long legs, multiple short legs, or dynamic hedge ratios.
I plan to test this pattern with a longer history and a better-cointegrated pair. TXN/KVUE was a bit of an arbitrary choice.
My Take
Dollar-neutral pair trading is not for retail portfolios unless you really know what you are doing. The short side adds complexity, borrow costs, and the risk of being squeezed on the position.
For most people, the simpler long-only strategies from the earlier notebooks are a better starting point.
Next I look at beta-neutral strategy, which tries to remove market exposure in a different way.
This Series
- Part 1: Fixed Ratio Rebalancing
- Part 2: Volatility Targeting
- Part 3: VIX Regime Switching
- Part 4: Dollar-Neutral Pair Trade ← you are here
- Part 5: Beta-Neutral Dynamic Strategy
- Part 6: Auto Investment Plan (DCA)