6.2.6 · HinglishBacktesting Frameworks

Learn about slippage assumptions

2,680 words12 min readRead in English

6.2.6 · Stock-Market › Backtesting Frameworks

Slippage Kya Hai?

YEH KYUN hoti hai: Markets infinitely liquid nahi hote. Bade orders har price level par available liquidity consume kar lete hain, jo baad ke fills ko worse prices par force karta hai. Chhote orders bhi bid-ask spread face karte hain—jo ek guaranteed minimum slippage hai.

YEH KAISE dikhti hai: Tum tab buy karne ka decide karte ho jab price 50.05 ho jaata hai. Tumhara fill 0.05 = 10 basis points.

Slippage Models ko First Principles se Derive Karna

1. Fixed Slippage Model

Assumption: Har trade ek constant slippage pay karta hai (basis points mein ya absolute dollars mein).

Derivation:

  • Buy karte waqt expected fill price:
  • Sell karte waqt expected fill price:

YEH FORM KYUN? Yeh sabse simple model hai: average market conditions assume karta hai aur volatility, order size, aur liquidity variations ko ignore karta hai.

Example: Buy 100 shares at s = 0.001$ (10 bps)

  • Expected fill:
  • Slippage cost: 100 \times 50 \times 0.001 = \5$

Yeh step kyun? Price se multiply karne par basis points dollars mein convert ho jaate hain. Absolute value ensure karta hai ki slippage hamesha ek cost ho, kabhi gain nahi. Conversion dhyaan se karo: 5 bps hai (na ki )—yahaan ek factor-of-10 ki galti silently tumhare costs ko tenfold inflate kar deti hai.

2. Volume-Dependent Slippage Model

Assumption: Average volume ke relative bade orders zyada worse slippage experience karte hain.

Market microstructure se Derivation:

  • Order book mein har price level par depth hoti hai
  • Tumhara order book ko walk up karta hai, liquidity consume karta hai
  • Average fill price consumed levels ka volume-weighted average hota hai

Average volume wale market mein size ke market order ke liye:

SQUARE ROOT KYUN? Yeh market impact ka empirical "square-root law" hai, jo bahut saare baad ke microstructure studies mein documented hai (jaise Almgren, Toth, Bouchaud). Note karo: Kyle ka original 1985 lambda model linear impact imply karta hai (); scaling ek empirical regularity hai jo real trade data mein observe ki gayi hai, Kyle's model ka direct consequence nahi. Intuitively, square root diminishing marginal impact capture karta hai—orders split karne wale informed traders unlimited profit extract nahi kar sakte.

Example: , ,

  • bps
  • 1000 \times 50 \times 0.01 = $500$

Yeh step kyun? Square root diminishing returns capture karta hai—order size double karne se impact double nahi hoti. Volume se divide karna different liquidity regimes mein normalize karta hai.

3. Volatility-Adjusted Slippage

Assumption: High volatility → prices tezi se move hoti hain → zyada slippage.

Derivation:

  • Latency (execution tak ka time) ke dauran, price volatility ke saath random walk follow karta hai
  • Expected price move:
  • Worst-case (directional): tumhare against

ke liye unit convention: Kyunki annualized hai, ko ek year ke fraction ke roop mein express karna zaroori hai. Examples:

  • Aadha trading day: years
  • Ek pura trading day: years
  • Kuch seconds ki latency: essentially is scale par hai, isliye intraday HFT models aksar per-second volatility use karte hain.

Example (half-day latency): (30% annual), years

  • bps

Yeh step kyun? Hum use karte hain kyunki price diffusion square root of time ke saath scale hoti hai (Brownian motion). Factor yeh acknowledge karta hai ki tumhe hamesha worst-case move nahi milta.

4. Combined Slippage Model

Real-world mein: Saare effects ek saath hote hain.

Example: Trade 500 shares, , , years (~quarter trading day)

  • Fixed: bps
  • Volume: bps
  • Volatility: bps
  • Total: bps

Yeh step kyun? Dhyaan se note karo: volume term equals bps hai (kyunki bps, aur ), 10 bps nahi. 500-share ka order jo daily volume ka 1% hai, already significant impact generate karta hai—yeh ek aur reminder hai bps conversions seedhe rakhne ka ().

Backtest Mein Slippage Implement Karna

Step-by-step:

  1. Apna model choose karo strategy frequency ke basis par:

    • High-frequency (seconds): volatility + volume model use karo
    • Medium-frequency (minutes-hours): volume + fixed use karo
    • Low-frequency (daily+): fixed slippage aksar kaafi hoti hai
  2. Parameters calibrate karo real execution data se:

    • 100+ trades par actual fill prices vs. decision prices measure karo
    • , , ko error minimize karne ke liye fit karo
    • Agar real data nahi hai: conservative estimates use karo (retail ke liye 10-20 bps, institutional ke liye 2-5 bps)
  3. Har trade par apply karo:

    # Pseudocode for backtest engine
    def execute_order(decision_price, quantity, volume, volatility):
        s_fixed = 0.0005  # 5 bps  (recall: 1 bp = 0.0001)
        s_volume = 0.1 * sqrt(abs(quantity) / volume)
        s_volatility = 0.5 * volatility * sqrt(latency_in_years)
        total_slippage = s_fixed + s_volume + s_volatility
     
        if quantity > 0:  # Buy
            fill_price = decision_price * (1 + total_slippage)
        else:  # Sell
            fill_price = decision_price * (1 - total_slippage)
     
        return fill_price

Yeh structure kyun? Slippage directional hoti hai—hamesha tumhe hurt karti hai. Buys mein worse fills milte hain (higher price), sells mein worse fills milte hain (lower price).

Recall Ek 12-Saal ke Bacche ko Explain Karo

Socho tum ek lemonade stand par ho jo har minute prices post karta hai. Tum dekhte ho "Lemonade: 1.10" kyunki paanch aur bacchon ne pehle buy kar liya aur ab kam lemonade bacha hai. Tumhe $1.10 dena hi padega kyunki tum pehle se commit ho chuke the. Yeh extra 10¢ slippage hai.

Bade buyers ke liye yeh aur bura hota hai: agar tum 10 lemonades chahte ho aur stand par sirf 3 1.20 mein hain, aur aakhri 4 1 se kaafi zyada hai. Yahi market impact hai.

Stock trading mein yeh hazaaron baar hota hai. Agar tum apni strategy test karte waqt iska account nahi karte, tumhara backtest sochta hai tum paisa kama rahe ho, lekin real life mein, tum har trade par extra pay kar rahe ho. Yeh aisa hai jaise pizza ke liye budget banate waqt delivery fee bhool jaao!

Connections

  • Transaction costs aur unka impact – slippage total transaction costs ka ek component hai
  • Realistic order execution modeling – slippage ko partial fills aur fill probability ke saath extend karta hai
  • Market microstructure basics – order book dynamics explain karta hai ki slippage kyun exist karti hai
  • Look-ahead bias – slippage ignore karna look-ahead bias ka ek form hai (perfect execution assume karta hai)
  • Position sizing – slippage costs position size ke saath scale hoti hain, optimal sizing ko affect karti hain

#flashcards/stock-market

Trading mein slippage kya hai?
Trade ki expected price (decision price) aur actual execution price ke beech ka difference, jo market impact, latency, liquidity constraints, aur bid-ask spread se hota hai.
Slippage ke chaar main sources kya hain?
(1) Market impact – tumhara order price ko tumhare against move karta hai, (2) Latency – decision aur execution ke beech price badal jaati hai, (3) Liquidity constraints – target price par insufficient volume, (4) Spread crossing – ask pay karna/bid receive karna.
1 basis point decimal mein kya hota hai, aur 5 bps kya hoga?
1 bp = 0.0001 (ek percent ka sauwaan hissa). Toh 5 bps = 0.0005, 0.005 NAHI. Ek misplaced zero costs ko 10× inflate kar deta hai.
Kya √(Q/V) market-impact law Kyle's 1985 model se derive hoti hai?
Nahi. Kyle ka original lambda model LINEAR impact imply karta hai (ΔP = λ·Q). Square-root law ek empirical regularity hai jo baad ke microstructure studies (Almgren, Toth, Bouchaud) mein mili, Kyle's model ka consequence nahi.
Chhote orders par bhi tum minimum kitni slippage pay karte ho?
Bid-ask spread ka half, kyunki market orders hamesha spread cross karte hain (ask par buy, bid par sell). Real markets mein yeh kabhi zero nahi hoti.
Fixed slippage formula total cost ke liye?
Slippage Cost = |Q| × P × s, jahaan Q quantity hai, P decision price hai, s slippage rate hai (jaise 10 bps ke liye 0.001). Absolute value ensure karta hai ki slippage hamesha cost ho.
Volatility slippage kyun badhata hai?
Execution latency τ ke dauran, price volatility σ ke saath random walk follow karti hai. Expected adverse price move σ√τ ke saath scale hoti hai (Brownian motion). Zyada volatility → tumhara order in-flight rehte waqt zyada price changes.
Volatility slippage formula mein τ ko years mein kyun express karna zaroori hai?
Kyunki σ annualized hoti hai. Units consistent rakhne ke liye, τ ek year ka fraction hona chahiye: jaise aadha trading day = 0.5/252 ≈ 0.002 years, ek trading day = 1/252 ≈ 0.004 years.
Combined slippage model formula?
s_total = s_fixed + α√(Q/V) + kσ√τ, jahaan s_fixed base slippage hai, α impact coefficient hai, Q/V order-to-volume ratio hai, σ volatility hai, τ latency years mein hai.
Slippage ignore karne par backtests returns kyun dramatically overestimate karte hain?
High-turnover strategies har round-trip (buy + sell) par slippage pay karti hain. 50 trades/year mein 10 bps per side ke saath, total cost 50 × 20 bps = 1000 bps = 10% annual drag hoti hai. Yeh zyatsar ya poora alpha khatam kar sakta hai.
Limit orders ke saath "adverse selection" problem kya hai?
Limit orders tab fill hote hain jab price tumhare against move kare (adverse selection) aur tab miss hote hain jab price tumhare favor mein move kare. Inhe "zero slippage" model nahi kar sakte – fill probability aur missed fills ki opportunity cost account karni padti hai.
Slippage modeling ke liye average volatility use karna galat kyun hai?
Volatility cluster hoti hai—earnings, news, market stress ke dauran spike karti hai. Slippage exactly tab sabse buri hoti hai jab volatility sabse zyada hoti. 30-day average use karne se critical high-volatility periods mein slippage underestimate hoti hai. Recent realized volatility use karo.

Concept Map

hai

cause karta hai

arise hoti hai

arise hoti hai

arise hoti hai

arise hoti hai

model hoti hai

model hoti hai

assume karta hai

cost formula

derive hota hai

square-root law

drive karta hai

guarantee karta hai

Slippage

Expected aur actual price ke beech ka gap

Backtest overconfidence

Market impact se

Latency se

Liquidity constraints se

Spread crossing se

Fixed slippage model se

Volume-dependent model se

Constant rate s in bps

Qty x Price x s

Market microstructure se

Impact scales with sqrt Q over V

Minimum slippage per trade