Package: pydhan
PydhanThe official Python client for communicating with theDhan APIPydhan 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 API collection.Dhan(c) 2022. Licensed under the Apache License 2.0DocumentationDhan HTTP API documentationPydhan API documentationPydhan Swagger DocumentationFeaturesGet Order listRetrieve a list of all orders requested in a day with their last updated status.Get Order by IDRetrieve the details and status of an order from the orderbook placed during the day.Modify OrderModify pending order in orderbook. The variables that can be modified are price, quantity, order type & validity.Cancel OrderCancel a pending order in the orderbook using the order id of an order.Place OrderPlace new orders.Get Order by Correlation IDRetrieves the order status using a field called correlation id, Provided by API consumer during order placement.Get PositionsRetrieve a list of all open positions for the day. This includes all F&O carryforward positions as well.Get HoldingsRetrieve all holdings bought/sold in previous trading sessions. All T1 and delivered quantities can be fetched.Intraday Daily Minute ChartsRetrieve OHLC & Volume of 1 minute candle for desired instrument for current day. This data available for all segments including futures & options.Historical Minute ChartsRetrieve OHLC & Volume of daily candle for desired instrument. The data for any scrip is available back upto the date of its inception.Get trade bookRetrieve a list of all trades executed in a day.Get trade historyRetrieve 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 limitsGet all information of your trading account like balance, margin utilised, collateral, etc.QuickstartYou can install the package via pippip install pydhanHands-onfrompydhanimportpydhandhan=pydhan("client_id","access_token")# Place an order for Equity Cashdhan.place_order(security_id='1333',#hdfcbankexchange_segment=dhan.NSE,transaction_type=dhan.BUY,quantity=10,order_type=dhan.MARKET,product_type=dhan.INTRADAY,price=0)# Place an order for Futures & Optionsdhan.place_order(security_id='52175',#hdfcbankexchange_segment=dhan.FNO,transaction_type=dhan.BUY,quantity=550,order_type=dhan.MARKET,product_type=dhan.INTRA,price=0)# Place an order for Currencydhan.place_order(security_id='10093',#usdinrexchange_segment=dhan.CUR,transaction_type=dhan.BUY,quantity=1,order_type=dhan.MARKET,validity=dhan.DAY,product_type=dhan.INTRA,price=0)# Place an order for BSE Equitydhan.place_order(security_id='500180',#hdfcbankexchange_segment=dhan.BSE,transaction_type=dhan.BUY,quantity=1,order_type=dhan.MARKET,product_type=dhan.INTRA,price=0,)# Place an order for MCX Commoditydhan.place_order(security_id='114',#goldexchange_segment=dhan.BSE,transaction_type=dhan.BUY,quantity=1,order_type=dhan.MARKET,product_type=dhan.INTRA,price=0)# Fetch all ordersdhan.get_order_list()# Get order by iddhan.get_order_by_id(order_id)# modify orderdhan.modify_order(order_id,order_type,leg_name,quantity,price,trigger_price,disclosed_quantity,validity)# Cancel orderdhan.cancel_order(order_id)# Get order by correlation iddhan.get_order_by_corelationID(corelationID)# Get positionsdhan.get_positions()# Get holdingsdhan.get_holdings()# Intraday daily minute chartsdhan.intraday_daily_minute_charts(security_id,exchange_segment,instrument_type)# Historical Minute chartsdhan.historical_minute_charts(symbol,exchange_segment,instrument_type,expiry_code,from_date,to_date)# Get trade bookdhan.get_trade_book(order_id)# Get trade historydhan.get_trade_history(from_date,to_date,page_number=0)# Get fund limitsdhan.get_fund_limits()Refer to thePython client documentationfor the complete list of supported methods.ChangelogCheck release notes