inflearn logo

Honestly, After Tax: An ETF Backtesting and Paper Trading Pipeline Built with Claude Code

Backtest result tables are usually pre-tax. We build a Python backtesting engine that includes fees and three types of taxes, lay out the rules and pass criteria before showing the results, and demonstrate how to evaluate it using only later periods, with the actual code and results.

2 learners are taking this course

Level Basic

Course period Unlimited

Python
Python
Investment
Investment
Financial Technology
Financial Technology
claude
claude
Python
Python
Investment
Investment
Financial Technology
Financial Technology
claude
claude

What you will gain after the course

  • After-Tax Backtesting Engine: Month-End Signals → Execution at the Next Trading Day’s Open, Simultaneous Holdings Across Multiple Assets, Asset-Specific Fees and Taxes, After-Tax Liquidation Value

  • 20 pytest cases comparing future data leakage, taxes, tax netting, and MDD against manual calculations

  • Pass/fail report based on predefined criteria (Markdown table, Excel)

  • Month-End Signal Script and Paper Trading Ledger Template

With the same rules and time period, adding taxes changes the rankings.

Backtest results are usually pre-tax. Once you factor in fees, taxes withheld when you sell, annual capital gains tax on overseas-listed assets, and taxes assuming you sell at the end of the period, the rankings of strategies and whether they meet the criteria can change. This course builds a Python backtesting engine that accounts for three tax treatments (tax-exempt / 15.4% tax on sale / 22% annual tax on overseas-listed assets after offsetting gains and deducting a KRW 2.5 million allowance) and shows, using actual code and results, how to write down the rules and pass criteria before looking at the results and evaluate them using only later periods. It also covers strategies that fell short during the learning period and results that barely passed the criteria, without omitting them.

Recommended for people like these

  • For those who have run backtests themselves but aren’t sure how to account for fees and taxes

  • Python users who want to test asset allocation and rotation rules using Korean-listed ETFs and U.S. ETFs.

  • People who want to avoid calculation errors such as look-ahead bias and omitted taxes when having AI (Claude Code) write their backtesting code.

  • Those who want to go through a paper-trading process rather than putting real money in right after backtesting.

Course List (10 Items)

  • Chapter 1. What Pre-Tax Backtests Hide — A Quick Look at This Course’s Engine (Free)

  • Chapter 2. Fetching the data — common trading dates, conversion to Korean won, and not overwriting data when a download fails

  • Chapter 3. Adding Costs and Taxes to the Engine

  • Chapter 4. Write Down the Rules First, Results Later — Preregistration

  • Chapter 5. Separating the Training and Validation Periods: Walk-Forward

  • Chapter 6. Prevent Future Data Leakage — Prove It with Tests

  • Chapter 7. The Verdict — If It Can’t Beat a 50:50 Hold, Discard It

  • Chapter 8. Four Weeks of Paper Trading — Month-End Signals and a Virtual Ledger

  • Chapter 9. Preventing Calculation Errors with Claude Code — Hooks, Tests, and Validation Scripts

  • Chapter 10. Failed Rule Examples and Next Steps

What You’ll Take Away from the Course (Course Materials ZIP)

  • After-tax backtesting engine: month-end signals → trades executed at the next trading day’s opening price, simultaneous holdings across multiple assets, fees and taxes per asset, and after-tax liquidation value.

  • 20 pytest cases: verify that no future data is used and that taxes, tax-loss netting, and MDD match hand calculations.

  • Report: a period-by-period table (Markdown) and an Excel file, with pass/fail assessments based on predefined criteria.

  • Month-End Signal Script and Paper Trading Ledger Template

  • Example scripts in the main text: preregistration freeze check (freeze_check.py), leakage experiment (leak_demo.py), walk-forward validation (walk_forward.py), detailed judgment (judge_detail.py), independent recalculation check (recalc_check.py), received data check (data_check.py), rerun with changed assumptions (assumption_check.py), and a pre-execution check hook for Claude Code (hook_precheck.py)

Please note

  • This is general education and does not recommend buying or selling any specific stocks or products. Past performance does not guarantee future returns. The results and sample stocks in this content are examples intended to demonstrate verification methods. We do not offer paid stock recommendations or one-on-one investment advice, and the course code does not place orders.

  • The tax and commission rates are illustrative figures based on 2026. Check the original tax laws and the terms of your own brokerage before applying them. Dividends and distributions, slippage, and currency conversion fees are simplified in the engine; their impact is calculated directly in Chapter 10.

  • The runtime environment is Python 3.11 or later. The engine itself uses only the standard library; openpyxl is used for Excel reports, and yfinance for fetching data. This is written for readers who know basic Python syntax.

  • The course materials contain only sample data, not actual market price files. Download the actual data yourself using the download script.

  • This is not an official course by Anthropic.

  • The draft was written with help from AI (Claude Code). Code excerpts were cross-checked against actual production files and programs, and the facts and wording were checked in a separate AI review before release.

Recommended for
these people

Who is this course right for?

  • Those who have run backtests themselves but aren’t sure how to factor in fees and taxes.

  • Python users who want to test asset allocation and rotation rules using Korean-listed and U.S. ETFs

  • If you’re using AI (Claude Code) to write backtesting code and want to prevent calculation errors such as look-ahead bias and omitted taxes.

  • Those who want to go through a paper trading phase after backtesting instead of immediately investing real money.

Need to know before starting?

  • Python Basics (Requires Python 3.11 or later)

Hello
This is Hypothesis Lab

I’m a practicing Java and Spring backend developer. I build backtesting and workflow automation tools in Python, and run development task automation with Claude Code. I turn topics you can use right away in interviews and on the job into concise, easy-to-read text lessons with code.

Reviews

Not enough reviews.
Please write a valuable review that helps everyone!

Hypothesis Lab's other courses

Check out other courses by the instructor!

Similar courses

Explore other courses in the same field!

25% off for new members

$13.10

25%

$23.10