VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Backtesting and validation

Backtesting Taiwan stocks and ETFs: data, costs and a 0050 example

A Taiwan stock or ETF backtest holds up only when it uses dividend- and split-adjusted prices, charges commission on both sides and transaction tax on the sale, fills on the next bar, and fixes the cash-flow plan (lump sum or regular fixed-amount investing) before the first run. Then compare the rule with simply holding the ETF.

By · Published · updated · Editorial policy

Contents
  1. What does a proper Taiwan stock or ETF backtest need?
  2. Why must Taiwan stock and ETF price data be adjusted for dividends and splits?
  3. What do tax, fees and slippage cost per round trip on Taiwan stocks and ETFs?
  4. Lump sum or dollar-cost averaging: how do you backtest each one?
  5. What does a first backtest on 0050 look like, step by step?
  6. Which free stock backtesting tools can you use, and where do they stop?
  7. Which mistakes make a Taiwan stock backtest look better than it was?
  8. Frequently asked questions
  9. References

What does a proper Taiwan stock or ETF backtest need?

A proper Taiwan stock or ETF backtest uses dividend- and split-adjusted prices, charges brokerage commission on both sides and securities transaction tax on the sale, fills every order on the next bar, and decides before the first run whether cash goes in as a lump sum or by dollar-cost averaging. Then it compares the rule with simply holding the same ETF.

A backtest is a replay of a trading rule over past prices that reports what the rule would have done. For a Taiwan stock backtest the replay goes wrong in four places that a futures backtest never meets: the price series must be adjusted for dividends and splits, the tax applies only when you sell and differs between stocks and ETFs, shares are bought in lots of a thousand so position size is lumpy, and many people invest a fixed amount every month instead of one sum. The next three sections handle adjustment, costs and the cash-flow plan; lot size comes up where it bites, in the dollar-cost averaging table.

The regular Taiwan Stock Exchange (TWSE) session runs from 09:00 to 13:30 Taiwan time, so a daily bar is a short session and the open often carries an overnight gap. Exchanges can change session times and fees; the TWSE trading-rules page is the place to confirm them before a test.

Why must Taiwan stock and ETF price data be adjusted for dividends and splits?

Unadjusted close prices drop on every ex-dividend day, so a backtest on raw data understates a dividend-paying ETF like 0050 and misreads every split; use an adjusted series or add the dividends back as cash.

Adjusted price data is a price series in which past prices have been scaled so that dividends and splits do not appear as price moves. Think of a water meter that someone resets to zero every few months: the raw reading would show a sudden fall, although no water flowed backwards. On the ex-dividend day the exchange lowers the reference price by the dividend amount. A holder lost nothing, because the cash arrives in the account, but a rule reading the raw close sees a loss and may even trigger a stop.

0050 is the stock code of the Yuanta Taiwan Top 50 ETF, which tracks the FTSE TWSE Taiwan 50 Index and pays cash dividends more than once a year. Over ten years that is many small steps down in the raw series. A trend rule tested on raw data sells into dividends that it never actually lost. Splits are worse: in 2025 the fund split each unit into four, so an unadjusted chart shows the price falling to about a quarter in one day, and any moving-average rule on raw data would see a crash.

Over one year, the raw price line of a dividend-paying ETF drops at each ex-dividend date. The adjusted line rises smoothly to the same end point, because the drops are cash paid to the holder and not losses. Dividend steps are not losses Raw vs adjusted price, one year Dividend steps Raw Adjusted The raw drops are cash paid out. So: test on adjusted prices.
Unadjusted vs adjusted prices for a dividend-paying ETF over one year. The steps in the raw line are cash paid to the holder, not losses, and the adjusted line removes them.

You have two correct options, and the choice depends on what you want to measure:

  1. Use a total-return adjusted series. Every past price is scaled down so the ex-dividend step disappears. The backtest then measures the return with dividends reinvested on the ex-date. Most data vendors and the fund issuer's own documents give you what you need to build it. Use this when you compare rules against each other.
  2. Use raw prices and book each dividend as cash. The rule reads the raw close, and on each ex-date the backtest adds the dividend times shares held to the cash balance. Use this when you want the rule to see the price the market actually printed, and you accept that the rule must be told not to treat the ex-dividend step as a signal.

Whichever you choose, check the series for the problems described in backtest data quality: gaps, bad ticks, time zones and rolls: missing holidays, a zero-volume bar, or a split that the vendor adjusted a day late.

What do tax, fees and slippage cost per round trip on Taiwan stocks and ETFs?

The round-trip cost is brokerage commission on both sides plus securities transaction tax on the sale only, and the tax rate for ETFs is lower than for stocks, so the same rule can pass on an ETF and fail on a stock.

Securities transaction tax is a tax charged to the seller as a percentage of the sale amount. Under the Securities Transaction Tax Act the rate is 0.3% for shares and 0.1% for ETF units. Brokerage commission is the broker's fee, charged on both the buy and the sell, with a regulated ceiling of 0.1425% of the trade amount; most brokers discount it and many apply a minimum charge per order. A temporary reduced rate applies to the sale side of cash day trades; its end date has been extended several times, so confirm the current date on the Ministry of Finance page before you test a day-trading rule.

The one formula in this article is the round-trip cost before slippage:

Round-trip cost % = 2 × commission % + transaction tax %

Here commission % is the rate your broker charges per side, counted twice because you buy and sell once each, and transaction tax % is counted once because only the sale is taxed. At the full commission ceiling that gives 0.585% for a stock and 0.385% for an ETF. Slippage is the difference between the price in the backtest and the price you would really have got; for a liquid ETF with a market order at the open, one tick per side is a fair starting assumption, more for thin stocks.

Cost itemStockETF
Commission on buy (ceiling)0.1425%0.1425%
Commission on sell (ceiling)0.1425%0.1425%
Transaction tax on sell0.3%0.1%
Round trip before slippage0.585%0.385%
Round-trip cost stacks at the commission ceiling, with estimated slippage. The fees are the same for both, but the transaction tax is 0.3 percent for a stock and 0.1 percent for an ETF, so the stock costs about 0.69 percent and the ETF about 0.49 percent. The stock pays 3× the tax Round trip at the fee ceiling Fees Tax Slippage (est.) Stock 0.3% 0.69% ETF 0.1% 0.49% Same rule, higher bar for stocks. So: re-run with 0.3% tax.
Round-trip cost stacks for a stock and an ETF at the commission ceiling, with an assumed slippage of about 5 basis points per side; the tick size on the TWSE depends on the price band, so convert your own tick to a percentage before you enter it. The transaction tax segment is three times taller for the stock.

Hypothetical example

You buy one lot (a thousand units) of an ETF at NT$100, a trade of NT$100,000, and later sell at the same price. Commission at 0.1425% is NT$142.5 on the buy and NT$142.5 on the sell. Transaction tax at 0.1% on the sale is NT$100. The round trip costs NT$385, or 0.385% of the position. The same trade in a stock would carry NT$300 of tax and cost NT$585. If your rule's average trade before costs is 0.5%, it survives on the ETF and loses on the stock.

Put the costs into the first run, not the last one, and compare them with the average trade as described in trading costs in backtests: commission, slippage and the average trade. A rule that trades weekly pays the round trip about fifty times a year; at 0.4% per trip that is about 20% of the capital per year before any slippage, which few rules on an index ETF can carry. Entering that 0.4% per trip once in the fee and slippage settings of AlphaPrime (Valynox) backtesting means a weekly rule on 0050 pays for every round trip from its very first test.

Lump sum or dollar-cost averaging: how do you backtest each one?

A lump-sum test measures the strategy; a dollar-cost averaging test measures the strategy plus the timing of your deposits, so the two need different equity curves and different performance measures.

Dollar-cost averaging (DCA), or regular fixed-amount investing, is a plan in which you invest the same amount of money on a fixed day every month, regardless of price. A lump sum is the whole amount invested on day one. The two are different objects: the lump-sum curve starts fully invested and every move acts on all the capital, while the DCA curve starts near zero and most of the capital arrives late. Comparing their final values is like comparing two runners who started at different times.

Capital invested over one year. A lump sum is fully invested from the start and stays flat. Monthly deposits climb in twelve steps, so most of that money arrives late and final values cannot be compared directly. DCA has less money at work Capital invested over one year Lump sum Monthly Start Year end Final values are not comparable. So: use IRR on invested cash.
Lump sum vs dollar-cost averaging over one year: one deposit and a flat invested line, or twelve deposits and a staircase. Judge each on return per unit of capital that was actually invested.

CAGR (compound annual growth rate) is the single yearly rate that would grow the starting sum to the final value; a money-weighted return (IRR) is the same idea for a stream of deposits, the one yearly rate that grows each deposit from the day it went in to the final value.

QuestionLump sumDollar-cost averaging
What it measuresThe rule on fixed capitalThe rule plus deposit timing
Return measureTotal return and CAGR on the starting sumMoney-weighted return (IRR) on the deposit stream
Drawdown measurePeak-to-trough of equityPeak-to-trough of equity minus deposits
Position sizeWhole lots of the starting sumOdd lots or saved cash until one lot is affordable
Costs per tradeFew, large tradesMany small buys, minimum commission matters

Three things to fix in a dollar-cost averaging backtest:

  1. The deposit day, for example the first trading day of each month, filled at the next open.
  2. What happens when the deposit cannot buy a whole lot: buy odd lots, or hold the cash until the deposit can.
  3. How drawdown is counted. Drawdown is the fall from the highest equity point to the next lowest; in a DCA curve it must be measured on equity after subtracting the deposits, or new cash hides the losses.

The free drawdown calculator gives maximum drawdown and recovery time from an equity series you paste in. Run the DCA test from several different start months as well, because a start at a market low flatters the result and a start at a high punishes it.

What does a first backtest on 0050 look like, step by step?

A first 0050 backtest fixes the data, the adjustment, the costs and the order timing before any rule is tested, then compares the rule with simply holding the ETF over the same period, all inside a hypothetical example.

The order matters because each later step inherits the earlier ones. A rule tested before the costs were set will be chosen for its gross result, and the costs added later remove the finalists.

Five steps of a first 0050 backtest: adjusted data, costs per side and next-bar fills are fixed first, then the rule is run, then it is compared with holding the ETF over the same dates. Test the rule last A first 0050 backtest in five steps 1 2 3 4 5 Adjusted data Costs per side Next-bar fills Run the rule Compare with holding Fixed first Costs set late remove the winners. So: fix data, costs, fills first.
The five steps of a first 0050 backtest. The rule is tested last, after data, costs and execution are fixed, and is judged against holding the ETF over the same dates.
  1. Load adjusted daily bars for 0050. Pick a start date that covers at least one large fall and one long rise, confirm the 2025 split and every dividend are already in the series, and check for missing days against the exchange holiday calendar.
  2. Enter the costs per side. Your actual commission rate on both sides, 0.1% tax on the sell side, and one tick of slippage per side.
  3. Set fills to the next bar's open. A rule that reads the daily close cannot trade at that close. The next open is the first price it could have got.
  4. Run the rule. Keep the first rule simple, with one or two parameters, so you can read what happened trade by trade.
  5. Compare with buy-and-hold over the same dates. Same series, same costs for one buy and one sell, same start and end. Record total return, maximum drawdown, number of trades and total costs paid for both.

Hypothetical example

Capital NT$1,000,000, adjusted daily bars for ten years. Rule: buy at the next open when the close crosses above its 200-day moving average, sell at the next open when it crosses below. Commission 0.1425% per side, tax 0.1% on sells, slippage one tick per side. The rule makes 24 round trips and pays about NT$150,000 in costs. Suppose the rule ends at NT$2,100,000 with a maximum drawdown of 18%, while buy-and-hold ends at NT$2,700,000 with a maximum drawdown of 32%. A good result for the rule is not a higher ending value; it is a lower drawdown for a cost in return you are willing to pay, with few enough trades that the costs stay small. A bad result is the same ending value as holding, a larger drawdown, and most of the gain coming from one or two trades.

Then change one thing at a time: the moving-average length, the slippage, the start year. If a small change in the length flips the result, the rule is fitting the history, not the market. AlphaPrime applies the same discipline in its backtesting on futures data: fees, slippage and next-bar execution are part of every evaluation, so the ranking already reflects what could have been traded.

Which free stock backtesting tools can you use, and where do they stop?

Spreadsheets, broker DCA simulators and charting-platform strategy testers each answer part of the question, and what you add yourself is usually dividend handling, Taiwan-specific costs or the ability to test many variants.

A spreadsheet is the most honest first tool, because you type every assumption yourself: the adjusted series in one column, the rule in the next, the fill price one row later, the tax on sells only. Its limit is scale: a second parameter or a second ETF doubles the work. Broker dollar-cost averaging simulators answer one question well, the staircase of monthly deposits, but they rarely let you add a rule, and some use raw prices without dividends, which you can detect by checking whether the result changes on an ex-dividend date. Charting-platform strategy testers, described in TradingView Strategy Tester: free backtests and what to check first, run rule-based entries and exits and let you set commission and slippage, but you must set the sell-side tax yourself and check whether the symbol's series is adjusted.

What each free tool type leaves to you: a spreadsheet needs each variant built by hand, a broker DCA simulator needs your entry and exit rule, and a charting-platform tester needs the sell-side tax and the monthly deposits. What you add yourself Free tools, one gap each Spreadsheet Each variant, by hand Broker DCA simulator Your entry and exit rule Charting tester Sell tax and monthly deposits
What you add yourself: one setting each free tool type leaves to you. Spreadsheet: each variant by hand. Broker DCA simulator: your entry and exit rule. Charting-platform tester: sell-side tax and monthly deposits.
NeedSpreadsheetBroker DCA simulatorCharting-platform tester
Dividend adjustmentFull, if you build the seriesPartial, depends on the brokerPartial, depends on the data feed
Taiwan tax and feesFull, typed by handPartialPartial, commission yes, sell-side tax by hand
Dollar-cost averaging cash flowFullFullNone or by script
Rule-based entries and exitsPartial, one rule at a timeNoneFull
Many variants at onceNoneNonePartial, one symbol, inputs changed by hand one run at a time

The last row is where free tools stop and where a new risk begins. Testing many variants and keeping the best one inflates the result, because among many random rules some will look good by chance; Bailey and colleagues (2014) show how fast this inflation grows with the number of trials. A tool that tests many variants must also help you judge how much of the best one is luck; that is what strategy validation is for.

Which mistakes make a Taiwan stock backtest look better than it was?

Survivorship bias, unadjusted prices, same-bar fills and ignoring the transaction tax are the four errors that inflate a Taiwan stock backtest most, and each has a simple check.

Survivorship bias is the error of testing only on the stocks that still exist today, which removes every company that was delisted, merged or collapsed from the history. It is like judging a marathon by interviewing only the finishers. A stock-picking rule tested on today's list of large companies has, without knowing it, avoided every failure of the past ten years. ETFs like 0050 avoid most of this because the index already replaced its fallen members as they went, but a backtest across individual Taiwan stocks needs a list of constituents as of each past date.

Survivorship bias: of ten stocks back then, three were delisted. Today's list shows only the seven that are still listed, so a backtest built from it never sees the three losers. Today's list hides the losers Ten stocks, three delisted Back then Still listed Delisted Today's list Missing Dead stocks drop out of the test. So: use the list as of each date.
Survivorship bias: three of ten stocks were delisted before today. A backtest built from today's list never sees them, so the losses they caused vanish from history.
MistakeWhat it does to the resultSimple check
Survivorship biasRemoves past losers, lifts every stock-picking resultCount the symbols in your universe in the first test year against the actual exchange list of that year
Unadjusted pricesCounts dividends as losses, treats splits as crashesLook at the equity curve on a known ex-dividend date and on the 2025 split date of 0050
Same-bar fillsTrades at a close the rule had not yet seen; a form of look-ahead biasMove every fill to the next open and compare; a large change means the edge was in the timing
Ignoring transaction taxHides up to 0.3% per round trip on stocksMultiply the number of sells by 0.3% (or 0.1% for ETFs) of the average position and compare with the total return

Run all four checks before you look at the headline return. A backtest that passes them is still only a record of the past, but it is a record of the past as it could have been traded, with the cash flows, the costs and the dead companies in place.

What this means if you use AlphaPrime: two of the four decisions in this article, costs per side and next-bar fills, are settings AlphaPrime's backtesting applies to every evaluation on futures, and traders who want to test an index idea across many variants often run it on TAIEX futures, which follow the same market as 0050, as described in how to backtest TAIEX futures strategies realistically, then carry the surviving rule back to the ETF by hand with the ETF's own costs.

Frequently asked questions

Does a 0050 backtest need dividend-adjusted data?

Yes. 0050 pays cash dividends more than once a year and the reference price drops by the dividend on each ex-date. On raw prices a backtest counts every dividend as a loss and may trigger exits on those days. Use a total-return adjusted series, or book each dividend as cash on the ex-date.

How much does a round trip on a Taiwan ETF cost?

Commission on both sides plus 0.1% transaction tax on the sale. At the commission ceiling of 0.1425% per side the round trip is 0.385% before slippage; with a discounted commission it is lower. For a stock the tax is 0.3%, so the same round trip costs 0.585% at the ceiling.

How do I backtest dollar-cost averaging fairly against a lump sum?

Do not compare final values, because the DCA plan has less capital invested for most of the period. Use a money-weighted return (IRR) for the deposit stream and measure drawdown on equity after subtracting deposits. Run the DCA test from several start months, since a start at a market low flatters it.

Can I use a free charting-platform strategy tester for Taiwan stock backtesting?

Yes, for rule-based entries and exits with commission and slippage. You must check whether the symbol's data is dividend-adjusted and add the sell-side transaction tax yourself, since most testers charge the same cost on both sides. Testing many variants usually means changing the inputs by hand and running the test again for each one.

Why does my stock backtest look better than my ETF backtest with the same rule?

Check two things. If you built the stock universe from today's list, delisted losers are missing, which is survivorship bias. If the tax is set to 0.1% or zero for the stock, it is underpaying by up to 0.2% per round trip. Fix both and re-run before comparing.

References

  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.