Forge Fate
Quant & Data Research

Do Transaction Costs Change the Conclusion? Accounting for Entry, Full Replacement, and Liquidation

5 min read

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:

ItemSYN_ASYN_BSYN_C
Initial execution price100100100
Ending valuation price12090120

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.

text
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:

text
Purchase notional + purchase cost = initial cashN + cN = 1000N = 1000 / (1 + c)

At 10 bp, rounded for display:

ItemAmount
Initial cash1000.000000
Actual purchase notional999.000999
Purchase cost0.999001
Remaining cash0.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:

text
Buy-and-hold ending value = 1100 / (1 + c)A-only ending value = 1200 / (1 + c)
Cost rateInitial purchase costBuy-and-hold ending valueMomentum ending value
0 bp0.0000001100.0000001200.000000
5 bp0.4997501099.4502751199.400300
10 bp0.9990011098.9010991198.801199
20 bp1.9960081097.8043911197.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:

text
Sale notional = value of holdings at the endSale cost = sale notional × cCash after liquidation = sale notional × (1 - c)
ActionAsset valueCashCost of this action
Value at ending prices1098.9010990.0000000.000000
Sell all at ending prices0.0000001097.8021981.098901

Valuation alone incurs no additional trading cost. The sale charge applies to the value actually sold then, not initial cash 1000.

text
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:

text
Sale notional = 1000Sale cost = 1000 × 0.001 = 1Cash after sale = 999

Then fund B's purchase and charge together from cash 999:

text
New purchase notional N = 999 / 1.001                       = 998.001998…Purchase cost = N × 0.001              = 0.998002…
StageCashAsset valueStage cost
Before replacement0.000000A: 1000.000000—
After selling A999.0000000.0000001.000000
After buying B0.000000B: 998.0019980.998002
text
Post-replacement holding value + total cost = pre-replacement wealth998.001998… + 1.998002… = 1000

In general:

text
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:

text
Turnover T = (sale notional + purchase notional) / pre-trade wealth

Add purchases and sales without a 1/2 factor. Do not count cash balances as additional trades.

text
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.

text
Total cost = cost rate × turnover × pre-trade wealth           = c × T × V

Their 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.

python
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, fee

The central invariant inside the trading functions is:

python
assert value(after, prices) + fee == before

At 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

python
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:

text
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.604790

Comparisons use exact fractions; only printed values are rounded to six decimal places.

Final liquidation

python
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 == mark

The final assertion checks that liquidation leaves cash equal to the preceding valuation less sale costs.

Full replacement of existing A with B

python
# 앞의 최초 매수 사례와 독립된 시작 장부다.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 * 1000

Besides 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:

python
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:

text
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

python
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 == 0

This 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.

CheckResult
Entry at 0, 5, 10, and 20 bpPurchase notional plus cost equals initial cash
Both ending valuationsExact agreement with displayed formulas
Final liquidationZero quantities; cash net of sale cost
A-to-B replacementBoth costs and new quantities checked
Cost/turnover relationshiptotal cost = c × T × pre-trade wealth
Overspending cashNegative-cash ledger detected
Selling a cash-only ledgerZero sale notional and cost
Valuation aloneLedger 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.

To: [email protected]

Open email draft

If no email app opens, copy these details into your usual email service.

Contact information