pytraderBacktest, paper trade, and automate PSX.
The live pyPSX platform. Validate an idea on 10 years of history, rehearse it in a free paper account with a real fill engine, then let it run on a schedule, locally or as a cloud bot. No broker account needed.
Paper trading is free and live today. Real-money execution through a broker is separate - see the Broker API →
Capabilities
Realistic commission and slippage. Grid-search over parameters. Per-symbol breakdown. Publish your losers.
results = run_backtest(
"ema_crossover",
symbols=index_constituents("KSE100"),
start="2016-01-01",
)Market, limit, stop, stop-limit, with a real fill engine and FIFO lot accounting. The same API surface live execution will use.
client = TradingClient.from_env(paper=True)
client.place_manual_order(
"OGDC", "BUY", 100, "MARKET"
)Real-time ticks over a single WebSocket with auto-reconnect. Quotes, L2 depth, recent trades, key-gated via pytrader.
feed = LiveFeed(symbols=["OGDC", "HBL"], paper=True)
feed.on_tick(lambda t: print(t.symbol, t.price))
feed.start()Describe a strategy in English, get a runnable paper bot. Ask for an indicator we don't support and it tells you, it won't fake it.
# "Buy KMI-30 stocks on EMA20 > EMA50"
# → runnable paper bot configArchitecture
Data flows one direction: fetch, validate against history, rehearse in paper, then ship live.
How it compares.
Honest table. If yfinance did what you needed for PSX, we wouldn't exist.
| Manual | Scraping | yfinance | pyPSX | |
|---|---|---|---|---|
| PSX historical (10y) | n/a | Fragile | ❌ | ✓ |
| Live ticks (WebSocket) | n/a | Polling | ❌ | ✓ |
| Backtesting | ❌ | Build it yourself | US only | ✓ |
| Paper trading | ❌ | ❌ | ❌ | ✓ |
| Maintenance | Daily | Weekly | None | None |