Member-only story
The Mirage of PTC: When a Beautiful Backtest Hides a Broken Strategy
A story about a strategy that looked perfect — until reality tested it.
Kryptera9 min read·Just now--
Act I: Love at First Backtest
Every quant knows the feeling. You run the numbers, the equity curve climbs, and for a moment, you believe you’ve found something real.
import pandas as pd
import numpy as np
import yfinance as yf
import vectorbt as vbt
# -------------------------
# Download Data
# -------------------------
symbol = "PTC"
start_date = "1960-01-01"
end_date = "2030-01-01"
interval = "1d"
df = yf.download(symbol, start=start_date, end=end_date, interval=interval, multi_level_index=False)
df.reset_index().to_csv("PTC_clean.csv", index=False)
# -------------------------
# Necessary Parameters
# -------------------------
ER_LEVEL_HIGH = 0.7
ER_PERIOD = 14
SMA_PERIOD = 20
# -------------------------
# Indicator Functions
# -------------------------
def close_cross_below_sma(df, period=SMA_PERIOD):
"""
Close price crosses below the SMA
"""
df = calculate_sma(df, period)
return (df['Close'] < df['SMA']) & (df['Close'].shift(1) >= df['SMA'].shift(1))
def calculate_sma(df, period=SMA_PERIOD):
"""
Calculate Simple Moving Average (SMA) of the Close price.
"""
df = df.copy()
df['SMA'] =…