Skip to main content

Python SDK for TSETMC

Project description

orbo

Tehran Stock Exchange data, done right.

فارسی  ·  PyPI Python License: MIT


orbo is a Python SDK for TSETMC. It turns raw API responses into clean, Jalali-dated DataFrames — with price adjustment, order-flow classification, and live data built in.

import orbo

stock = orbo.Instrument("شپنا")

# Adjusted daily history — Jalali dates, derived returns
df = stock.history(adjust=True)
#         date      open    high     low   close  volume
# 0  1394-01-05  7,230.0  7,420.0  7,210.0  7,380.0  3.2M
# …
# 1403-11-22   41,250.0  42,100.0  41,100.0  41,900.0  8.7M

# Return distribution
stats = stock.stats()
print(stats.descriptive["std"])         # daily return std
print(stats.distribution["tail_type"])  # fat_tail / thin_tail / normal_tail

# Intraday order flow
session    = stock.intraday("20260628")
classified = orbo.TradeSideEngine().classify(session.trades, session.orderbook)
result     = orbo.FootprintEngine().build(classified)
print(result.poc_price)    # Point of Control — highest-volume price
print(result.total_delta)  # net buy pressure for the session

Install

pip install orbo

Requires Python ≥ 3.11. Works from inside Iran without VPN.


What it does

stock.history(adjust=True) Full OHLCV history, price-adjusted for dividends and capital increases
stock.today() Live current-session price
stock.stats() Daily/monthly/yearly returns, skewness, kurtosis, tail type
stock.intraday(date) Trades, order book, price tape, shareholders, client-type flows
stock.live() Live price + trades + 5-level book + real/legal flows in one call
TradeSideEngine Lee-Ready aggressor classification (Quote Rule + Tick Rule)
FootprintEngine Per-price buy/sell volume, delta, POC, imbalance flags
OptionChain.fetch() Full listed option chain with moneyness — refreshable live
find_index("شاخص كل") TSE/OTC indices — history, intraday, constituent companies

Examples

Price history and statistics

stock = orbo.Instrument("فملی")
df    = stock.history(adjust=True, count=252)   # last year, adjusted

stats = stock.stats(adjust=True)
print(stats.descriptive)   # mean, median, std, min, max, range
print(stats.monthly)       # compounded monthly returns table
print(stats.distribution)  # skewness, kurtosis, fat-tail classification

Intraday order flow → footprint

session = orbo.Instrument("شپنا").intraday("20260628")

# Classify each trade as aggressive buy or sell (Lee-Ready algorithm)
classified = orbo.TradeSideEngine().classify(
    session.trades,
    session.orderbook,   # enables Quote Rule; falls back to Tick Rule
)

# Aggregate into per-price footprint bars
fp = orbo.FootprintEngine().build(classified)
print(fp.bars[["price","buy_volume","sell_volume","delta","imbalance"]])
print(fp.summary())

Option chain

chain = orbo.OptionChain.fetch()             # full snapshot, all markets
chain.refresh()                              # update prices in-place

print(chain.underlyings)                     # ["اهرم", "توان", ...]
df = chain.for_expiry("اهرم", "1405-05-31") # one strike table
print(chain.summary())                       # n_strikes + OI per expiry

Market indices

idx = orbo.find_index("شاخص كل")    # search by name
df  = idx.history()                  # full daily values, Jalali dates

stats = idx.stats()
print(stats.yearly)

Batch intraday with automatic retry

sessions, failed = orbo.fetch_intraday_range(
    inscode = "7745894403636165",
    dates   = ["20260622", "20260623", "20260624", "20260625"],
    fields  = ["trades", "orderbook"],
)
# failed → dates that didn't come through after all retry rounds

Architecture

orbo/
├── clients/        httpx wrappers — retry on every call
├── data/           transformers — JSON → typed DataFrames, Jalali dates
├── engines/        pure computation — no network, fully testable
│   ├── adjustment  backward cumulative price adjustment
│   ├── trade_side  Lee-Ready aggressor classification
│   ├── footprint   per-price order-flow aggregation
│   ├── daily_stats return series + distribution stats
│   └── intra_stats VWAP + tick-level distribution
├── registry/       local Parquet cache for symbol → inscode lookup
└── instrument.py   unified high-level entry point

Engines never touch the network. Transformers own all renaming and date conversion. Clients retry automatically (3 attempts, exponential backoff).


Coming next — orbo-quant

A separate library that reads from orbo and adds options analytics: Black-Scholes pricing, Greeks (Δ Γ Θ ν ρ), implied volatility, IV surface, strategy builder, and portfolio optimization.

orbo stays focused on data. Analytics live in orbo-quant.


Development

git clone https://github.com/ORBO-ir/ORBO.git
cd ORBO
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest tests/ -v

License

MIT © 2026 — ORBO-ir

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orbo-0.2.4.tar.gz (69.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orbo-0.2.4-py3-none-any.whl (65.0 kB view details)

Uploaded Python 3

File details

Details for the file orbo-0.2.4.tar.gz.

File metadata

  • Download URL: orbo-0.2.4.tar.gz
  • Upload date:
  • Size: 69.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for orbo-0.2.4.tar.gz
Algorithm Hash digest
SHA256 d3e0346ec75d304976dced4389259d3516def5d77cfbd403c5c38eaba07893df
MD5 548cb6d685a8b45d7c1001cdc5ab2711
BLAKE2b-256 1edf98c8d64b83647fb6beb02ab654496c5fde1a6a70c4f186e0273309d3a087

See more details on using hashes here.

File details

Details for the file orbo-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: orbo-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 65.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for orbo-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1a03bea6da4a2b6786a0001d5a2787e544e1a8e3c45a5e3af8d4fbfb5fce2870
MD5 16303042914e7600097b93be5723b77f
BLAKE2b-256 8b3a273d8b9e74c522c8e6ccc767c8a6330ba5c58f4102828ff22c861401f188

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page