Skip to main content

brokerkit-core

The framework half of BrokerKit: the models, the interfaces every broker adapter implements, and the assembly layer that resolves create_broker("zerodha", ...) to a live, authenticated broker.

This package ships no broker integrations. Install it alongside at least one adapter.

pip install brokerkit-core brokerkit-zerodha

Available adapters: brokerkit-groww, brokerkit-fyers, brokerkit-upstox, brokerkit-dhan, brokerkit-angelone, brokerkit-zerodha.

The idea

Every Indian broker ships its own SDK with its own auth flow, symbol format, units (some report prices in paise, some in rupees), error convention (some raise, some return a failure dict, some return status: false and only log it) and its own idea of what a "quote" contains. brokerkit-core defines one typed, async contract; each adapter absorbs its broker's quirks behind it.

from brokerkit import create_broker

broker = await create_broker("zerodha", api_key=..., api_secret=..., access_token=...)

instruments = await broker.instruments.fetch_instruments()
reliance = next(i for i in instruments if i.symbol == "RELIANCE")

quote = await broker.market.get_quote(reliance)
print(quote.last_price, quote.volume)

await broker.close()

Swap "zerodha" for "fyers" and nothing else changes.

The contract

Every broker exposes the same providers:

Attribute Interface Methods
broker.auth AuthProvider login, get_token
broker.instruments InstrumentProvider fetch_instruments
broker.orders OrderProvider place_order, modify, cancel, get_order, list_orders
broker.portfolio PortfolioProvider holdings, positions
broker.market MarketDataProvider get_quote, get_ltp, get_ohlc, get_option_chain
broker.historical HistoricalDataProvider get_candles
broker.streaming StreamingProvider subscribe_ltp, unsubscribe_ltp, close

Plus three interfaces that only some brokers implement, deliberately kept off the shared Broker base so no broker is forced to carry a hole: ChargesProvider, FundamentalsProvider, NewsProvider, MarketInformationProvider.

Design decisions worth knowing

  • Async-native. Every interface method is async def. Adapters wrap sync vendor SDKs with asyncio.to_thread; blocking calls never run inside an interface method.
  • Pydantic v2 models, Decimal prices. Validation at construction, JSON-serializable for API/agent layers. Enums are stdlib StrEnum.
  • Instruments are a thin adapter, not a store. fetch_instruments() downloads, normalizes and returns — the framework holds no cache, no indexes, no lookups. Storage and querying belong to your app. Calling it again re-downloads, because brokers update masters daily.
  • Instance-scoped state only. No module-level tokens, clients or caches, so one process can hold several accounts. BrokerManager composes N named brokers on top of that.
  • Adapters are plugins. Core never imports an adapter. create_broker("dhan", ...) lazily imports brokerkit_dhan, whose Broker subclass self-registers via __init_subclass__. Adding a broker touches no core code.

Models

Instrument, Order / OrderRequest, Position, Holding, Quote / Ohlc / DepthLevel, Candle, Tick, OptionChain / OptionContract / OptionGreeks, BrokerageCharges, and the fundamentals/news/market-information models.

Two cross-broker facts these encode:

  • Tick.minute_ohlc only ever populates for Upstox — it is the one broker whose feed computes a live 1-minute candle server-side. Everywhere else it stays None and you aggregate ticks yourself.
  • Instrument.isin is None for Angel One and Zerodha — their instrument masters have no ISIN column at all. ISIN is the natural cross-broker join key for equities, so join those two on exchange_token instead; it matches exactly across Groww, Fyers, Dhan and Zerodha.

Multiple accounts

from brokerkit import BrokerManager

manager = BrokerManager()
await manager.add("main", "zerodha", api_key=..., api_secret=..., access_token=...)
await manager.add("data", "fyers", client_id=..., secret_key=..., ...)

quote = await manager["data"].market.get_quote(instrument)
await manager.close_all()

License

MIT © 2026 Aditya Vishwakarma

Download files

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

Source Distribution

brokerkit_core-1.0.3.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

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

brokerkit_core-1.0.3-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file brokerkit_core-1.0.3.tar.gz.

File metadata

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

File hashes

Hashes for brokerkit_core-1.0.3.tar.gz
Algorithm Hash digest
SHA256 53d99c0e9499ccabefd75b874b58a32460f77749ee86ac6699378359ed2aae75
MD5 31f4aa9334d14c078ef2dea91d2f2837
BLAKE2b-256 e53fbd1e71e90fe6249837040445685e46780dd0d571fd3b5453725eab917e9b

See more details on using hashes here.

File details

Details for the file brokerkit_core-1.0.3-py3-none-any.whl.

File metadata

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

File hashes

Hashes for brokerkit_core-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5dc1a8dc5e174b075e2641304fa3b946115da65c3e0dadee4d1981c5179c06fe
MD5 25e816f6504322ee8386bd192c9b890b
BLAKE2b-256 b16af5c93bd49d1127d52c32c3a53b25d56cd455d8d0cb07c2df62a2aea58d4b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page