MSTR-BTC Pairs Trading Strategy
MSTR-BTC Pairs Trading Strategy
Strategy Overview
Here’s a video explaining our MSTR-BTC pairs trading strategy:
This trading strategy exploits the statistical relationship between MicroStrategy (MSTR) stock and Bitcoin (BTC). Since MicroStrategy has adopted a strategy of holding substantial Bitcoin reserves on its balance sheet, the two assets demonstrate a high correlation while occasionally experiencing temporary price divergences. The strategy aims to capitalize on these divergences through pairs trading techniques.
Key Components
- Assets: MicroStrategy (MSTR) and Bitcoin (BTC)
- Relationship: Statistical arbitrage based on price ratio mean-reversion
- Method: Z-score trading signals with varying thresholds
- Time Frame: Daily trading (based on daily price data)
- Market Approach: Market-neutral strategy that can work in various market conditions
Data Analysis
MSTR and BTC Price Relationship
The relationship between MSTR and BTC prices forms the foundation of our pairs trading strategy. The chart above shows the price trends of both assets with MSTR on the left axis and BTC on the right axis. Below you can see the Z-score that drives our trading signals:
Statistical Relationship Analysis
The key metrics that validate our pairs trading approach:
Metric | Value | |
---|---|---|
0 | Correlation Coefficient | 0.7225 |
1 | Beta (MSTR to BTC) | 1.3944 |
2 | Average Price Ratio | 0.0022 |
3 | Price Ratio StdDev | 0.0009 |
4 | ADF Test p-value | 0.8469 (Non-stationary) |
Trade Entry and Exit Mechanism
Z-Score Calculation
The core of our pairs trading strategy revolves around a statistical measure called the Z-score. This metric quantifies how far the MSTR/BTC price ratio deviates from its historical mean in terms of standard deviations:
We first calculate the daily ratio between MSTR and BTC prices:
'Ratio'] = data['MSTR'] / data['BTC'] data[
Then we calculate a 20-day moving average and standard deviation of this ratio:
'Ratio_MA'] = data['Ratio'].rolling(window=20).mean() data['Ratio_STD'] = data['Ratio'].rolling(window=20).std() data[
Finally, we compute the Z-score as the number of standard deviations the current ratio is from its 20-day moving average:
'Z_Score'] = (data['Ratio'] - data['Ratio_MA']) / data['Ratio_STD'] data[
Entry Conditions
Our strategy generates trading signals based on the Z-score crossing specific thresholds:
When Z-score falls below negative threshold (-0.5, -1.0, etc.): This indicates MSTR is relatively undervalued compared to BTC. We enter a position going long MSTR and short BTC.
When Z-score rises above positive threshold (0.5, 1.0, etc.): This indicates MSTR is relatively overvalued compared to BTC. We enter a position going short MSTR and long BTC.
# Create position signals based on Z-score
'Signal'] = 0
df['Z_Score'] < -threshold, 'Signal'] = 1 # Long MSTR, Short BTC
df.loc[df['Z_Score'] > threshold, 'Signal'] = -1 # Short MSTR, Long BTC
df.loc[df[
# Apply signal with one-day delay to avoid lookahead bias
'Position'] = df['Signal'].shift(1) df[
The strategy uses a one-day delay between signal generation and position execution to avoid lookahead bias, ensuring our backtest accurately reflects real-world trading constraints. If the day before z-score exceed the threshold but the second day quickly return to normal, the trade will not execute.
Exit Conditions
Positions are exited when the Z-score reverts toward the mean, specifically:
- A long MSTR/short BTC position is exited when the Z-score rises back above -threshold
- A short MSTR/long BTC position is exited when the Z-score falls back below threshold
This mean-reversion approach is implemented by setting the position to zero when the Z-score returns to the range between the negative and positive thresholds:
# Track trade entries and exits
'Entry'] = df['Position'] != df['Position'].shift(1)
df['Exit'] = (df['Position'] == 0) & (df['Position'].shift(1) != 0) df[
With this corrected exit logic, a position is only marked for exit when the position actually changes from non-zero to zero, which happens when the Z-score returns to the normal range.
Threshold Selection
The choice of Z-score threshold represents a trade-off between trading frequency and signal quality:
- Lower thresholds (e.g., 0.5): More frequent trades but potentially weaker signals
- Higher thresholds (e.g., 2.5): Fewer trades but stronger statistical divergence signals
Our backtest analyzes multiple thresholds (0.5, 1.0, 1.5, 2.0, 2.5) to identify the optimal balance. As shown in the performance metrics, the Z-score threshold of 2.5 provides the best risk-adjusted returns as measured by the Sharpe ratio.
Trade Execution Logic
When a trade is initiated, equal dollar amounts are allocated to both legs of the pairs trade (long and short). The position sizes are kept constant throughout the trade duration until an exit signal is generated:
# Calculate position values (assume equal dollar amounts in both legs)
'MSTR_Position'] = df['Position'] * 1 # +1 for long, -1 for short
df['BTC_Position'] = -df['Position'] * 1 # Opposite of MSTR position df[
This market-neutral approach allows the strategy to potentially profit regardless of the overall market direction, focusing instead on the relative performance between MSTR and BTC.
Backtest Results
The performance of our pairs trading strategy with different Z-score thresholds compared to buy-and-hold strategies:
Annual Return | Annual Volatility | Sharpe Ratio | Max Drawdown | Trade Count | Position Days Ratio | Win Ratio | |
---|---|---|---|---|---|---|---|
Pairs_Z0.5 | -21.13% | 62.72% | -0.40 | -73.03% | 55 | 74.43% | 36.80% |
Pairs_Z1.0 | -19.32% | 53.82% | -0.43 | -67.54% | 54 | 49.69% | 23.70% |
Pairs_Z1.5 | -21.14% | 46.38% | -0.54 | -64.58% | 43 | 29.31% | 12.06% |
Pairs_Z2.0 | 5.64% | 38.17% | 0.04 | -44.68% | 32 | 13.10% | 5.61% |
Pairs_Z2.5 | 16.45% | 24.57% | 0.51 | -17.66% | 13 | 4.57% | 2.29% |
Hold_BTC | 96.61% | 50.01% | 1.85 | -28.11% | |||
Hold_MSTR | 282.81% | 96.39% | 2.89 | -49.78% |
Best Strategy Analysis
Strategy Type | Strategy | Sharpe Ratio | |
---|---|---|---|
0 | Best Pairs Strategy | Pairs_Z2.5 | 0.51 |
1 | Best Overall Strategy | Hold_MSTR | 2.89 |
Strategy Returns Visualization
The cumulative returns of all strategies:
Risk-Return Profile
Annual Return | Annual Volatility | Sharpe Ratio | |
---|---|---|---|
Pairs_Z0.5 | -21.13% | 62.72% | -0.40 |
Pairs_Z1.0 | -19.32% | 53.82% | -0.43 |
Pairs_Z1.5 | -21.14% | 46.38% | -0.54 |
Pairs_Z2.0 | 5.64% | 38.17% | 0.04 |
Pairs_Z2.5 | 16.45% | 24.57% | 0.51 |
Hold_BTC | 96.61% | 50.01% | 1.85 |
Hold_MSTR | 282.81% | 96.39% | 2.89 |
Drawdown Analysis
Trading Analysis
Trade Performance by Z-Score Threshold
Count | Win Rate | Avg Return | Avg Duration | |
---|---|---|---|---|
Pairs_Z0.5 | 55 | 63.64% | 0.13% | 9.2 days |
Pairs_Z1.0 | 54 | 59.26% | 0.31% | 6.4 days |
Pairs_Z1.5 | 43 | 62.79% | 1.18% | 4.6 days |
Pairs_Z2.0 | 32 | 56.25% | 0.09% | 2.8 days |
Pairs_Z2.5 | 13 | 53.85% | -0.14% | 2.4 days |
Position Analysis Over Time
Trade Win Rate vs Z-Score Threshold
## Trade Blotter and Portfolio Ledger for Pairs_Z2.5
Showing 10 records out of 13 trades and 481 portfolio days
Trade Blotter
The trade blotter provides detailed information about each entry and exit point in our pairs trading strategy, including position sizes, values, and profit/loss for each leg of the trade:
TimeEntry | TimeExit | PositionBTC | PositionMSTR | QuantityBTC | EntryBTCvalue | ExitBTCvalue | P&L BTC value | EntryMSTRvalue | ExitMSTRvalue | P&LMSTRvalue | Success/Fail | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2023-06-27 | 2023-06-28 | Short | Long | 0.325921 | $10000.00 | $9807.71 | $192.29 | $10000.00 | $10021.55 | $21.55 | Success |
1 | 2023-07-05 | 2023-07-07 | Long | Short | 0.328464 | $10000.00 | $9938.25 | $-61.75 | $10000.00 | $10068.76 | $-68.76 | Fail |
2 | 2023-12-26 | 2024-01-02 | Long | Short | 0.237351 | $10000.00 | $10637.17 | $637.17 | $10000.00 | $11346.25 | $-1346.25 | Fail |
3 | 2024-02-09 | 2024-02-14 | Long | Short | 0.208122 | $10000.00 | $10761.26 | $761.26 | $10000.00 | $11912.42 | $-1912.42 | Fail |
4 | 2024-02-15 | 2024-02-16 | Long | Short | 0.193334 | $10000.00 | $10011.26 | $11.26 | $10000.00 | $9743.73 | $256.27 | Success |
5 | 2024-03-05 | 2024-03-06 | Long | Short | 0.161496 | $10000.00 | $10825.12 | $825.12 | $10000.00 | $11857.28 | $-1857.28 | Fail |
6 | 2024-05-16 | 2024-05-17 | Long | Short | 0.153437 | $10000.00 | $10129.81 | $129.81 | $10000.00 | $11003.47 | $-1003.47 | Fail |
7 | 2024-05-20 | 2024-05-21 | Long | Short | 0.142717 | $10000.00 | $9885.79 | $-114.21 | $10000.00 | $9584.30 | $415.70 | Success |
8 | 2024-06-28 | 2024-07-01 | Long | Short | 0.161466 | $10000.00 | $10204.25 | $204.25 | $10000.00 | $9916.52 | $83.48 | Success |
9 | 2024-09-04 | 2024-09-05 | Short | Long | 0.172289 | $10000.00 | $9656.46 | $343.54 | $10000.00 | $9577.09 | $-422.91 | Fail |
Portfolio Ledger
The portfolio ledger tracks the daily positions and cumulative performance of our trading strategy, showing how the portfolio value evolves over time:
Date | BTCposition | MSTRposition | Daily Return | Portfolio value | |
---|---|---|---|---|---|
0 | 2023-05-25 | None | None | -0.00% | $100000.00 |
1 | 2023-05-26 | None | None | 0.00% | $100000.00 |
2 | 2023-05-30 | None | None | 0.00% | $100000.00 |
3 | 2023-05-31 | None | None | 0.00% | $100000.00 |
4 | 2023-06-01 | None | None | 0.00% | $100000.00 |
5 | 2023-06-02 | None | None | 0.00% | $100000.00 |
6 | 2023-06-05 | None | None | 0.00% | $100000.00 |
7 | 2023-06-06 | None | None | 0.00% | $100000.00 |
8 | 2023-06-07 | None | None | 0.00% | $100000.00 |
9 | 2023-06-08 | None | None | 0.00% | $100000.00 |
Trade Summary
Thoughts
This pairs trading strategy exploiting the MSTR-BTC relationship provides a market-neutral approach that can complement traditional long-only cryptocurrency and equity strategies. Based on our real market data analysis, the optimal configuration uses a Z-score threshold of 2.5, which provides the best Sharpe ratio among pairs strategies at 0.51.
While our backtest shows that simply holding MSTR would have yielded higher absolute returns with a Sharpe ratio of 2.89, the pairs trading approach demonstrates significantly better risk characteristics:
- Lower Maximum Drawdown for pairs trading vs. holding MSTR
- Lower Volatility for pairs trading vs. holding MSTR
Potential Improvements
The pairs trading strategy could be enhanced through:
Alternative Distribution Fitting: The current approach assumes normal distribution of the ratio. We could improve signal generation by fitting alternative distributions (Student’s t, skewed t, or mixture models) that better capture the fat-tailed nature of financial data.
Dynamic Thresholds: Instead of fixed Z-score thresholds, implementing adaptive thresholds based on market volatility regimes could improve performance.
Machine Learning Enhancement: Incorporating additional features beyond just the price ratio (such as volume, volatility, and sentiment indicators) into a machine learning model could better predict mean reversion points.
Multi-Asset Extension: Expanding beyond the MSTR-BTC pair to include other assets could create a more diversified statistical arbitrage portfolio.