Do Transaction Costs Change the Conclusion? Accounting for Entry, Full Replacement, and Liquidation
Before subtracting a percentage from returns, specify the traded amount to which costs apply. With cash 1000 and a purchase charge of 0.1%, buying assets worth 1000 and then deducting 1 leaves cash at -1. A no-borrowing account has exceeded its budget.
This synthetic example covers initial purchases, selling one asset entirely to buy another, and the difference between valuation and liquidation. Its invariant is: at identical execution prices, wealth lost during a trade equals that trade's cost. No actual ETF prices or broker fees are used.
1. Specify the trades and prices subject to costs
Use the preceding quantity-accounting example's inputs:
| Item | SYN_A | SYN_B | SYN_C |
|---|---|---|---|
| Initial execution price | 100 | 100 | 100 |
| Ending valuation price | 120 | 90 | 120 |
Initial cash is 1000. Buy-and-hold enters all three assets equally; the momentum example buys only the previously selected SYN_A. Neither trades again before ending valuation. Fractional quantities are allowed; there is no interest, dividend, split, deposit, or withdrawal.
Apply the same proportional rate to purchases and sales. Fixed/minimum fees, taxes, price impact, and partial fills are not implemented.
c = bp / 1000010bp = 0.001 = 0.1%Here c is one cash-deducted proportional charge, not a model of every real trading cost.
2. Reserve cash for the initial purchase cost
For initial cash 1000 and actual purchase notional N:
Purchase notional + purchase cost = initial cashN + cN = 1000N = 1000 / (1 + c)At 10 bp, rounded for display:
| Item | Amount |
|---|---|
| Initial cash | 1000.000000 |
| Actual purchase notional | 999.000999 |
| Purchase cost | 0.999001 |
| Remaining cash | 0.000000 |
Buy-and-hold divides 999.000999… among three assets; the A-only strategy invests the same amount entirely in A. Equal total notionals mean equal entry costs.
Compared with the cost-free investment of 1000, investment falls to 1000 / (1+c), reducing ending valuations proportionally:
Buy-and-hold ending value = 1100 / (1 + c)A-only ending value = 1200 / (1 + c)| Cost rate | Initial purchase cost | Buy-and-hold ending value | Momentum ending value |
|---|---|---|---|
| 0 bp | 0.000000 | 1100.000000 | 1200.000000 |
| 5 bp | 0.499750 | 1099.450275 | 1199.400300 |
| 10 bp | 0.999001 | 1098.901099 | 1198.801199 |
| 20 bp | 1.996008 | 1097.804391 | 1197.604790 |
These are valuations including entry costs but excluding final sale costs. Holdings have not been sold. Rankings remain unchanged because both cost-free ending values are multiplied by the same positive factor 1 / (1+c). This says nothing about strategies with different trading frequency or notionals.
3. Ending valuation differs from cash after liquidation
At 10 bp, buy-and-hold's ending valuation is approximately 1098.901099. Selling everything incurs another charge:
Sale notional = value of holdings at the endSale cost = sale notional × cCash after liquidation = sale notional × (1 - c)| Action | Asset value | Cash | Cost of this action |
|---|---|---|---|
| Value at ending prices | 1098.901099 | 0.000000 | 0.000000 |
| Sell all at ending prices | 0.000000 | 1097.802198 | 1.098901 |
Valuation alone incurs no additional trading cost. The sale charge applies to the value actually sold then, not initial cash 1000.
1100 × (1 - c) / (1 + c)The denominator 1+c accounts for reserving entry-cost cash; numerator 1-c accounts for the final sale charge.
4. Full replacement incurs both sale and purchase costs
Separately from the entry example, start with an existing A holding worth exactly 1000. Sell all A and buy B, with unchanged prices during replacement and 10 bp on each side. This check covers only the current replacement, not historical A acquisition costs.
First sell A:
Sale notional = 1000Sale cost = 1000 × 0.001 = 1Cash after sale = 999Then fund B's purchase and charge together from cash 999:
New purchase notional N = 999 / 1.001 = 998.001998…Purchase cost = N × 0.001 = 0.998002…| Stage | Cash | Asset value | Stage cost |
|---|---|---|---|
| Before replacement | 0.000000 | A: 1000.000000 | — |
| After selling A | 999.000000 | 0.000000 | 1.000000 |
| After buying B | 0.000000 | B: 998.001998 | 0.998002 |
Post-replacement holding value + total cost = pre-replacement wealth998.001998… + 1.998002… = 1000In general:
Pre-replacement holding value = VNew purchase notional = V × (1-c) / (1+c)Total cost = c × (old sale notional + new purchase notional)This formula applies to selling everything and fully reinvesting the remaining cash. It is not a general partial-rebalancing formula.
5. Turnover and cost have different units
For this single replacement, define turnover as:
Turnover T = (sale notional + purchase notional) / pre-trade wealthAdd purchases and sales without a 1/2 factor. Do not count cash balances as additional trades.
T = (1000 + 998.001998…) / 1000 = 1.998001998…The ratio is approximately 1.998002, or 199.8002%. Total cost was also approximately 1.998002, but the units differ: cost is an amount, turnover a ratio to pre-trade wealth.
Total cost = cost rate × turnover × pre-trade wealth = c × T × VTheir numerical equality occurs because c × V = 0.001 × 1000 = 1; changing wealth or the rate removes it. When using turnover from another source, inspect its numerator, denominator, and aggregation period. This article defines a single-replacement measure.
6. Code checking quantities, cash, and costs together
The code uses only the standard library. Integer/fraction inputs and Fraction separate exact accounting checks from rounded display. Python documentation
It implements ledger valuation, full investment from cash, and full liquidation. Replacement calls liquidation followed by purchase. All trades are assumed fully executed at the supplied prices.
from dataclasses import dataclassfrom fractions import Fraction as F@dataclass(frozen=True)class Book: qty: tuple cash: Fdef value(book, prices): if not prices or len(book.qty) != len(prices): raise ValueError("수량과 가격의 자산 수가 맞지 않습니다") if any(p <= 0 for p in prices): raise ValueError("가격은 양수여야 합니다") if book.cash < 0 or any(q < 0 for q in book.qty): raise ValueError("현금과 수량은 음수가 될 수 없습니다") return book.cash + sum( q * p for q, p in zip(book.qty, prices) )def check_rate(c): if not 0 <= c < 1: raise ValueError("비용률은 0 이상 1 미만이어야 합니다")def buy_all(book, prices, weights, c): check_rate(c) before = value(book, prices) if any(book.qty): raise ValueError("이 함수는 현금만 보유한 장부에서 매수합니다") if len(weights) != len(prices) or any(w < 0 for w in weights): raise ValueError("목표비중을 확인하세요") if sum(weights) != 1: raise ValueError("이 예제의 매수비중 합은 1이어야 합니다") bought = book.cash / (1 + c) fee = bought * c qty = tuple( bought * w / p for w, p in zip(weights, prices) ) after = Book(qty, book.cash - bought - fee) assert value(after, prices) + fee == before return after, bought, feedef sell_all(book, prices, c): check_rate(c) before = value(book, prices) sold = before - book.cash fee = sold * c after = Book( (F(0),) * len(prices), book.cash + sold - fee, ) assert value(after, prices) + fee == before return after, sold, feeThe central invariant inside the trading functions is:
assert value(after, prices) + fee == beforeAt the same execution prices, post-trade wealth plus that trade's cost must equal pre-trade wealth. Do not apply this identity unchanged across a holding period with different prices: price gains and losses occur in between.
7. Compare the table with the actual ledger
Append these checks to the function definitions.
Initial purchases and ending valuation
prices = (F(100),) * 3end_prices = tuple(map(F, [120, 90, 120]))initial = Book((F(0),) * 3, F(1000))equal = (F(1, 3),) * 3only_a = (F(1), F(0), F(0))only_b = (F(0), F(1), F(0))print("bp | entry fee | buyhold mark | momentum mark")for bp in (0, 5, 10, 20): c = F(bp, 10000) bh, bought, fee = buy_all( initial, prices, equal, c ) mom, _, mom_fee = buy_all( initial, prices, only_a, c ) assert bought + fee == 1000 assert bh.cash == 0 assert mom_fee == fee assert value(bh, end_prices) == F(1100) / (1 + c) assert value(mom, end_prices) == F(1200) / (1 + c) print( bp, *(f"{float(x):.6f}" for x in ( fee, value(bh, end_prices), value(mom, end_prices), )), )Output:
bp | entry fee | buyhold mark | momentum mark0 0.000000 1100.000000 1200.0000005 0.499750 1099.450275 1199.40030010 0.999001 1098.901099 1198.80119920 1.996008 1097.804391 1197.604790Comparisons use exact fractions; only printed values are rounded to six decimal places.
Final liquidation
c = F(10, 10000)bh, bought, entry_fee = buy_all( initial, prices, equal, c)mark = value(bh, end_prices)closed, sold, exit_fee = sell_all( bh, end_prices, c)assert sold == mark == F(100000, 91)assert exit_fee == F(100, 91)assert closed.cash == F(99900, 91)assert closed.qty == (F(0),) * 3assert closed.cash + exit_fee == markThe final assertion checks that liquidation leaves cash equal to the preceding valuation less sale costs.
Full replacement of existing A with B
# 앞의 최초 매수 사례와 독립된 시작 장부다.existing = Book( (F(10), F(0), F(0)), F(0),)cash_book, sold, sell_fee = sell_all( existing, prices, c)switched, bought, buy_fee = buy_all( cash_book, prices, only_b, c)total_fee = sell_fee + buy_feeturnover = (sold + bought) / value(existing, prices)assert sold == 1000assert sell_fee == 1assert cash_book.cash == 999assert bought == F(999000, 1001)assert buy_fee == F(999, 1001)assert total_fee == F(2000, 1001)assert switched.qty == ( F(0), F(9990, 1001), F(0))assert switched.cash == 0assert value(switched, prices) + total_fee == 1000assert turnover == F(2000, 1001)assert total_fee == c * turnover * 1000Besides both charges, this checks that A quantities disappear and only B quantities remain.
Buying everything without reserving cost cash
Deliberately construct a ledger that buys assets worth 1000 and deducts an additional 1:
bad = Book( (F(10), F(0), F(0)), -F(1),)try: value(bad, prices)except ValueError as error: print("bad entry detected:", error)else: raise AssertionError("현금 초과 사용을 놓쳤습니다")Output:
bad entry detected: 현금과 수량은 음수가 될 수 없습니다The Korean error states that cash and quantities must not be negative.
Assets 1000 plus cash -1 give wealth 999. Wealth fell by the correct charge, but the no-borrowing condition is violated. Conservation alone is insufficient; cash and quantities must satisfy permitted bounds too.
No sale cost for a cash-only ledger
unchanged, sold_again, fee_again = sell_all( closed, end_prices, c)assert unchanged == closedassert sold_again == 0assert fee_again == 0# 평가 함수는 보유 수량과 현금을 바꾸지 않는다.assert value(bh, end_prices) == markassert bh.cash == 0This prevents charging a percentage of cash when there are no assets to sell.
8. Verified scope and remaining limitations
These synthetic calculations and checks ran locally with Python 3.14.5 on 2026-10-24 while preparing the revision, without external packages.
| Check | Result |
|---|---|
| Entry at 0, 5, 10, and 20 bp | Purchase notional plus cost equals initial cash |
| Both ending valuations | Exact agreement with displayed formulas |
| Final liquidation | Zero quantities; cash net of sale cost |
| A-to-B replacement | Both costs and new quantities checked |
| Cost/turnover relationship | total cost = c × T × pre-trade wealth |
| Overspending cash | Negative-cash ledger detected |
| Selling a cash-only ledger | Zero sale notional and cost |
| Valuation alone | Ledger unchanged, no additional charge |
This does not reconstruct the supplied 2026-09-18 execution record cited by the original article. These are new checks using this revision's code and inputs.
Date alignment, actual trading calendars, partial rebalancing, lot restrictions, minimum fees, and rounding rules remain unimplemented. The code is not a complete live-order system.
Ending prices alone reveal no intermediate loss path. Equal final returns can involve different declines; that needs a time series, discussed in loss paths and trading costs.
Read the later SPY/IEF/GLD baseline comparison separately. This article checks synthetic accounting, not actual strategy performance or broker-fee accuracy.
For the title's question, the ranking stays unchanged in this initial-entry example because both strategies receive the same cost factor. Other comparisons require calculating each strategy's actual purchases, sales, and charges before judging the ranking.
Report an error or share feedback
Open a draft with this article’s title and URL. Review the message and recipient before sending.
Open email draftIf no email app opens, copy these details into your usual email service.
Related posts
Quant & Data Research What to Examine Before Returns: Loss Paths and Trading Costs
Reorder identical returns to compare drawdown and recovery, then calculate cumulative cost effects in a separate twelve-month synthetic example.
Quant & Data Research A 12-Month Momentum Backtest with SPY, IEF, and GLD: Comparing Baselines from 2007 to 2025
An executed 2007–2025 comparison of buy-and-hold and 12-month momentum using SPY, IEF, and GLD, with transaction records, costs, interpretation, and reproduction limits.