{"slug": "i-asked-claude-code-to-find-me-a-trading-edge-it-killed-three-strategies-first", "title": "I Asked Claude Code to Find Me a Trading Edge. It Killed Three Strategies First.", "summary": "A freelance web developer in Japan built a fully automated, rule-based Japanese stock research pipeline using Claude Code, J-Quants, and a macOS cron job. The system, which is forbidden from making predictions, killed three of four strategy ideas with evidence, leaving one that survived liquidity filters and is now in paper trading.", "body_md": "*How I built a fully automated, rule-based Japanese stock research pipeline with Claude Code, J-Quants, and a macOS cron job — and why \"the AI is not allowed to predict anything\" turned out to be the most useful constraint in the whole project.*\n\nEveryone's first idea for \"AI + stocks\" is the same: ask the model whether a stock will go up. That idea has been tested, and it fails — LLMs guessing post-event price direction land around coin-flip accuracy. I'm a freelance web developer in Japan, not a quant, and I knew that if I let an LLM \"predict\" anything I would just be laundering my own wishful thinking through a chatbot.\n\nSo I gave Claude Code a different job description. In my project's `CLAUDE.md`\n\n— the standing instructions file the agent reads every session — there's a hard rule:\n\nNo predictions. Data only.The AI's role is limited to four things: (1) structuring data, (2) computing factual metrics, (3) checking facts against pre-defined rules, (4) explaining results with sources. Trading decisions are rule-based. Overfitting to past data is a hidden prediction — prefer economically sensible rules.\n\nClaude Code's job was to be the engineer: build the data pipeline, implement backtests I specified, and then — this is the important part — **kill my ideas with evidence**. Over a few weeks it killed three of them. Here's the honest record.\n\nNothing exotic. The point was cheap and reproducible:\n\n`yfinance`\n\nfor live tracking.First I had Claude Code implement the classics on Nikkei-universe data: breakout entries, RSI mean-reversion, with realistic costs and taxes included.\n\nTen-year portfolio result: **+15.4%** total. Sounds okay until you put it next to the benchmark: buy-and-holding the Nikkei over the same period returned **+138.8%** (with a −26% max drawdown). My \"strategy\" wasn't a strategy; it was an expensive way to sit out a bull market.\n\nVerdict: dead. Next.\n\nPost-earnings announcement drift is one of the best-documented anomalies: stocks that beat guidance keep drifting up for weeks. On large caps, my backtest found nothing — no monotonicity across surprise sizes, slightly negative drift everywhere. Institutional money has eaten that edge.\n\nSmall caps looked genuinely exciting: 276 stocks, 1,385 earnings events, 423 trades. The threshold sweep was beautifully monotonic — bigger guidance beats, bigger drift: +1.6% → +2.1% → +2.7% → +3.4% per trade as the threshold rose.\n\nThen I asked Claude Code to add one boring, adult filter: **only keep stocks with at least ¥100M in daily trading value** — i.e., stocks I could actually buy without moving the price.\n\nThe edge evaporated: **−0.34%** per trade on the 33 surviving trades. At ¥300M/day it got worse (−2.48%).\n\nThe anomaly was real, but it lives exclusively in stocks too illiquid to trade at size. This was the single most valuable chart the pipeline ever produced, and it's a *negative* result. If your backtest doesn't include an executability filter, it isn't a backtest — it's fan fiction.\n\nThird idea: a quarterly-rebalanced screen. Rank small caps by valuation (with quality guards: equity ratio ≥ 25%, positive forecast EPS, and a filter against one-off earnings spikes), split into quintiles, hold the cheapest.\n\nThis one behaved differently. The cheapest quintile (Q1) returned **+8.89% per quarter**, returns were fully monotonic down the ranks, the cheap-vs-expensive spread was +8.96% per quarter, and Q1 beat the universe average in **all six** backtest quarters.\n\nAnd the crucial difference from PEAD: **the edge survived the liquidity filter.** Restricted to ≥¥100M/day stocks, Q1 still returned +10.06% per quarter (+78.7% cumulative vs +42.2% for the universe). The sign didn't flip.\n\nOne strategy out of three survived its own audit. That's the pipeline working as intended.\n\nA backtest that survives in-sample is still just a hypothesis, so the surviving strategy went into \"Phase 0\": a paper portfolio tracked automatically every trading day, with a pre-committed bar to clear — beat the benchmark over 2–3 months *without touching the parameters* — before real money scales beyond pocket change.\n\nThe automation is deliberately low-tech. A launchd job fires at 15:45 JST on weekdays (after the Tokyo close) and runs a shell script:\n\n``` bash\n#!/bin/zsh\n# Runs from launchd on weekdays at 15:45 JST.\n# 1) Record any not-yet-entered positions at today's opening price\n# 2) Append the daily report to the log, push a summary to macOS notifications\nREPO=\"$HOME/work/makemoney\"\nPY=\"$REPO/.venv/bin/python\"\n{\n  echo \"===== $(date +%F) =====\"\n  \"$PY\" phase0_track.py open --date \"$(date +%F)\"\n  report=$(\"$PY\" phase0_track.py report)\n  echo \"$report\"\n} >> \"$REPO/data/phase0_daily.log\"\n\nsummary=$(echo \"$report\" | grep \"Portfolio\" | head -1)\nosascript -e \"display notification \\\"$summary\\\" with title \\\"Phase 0\\\"\"\n```\n\nThe Python side is a small CLI with two subcommands. `open`\n\nrecords entries at the day's opening price (same conditions as the fractional-share \"opening auction\" orders I'd use with real money) with an idempotency guard, so re-running never double-records:\n\n```\n# double-entry guard\nexisting = {p[\"ticker\"] for p in journal.open_positions()\n            if p[\"strategy\"] == STRATEGY}\nlst = lst[~lst[\"ticker\"].isin(existing)]\n```\n\n`report`\n\nmarks the portfolio to market and compares it against two benchmarks (Nikkei 225 and a TOPIX ETF) *measured from the same entry date* — the comparison that Round 1 taught me never to skip. The result lands in a log file and a macOS notification. Total infrastructure cost: ¥0.\n\nAs of 2026-08-14, one month after entry (18 positions, a small paper portfolio):\n\nBeating the Nikkei, narrowly losing to TOPIX. Inside the portfolio the dispersion is exactly what a small-cap quintile bet looks like: the best position is +46%, the worst is −33%. The daily report ends with a line I wrote for my own discipline: *\"The pass bar is 2–3 months against the benchmark. Do not react to daily noise.\"*\n\nMaybe it clears the bar in October. Maybe it doesn't and the strategy joins the graveyard with the other three. Either outcome is the system working.\n\nA few workflow notes for anyone trying something similar:\n\n`CLAUDE.md`\n\n, not in your willpower.*Nothing here is investment advice — it's a build log of a personal research tool, running on pocket-money stakes precisely because the evidence isn't in yet. J-Quants data is used under its personal-use license.*", "url": "https://wpnews.pro/news/i-asked-claude-code-to-find-me-a-trading-edge-it-killed-three-strategies-first", "canonical_source": "https://dev.to/hidenari/i-asked-claude-code-to-find-me-a-trading-edge-it-killed-three-strategies-first-22ai", "published_at": "2026-08-14 07:26:03+00:00", "updated_at": "2026-08-14 07:46:12.455490+00:00", "lang": "en", "topics": ["artificial-intelligence", "developer-tools", "ai-agents"], "entities": ["Claude Code", "J-Quants", "yfinance", "Nikkei"], "alternates": {"html": "https://wpnews.pro/news/i-asked-claude-code-to-find-me-a-trading-edge-it-killed-three-strategies-first", "markdown": "https://wpnews.pro/news/i-asked-claude-code-to-find-me-a-trading-edge-it-killed-three-strategies-first.md", "text": "https://wpnews.pro/news/i-asked-claude-code-to-find-me-a-trading-edge-it-killed-three-strategies-first.txt", "jsonld": "https://wpnews.pro/news/i-asked-claude-code-to-find-me-a-trading-edge-it-killed-three-strategies-first.jsonld"}}