Skip to main content

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

Documentation

Features

  • 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.

Quickstart

You can install the package via pip

pip install dhanhq

Hands-on

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'
    quantity=10
    order_type='MARKET'
    validity= 'DAY'
    product_type= 'INTRADAY'
    price=0
    trigger_price=0)
    


# Fetch all orders
dhan.get_order_list()

# Get order by id
dhan.get_order_by_id(order_id)

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

# Cancel order
dhan.cancel_order(order_id)

# Get order by correlation id
dhan.get_order_by_corelationID(corelationID)

# Get positions
dhan.get_positions()

# Get holdings
dhan.get_holdings()

# Intraday daily minute charts
dhan.intraday_daily_minute_charts(security_id,exchange_segment,instrument_type)

# Historical Minute charts
dhan.historical_minute_charts(symbol,exchange_segment,instrument_type,expiry_code,from_date,to_date)

# Get trade book
dhan.get_trade_book(order_id)

# Get trade history
dhan.get_trade_history(from_date,to_date,page_number=0)

# Get fund limits
dhan.get_fund_limits()

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

Changelog

Check release notes

Metadata

Release files for dhanhq 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dhanhq 1.0
File Size Uploaded
dhanhq-1.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dhanhq 1.0
File Interpreter ABI Platform
dhanhq-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / dhanhq-1.0.tar.gz

Download URL dhanhq-1.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9a9a15697a7cb555de0c75d714ed421ecb1f1a03c7ae82741453901e1af840d6
BLAKE2b-256 checksum
How to use checksums
307329f6c2de50b77f29bb3d8afb019983922ac48222fe01c0eed5fe4504d4bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / dhanhq-1.0-py3-none-any.whl

Download URL dhanhq-1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b77eec606066b2d79036a40e7897f469fc4199af13233fbf42daa42f2bf3b32d
BLAKE2b-256 checksum
How to use checksums
6a76909d13f8199117df6f7917e55939f6723c08d76de2b4f187bcf1a6248ff4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2

1 release file

1.1

1 release file

This release

1.0 This release

2 release 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