Skip to main content

The official Python client for communicating with the Dhan API

Project description

DhanHQ - v1.0

The official Python client for communicating with the Dhan API

DhanHQ Rest API is used to automate investing and trading. Order execution in real time, Portfolio management, Check positions, holdings, funds and more with the simple HTTP API collection.

Dhan (c) 2022. Licensed under the Apache License 2.0



  • Get Order list
    Retrieve a list of all orders requested in a day with their last updated status.

  • Get Order by ID
    Retrieve the details and status of an order from the orderbook placed during the day.

  • Modify Order
    Modify pending order in orderbook. The variables that can be modified are price, quantity, order type & validity.

  • Cancel Order
    Cancel a pending order in the orderbook using the order id of an order.

  • Place Order
    Place new orders.

  • Get Order by Correlation ID
    Retrieves the order status using a field called correlation id, Provided by API consumer during order placement.

  • Get Positions
    Retrieve a list of all open positions for the day. This includes all F&O carryforward positions as well.

  • Get Holdings
    Retrieve all holdings bought/sold in previous trading sessions. All T1 and delivered quantities can be fetched.

  • Intraday Daily Minute Charts
    Retrieve OHLC & Volume of 1 minute candle for desired instrument for current day. This data available for all segments including futures & options.

  • Historical Minute Charts
    Retrieve OHLC & Volume of daily candle for desired instrument. The data for any scrip is available back upto the date of its inception.

  • Get trade book
    Retrieve a list of all trades executed in a day.

  • Get trade history
    Retrieve the trade history Often during partial trades or Bracket/ Cover Orders, traders get confused in reading trade from tradebook. The response of this API will include all the trades generated for a particular order id.

  • Get fund limits
    Get all information of your trading account like balance, margin utilised, collateral, etc.


You can install the package via pip

pip install dhanhq


from dhanhq import dhanhq

dhan = dhanhq("client_id","access_token")

# Place an order
dhan.place_order(security_id= '1333' #hdfc bank
    exchange_seg= 'NSE_EQ'
    transaction_type= 'BUY'
    validity= 'DAY'
    product_type= 'INTRADAY'

# Fetch all orders

# Get order by id

# modify order
dhan.modify_order(order_id, order_type, leg_name, quantity, price, trigger_price, disclosed_quantity, validity)

# Cancel order

# Get order by correlation id

# Get positions

# Get holdings

# Intraday daily minute charts

# Historical Minute charts

# Get trade book

# Get trade history

# Get fund limits

Refer to the Python client documentation for the complete list of supported methods.


Check release notes

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

dhanhq-1.0.tar.gz (5.0 kB view hashes)

Uploaded source

Built Distribution

dhanhq-1.0-py3-none-any.whl (5.5 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page