Jason Zou
05Smaller toolsSubstitutes finder · MACD test

Two smaller tools

This page covers two small tools. One finds close substitutes for a stock, for use in tax-loss harvesting, and the other tests whether the monthly MACD crossover has worked on a given stock. Only the substitutes finder is public.

On this page
Substitutes finder · MACD signal test
Public
The substitutes finder only. The MACD test has no public repository.
Data
Yahoo Finance through yfinance
05 · Claude skill, v0.1.0, public

Correlated substitutes finder

The finder takes one stock and finds the three liquid US stocks whose returns have behaved most like that stock's. I built it as research support for tax-loss harvesting in direct-indexed accounts, where a name that has been sold needs a close stand-in.

  1. 1Candidates come from a built-in list of 151 large US stocks, or from a text file of tickers. Each needs a 90-day median daily volume of at least $25m and 250k shares. ETFs, ADRs, preferreds and closed-end funds are excluded.
  2. 2The finder works on daily log returns computed from adjusted closes. By default it uses two years of returns, which is 504 trading days, or fewer when a name has a shorter history.
  3. 3A composite score ranks the candidates, with the raw correlation shown beside it. I set its weights by judgement and didn't fit them to any outcome. The top three are kept, each with a one-line rationale assembled by rule.
  4. 4The output is the results in JSON, together with a copy of a fixed dashboard in which only the data block has been replaced. The layout is the same for every run.
SKILL.md · composite score
score = 0.45 × correlation
+ 0.20 × R²
+ 0.15 × (1 − |β − 1|)
+ 0.10 × min 60-day rolling correlation
+ 0.10 × liquidity score
// the β and rolling-correlation terms are clipped to 0 to 1
// liquidity is log-scaled, $25m a day = 0 and $5bn a day = 1

Correlation labels run from Very High (0.90 and above) to Poor (below 0.40), and a collapse in rolling correlation is flagged. The tool makes no wash-sale determination.

View on GitHubMIT · yfinance · Python 3.10+
Try the score · enter a candidate's statistics

The sliders only reproduce the score formula. A real run computes the inputs from two years of prices for about 150 candidates and keeps the top three.

06MACD signal testClaude skill · v0.1.0 · not public

Backtesting monthly MACD crossovers on one stock

The script asks whether the monthly MACD (12, 26, 9) crossover has been worth acting on for one stock. It scores every crossover in the last five years on the forward return over the next 3, 6 and 12 months.

  1. 1Four statistics. The number of signals, the 3-month hit rate, the expectancy (average 3-month return, sign flipped for bear signals) and the false-signal rate, where a reversal within two months counts as false.
  2. 2One result. Fixed thresholds, the same every run, turn those four into Reliable, Mixed or Inaccurate. Eight to fifteen signals is a small sample, so the result describes those five years on that stock and is not a recommendation.
  3. 3A fixed dashboard. Only the data block changes between runs. It shows the result, the statistics behind it and the stock's momentum against its 10-month moving average.
Try the rules with your own numbers
ResultRule, applied from the top
ReliableN ≥ 8, 3-month hit rate ≥ 60%, expectancy ≥ 3% on bull or bear signals, false signals ≤ 25%
Mixedfewer than 8 signals in the five-year window (low sample)
InaccurateN ≥ 8, 3-month hit rate < 40% and false signals ≥ 35%
Mixedanything else, reported as Mixed or inconclusive with the reasons given