How dhan-oss/dhanhq-py works
DhanHQ-py is the official Python client for Dhan’s trading and market-data APIs. The main workflow is: a user obtains credentials through authentication, creates a connection context and client, then invokes trading, account, or data operations; the client sends REST requests through a shared HTTP layer and returns API responses. Separate WebSocket clients provide live market, full-depth, and US-stock feeds. The README documents the broader feature set; several service modules are represented from their names and documented capabilities because their source was not sampled.
Main entry points: dhanhq.py DhanHQ client · dhan_http.py REST transport · dhan_context.py DhanContext · auth.py DhanLogin
Components 23
Connection and Auth
- DhanLogin
src/dhanhq/auth.py - DhanContext
src/dhanhq/dhan_context.py - REST transport
src/dhanhq/dhan_http.py - DhanHQ client
src/dhanhq/dhanhq.py
Trading Operations
- Orders
src/dhanhq/_order.py - Conditional orders
src/dhanhq/_conditional_order.py - Forever orders
src/dhanhq/_forever_order.py - Super orders
src/dhanhq/_super_order.py - Trader controls
src/dhanhq/_trader_control.py
Account and Instruments
- Portfolio
src/dhanhq/_portfolio.py - Funds and margin
src/dhanhq/_funds.py - Statements and reports
src/dhanhq/_statement.py - eDIS and securities
src/dhanhq/_security.py
Market Data
- Historical data
src/dhanhq/_historical_data.py - Quotes and option chain
src/dhanhq/_market_feed.py - Option chain
src/dhanhq/_option_chain.py - Live market feed
src/dhanhq/marketfeed.py - Full market depth
src/dhanhq/fulldepth.py
Global Stocks
- Global stock operations
src/dhanhq/_global_stocks.py - Global stocks feed
src/dhanhq/global_stocks_feed.py
Other components
- Client application
- Dhan API
- Dhan WebSocket services
Connections 40
- Client application → DhanLogin: authenticates
- DhanLogin → Dhan API: requests tokens
- Client application → DhanContext: provides credentials
- DhanContext → REST transport: creates transport
- DhanContext → DhanLogin: creates login
- Client application → DhanHQ client: invokes client
- DhanHQ client → DhanContext: uses context
- DhanHQ client → Orders: delegates orders
- DhanHQ client → Conditional orders: delegates conditions
- DhanHQ client → Forever orders: delegates orders
- DhanHQ client → Super orders: delegates orders
- DhanHQ client → Trader controls: delegates controls
- DhanHQ client → Portfolio: delegates portfolio
- DhanHQ client → Funds and margin: delegates funds
- DhanHQ client → Statements and reports: delegates reports
- DhanHQ client → eDIS and securities: delegates securities
- DhanHQ client → Historical data: delegates history
- DhanHQ client → Quotes and option chain: delegates quotes
- DhanHQ client → Option chain: delegates options
- DhanHQ client → Global stock operations: delegates global trades
- Orders → REST transport: sends requests
- Conditional orders → REST transport: sends requests
- Forever orders → REST transport: sends requests
- Super orders → REST transport: sends requests
- Trader controls → REST transport: sends requests
- Portfolio → REST transport: sends requests
- Funds and margin → REST transport: sends requests
- Statements and reports → REST transport: sends requests
- eDIS and securities → REST transport: sends requests
- Historical data → REST transport: sends requests
- Quotes and option chain → REST transport: sends requests
- Option chain → REST transport: sends requests
- Global stock operations → REST transport: sends requests
- REST transport → Dhan API: sends REST
- Client application → Live market feed: subscribes
- Client application → Full market depth: subscribes
- Client application → Global stocks feed: subscribes
- Live market feed → Dhan WebSocket services: opens feed
- Full market depth → Dhan WebSocket services: opens feed
- Global stocks feed → Dhan WebSocket services: opens feed