Skip to content

Souparno467/transaction-slippage-estimator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transaction Slippage Estimator

A Streamlit app that estimates pre-trade transaction costs using a bid-ask spread model and a square-root market impact model (Almgren-Chriss simplified).

Features

  • Spread slippage + market impact cost breakdown
  • Risk classification (Low / Medium / High / Very High)
  • Actionable execution tips per risk level
  • Scenario table: how slippage scales with order size
  • Custom bid/ask/volatility overrides in sidebar

Setup

pip install -r requirements.txt
streamlit run app.py

Project Structure

transaction-slippage-estimator/
├── app.py                      # Streamlit UI
├── src/
│   ├── slippage_calculator.py  # Spread & market impact models
│   └── risk_model.py           # Risk classification & tips
├── utils/
│   └── helpers.py              # Data loading & formatting
├── data/
│   └── *.csv                   # Put your CSV(s) here; app lets you pick one
├── tests/
│   └── test_slippage.py
└── requirements.txt

CSV Format

Preferred CSV includes these columns:

Column Description
symbol Ticker symbol
close Last close price
bid Best bid
ask Best ask
avg_daily_volume Average daily share volume

Optional: volume, open, high, low, market_cap

If your CSV has a different schema (e.g., NSE snapshots with LTP + VOLUME (shares)), the app will try to normalize it automatically by:

  • mapping LTP/PREV. CLOSE to close
  • mapping VOLUME (shares) to avg_daily_volume
  • deriving bid/ask from close when missing

Models

Spread Slippage = (ask - bid) / mid / 2 (one-way half-spread)

Market Impact = volatility × √(order_shares / ADV) (Almgren-Chriss square-root law)

Total Slippage = Spread + Market Impact

Running Tests

pytest tests/

Releases

No releases published

Packages

 
 
 

Contributors

Languages