Date | Stock_A_Price | Stock_B_Price | Log_Spread | Z_Score | |
---|---|---|---|---|---|
0 | 2025-03-13 | 3545.65 | 1289.49 | 1.011475 | 1.652931 |
1 | 2025-03-14 | 3554.91 | 1327.41 | 0.985100 | 0.664568 |
2 | 2025-03-17 | 3620.82 | 1347.99 | 0.988086 | 0.716633 |
3 | 2025-03-18 | 3614.27 | 1338.75 | 0.993154 | 0.819737 |
4 | 2025-03-19 | 3591.61 | 1340.09 | 0.985864 | 0.531886 |
5 | 2025-03-20 | 3573.38 | 1343.15 | 0.978494 | 0.244672 |
6 | 2025-03-21 | 3606.34 | 1339.09 | 0.990703 | 0.590982 |
7 | 2025-03-24 | 3657.82 | 1362.74 | 0.987370 | 0.419903 |
8 | 2025-03-25 | 3672.23 | 1375.48 | 0.981996 | 0.161267 |
9 | 2025-03-26 | 3681.68 | 1380.98 | 0.980576 | 0.030481 |
10 | 2025-03-27 | 3828.11 | 1423.62 | 0.989168 | 0.284125 |
11 | 2025-03-28 | 3771.00 | 1408.55 | 0.984779 | -0.016779 |
12 | 2025-03-31 | 3812.78 | 1432.58 | 0.978882 | -0.584602 |
13 | 2025-04-01 | 3813.27 | 1431.80 | 0.979555 | -0.974716 |
14 | 2025-04-02 | 3809.26 | 1417.01 | 0.988886 | -0.143995 |
15 | 2025-04-03 | 3826.15 | 1441.89 | 0.975904 | -1.303938 |
16 | 2025-04-04 | 3653.24 | 1389.87 | 0.966404 | -2.000556 |
17 | 2025-04-07 | 3478.38 | 1333.84 | 0.958505 | -2.383379 |
18 | 2025-04-08 | 3499.08 | 1315.20 | 0.978511 | -0.501904 |
19 | 2025-04-09 | 3502.03 | 1322.04 | 0.974167 | -0.812158 |
Pairs Trading Analysis: AZO vs ORLY
Stock A: AZO | Stock B: ORLY
AZO (AutoZone Inc) is a leading retailer in the automotive aftermarket that specializes in replacement parts, accessories, and maintenance products for vehicles.
ORLY (O’Reilly Automotive Inc) is a major distributor of automotive replacement parts, tools, supplies, and equipment, serving both professional service providers and retail customers.
Important Values
Stock prices are all from Shinybroker. Thanks Professor Jacob :)
Statistical Analysis
Correlation Analysis:
Pearson correlation coefficient: 0.9484
Conclusion: Strong correlation (≥0.7), suitable for pairs trading
Cointegration Test:
p-value: 0.0947
Conclusion: Pair is not cointegrated (p-value >= 0.05)
Augmented Dickey-Fuller Test:
ADF Statistic: -1.8980
p-value: 0.3330
Conclusion: Spread is not stationary (p-value >= 0.05)
AZO and ORLY are somewhat suitable for pairs trading, meeting most test conditions
Mean Reversion Analysis:
Regression coefficient (ρ): -0.0317
Half-life: 21.85 days
Recommended maximum holding time: 32 days
Trading Strategy Implementation
Trading period length: 5 days
Initial capital: $1,000,000.00
Shares per trade: 100
Stop-loss percentage: 5.0%
Maximum holding time: 32 days
Trading Results
Blotter (Trade Records)
entry_timestamp | exit_timestamp | AZO Position | ORLY Position | Quantity | AZO Entry | AZO Exit | AZO P&L | ORLY Entry | ORLY Exit | ORLY P&L | Total P&L | success | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2024-05-22 | 2024-05-30 | LONG | SHORT | 100 | $2,772.64 | $2,772.56 | $-8.00 | $991.44 | $963.64 | $2,780.00 | $2,772.00 | True |
1 | 2024-07-16 | 2024-07-22 | SHORT | LONG | 100 | $2,985.33 | $2,957.73 | $2,760.00 | $1,043.52 | $1,057.10 | $1,358.00 | $4,118.00 | True |
2 | 2024-08-16 | 2024-08-21 | SHORT | LONG | 100 | $3,212.87 | $3,202.22 | $1,065.00 | $1,119.52 | $1,138.16 | $1,864.00 | $2,929.00 | True |
3 | 2024-09-17 | 2024-09-26 | LONG | SHORT | 100 | $3,078.31 | $3,189.09 | $11,078.00 | $1,127.92 | $1,159.62 | $-3,170.00 | $7,908.00 | True |
4 | 2024-10-02 | 2024-10-23 | LONG | SHORT | 100 | $3,083.43 | $3,196.55 | $11,312.00 | $1,154.92 | $1,199.25 | $-4,433.00 | $6,879.00 | True |
5 | 2024-11-08 | 2024-11-18 | LONG | SHORT | 100 | $3,110.12 | $3,166.93 | $5,681.00 | $1,217.70 | $1,216.67 | $103.00 | $5,784.00 | True |
6 | 2024-11-22 | 2024-11-27 | LONG | SHORT | 100 | $3,099.38 | $3,190.10 | $9,072.00 | $1,227.37 | $1,244.01 | $-1,664.00 | $7,408.00 | True |
7 | 2024-12-06 | 2025-01-08 | SHORT | LONG | 100 | $3,309.44 | $3,303.35 | $609.00 | $1,257.78 | $1,205.74 | $-5,204.00 | $-4,595.00 | False |
8 | 2025-01-28 | 2025-02-10 | LONG | SHORT | 100 | $3,318.58 | $3,427.55 | $10,897.00 | $1,278.34 | $1,310.02 | $-3,168.00 | $7,729.00 | True |
9 | 2025-02-25 | 2025-03-20 | LONG | SHORT | 100 | $3,425.60 | $3,573.38 | $14,778.00 | $1,346.58 | $1,343.15 | $343.00 | $15,121.00 | True |
Ledger (Account Daily Status–With active position)
date | position | cash | AZO Price | ORLY Price | Portfolio Value | |
---|---|---|---|---|---|---|
27 | 2024-05-22 | 100 | $1,000,000.00 | $2,772.64 | $991.44 | $1,178,120.00 |
28 | 2024-05-23 | 100 | $1,000,000.00 | $2,777.54 | $975.87 | $1,180,167.00 |
29 | 2024-05-24 | 100 | $1,000,000.00 | $2,792.90 | $986.96 | $1,180,594.00 |
30 | 2024-05-28 | 100 | $1,000,000.00 | $2,800.00 | $957.51 | $1,184,249.00 |
31 | 2024-05-29 | 100 | $1,000,000.00 | $2,739.10 | $957.90 | $1,178,120.00 |
... | ... | ... | ... | ... | ... | ... |
228 | 2025-03-13 | 100 | $1,000,000.00 | $3,545.65 | $1,289.49 | $1,225,616.00 |
229 | 2025-03-14 | 100 | $1,000,000.00 | $3,554.91 | $1,327.41 | $1,222,750.00 |
230 | 2025-03-17 | 100 | $1,000,000.00 | $3,620.82 | $1,347.99 | $1,227,283.00 |
231 | 2025-03-18 | 100 | $1,000,000.00 | $3,614.27 | $1,338.75 | $1,227,552.00 |
232 | 2025-03-19 | 100 | $1,000,000.00 | $3,591.61 | $1,340.09 | $1,225,152.00 |
90 rows × 6 columns
Last date of this trading period:
date | position | cash | AZO Price | ORLY Price | Portfolio Value | |
---|---|---|---|---|---|---|
247 | 2025-04-09 | 0 | $1,015,121.00 | $3,502.03 | $1,322.04 | $1,015,121.00 |
Performance Metrics
Initial Capital: $1,000,000.00
Final Assets: $1,015,121.00
Total Return: 1.51%
Annualized Return: 39.06%
Annualized Volatility: 87.52%
Sharpe Ratio: 0.4463
Maximum Drawdown: -34.16%