Algo Trading · pytrader

Backtest, 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

Backtesting

Realistic commission and slippage. Grid-search over parameters. Per-symbol breakdown. Publish your losers.

python
results = run_backtest(
    "ema_crossover",
    symbols=index_constituents("KSE100"),
    start="2016-01-01",
)
Paper trading

Market, limit, stop, stop-limit, with a real fill engine and FIFO lot accounting. The same API surface live execution will use.

python
client = TradingClient.from_env(paper=True)
client.place_manual_order(
    "OGDC", "BUY", 100, "MARKET"
)
Live market data

Real-time ticks over a single WebSocket with auto-reconnect. Quotes, L2 depth, recent trades, key-gated via pytrader.

python
feed = LiveFeed(symbols=["OGDC", "HBL"], paper=True)
feed.on_tick(lambda t: print(t.symbol, t.price))
feed.start()
Strategy Copilot

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.

python
# "Buy KMI-30 stocks on EMA20 > EMA50"
# → runnable paper bot config

Architecture

Data flows one direction: fetch, validate against history, rehearse in paper, then ship live.

Data
pypsx
OHLCV, fundamentals, live feed
Validate
run_backtest()
commission, slippage, sharpe
Paper
TradingClient
market/limit/stop, WebSocket fills
Live
coming soon
broker routing, custody

How it compares.

Honest table. If yfinance did what you needed for PSX, we wouldn't exist.

ManualScrapingyfinancepyPSX
PSX historical (10y)n/aFragile
Live ticks (WebSocket)n/aPolling
BacktestingBuild it yourselfUS only
Paper trading
MaintenanceDailyWeeklyNoneNone