Hi @sac777 Welcome to Dhan community. Are you referring to Markets Feeds APIs or something else?
Thanks. Please resolve this BUG. For positions API, both realized and unrealized fields are coming as zero for open position
‘realizedProfit’: 0.0, ‘unrealizedProfit’: 0.0,
Hi @ssn
These values need to be computed using the APIs itself on the frontend. Its simple sum of all the positions in either states. We will update the documentation to ensure this is communicated as well.
hi @t7support we usually release APIs after achieving product-market fit. At this point of time, we are enhancing a lot on backend systems and calculations and more. Will release once we are at a comfortable stage.
I am trying to use the Dhan Pyhton API for creating a Algo.
As per Documentation , I am trying to connect to API and getting the Holdings.
It is taking almost 1-2 minutes to give the Holdings.{Refer ScreenShot Below}
Further, when I am trying to place a Buy Order as per the Documentation following message is appearing:{refer screenShot below}
Whats the issue ??
Why results are displaying so late…
Documentation needs to be improved. Other Brokers are providing very good documentation for every function for easier understanding of API and implementation
Hi, you can try the sample code below. There are couple of things in the Documentation that need to be fixed.
- exchange_seg= ‘NSE_EQ’ should be exchange_segment=‘NSE_EQ’
- There is no argument option for passing corelationID
from dhanhq import dhanhq
client_id = "Enter your client_id here "
access_token = "Enter your access_token here "
dhan = dhanhq(client_id, access_token)
# Place an order (hdfc bank- 1333)
market_order = dhan.place_order(
security_id='1333',
exchange_segment='NSE_EQ',
transaction_type='BUY',
order_type='MARKET',
product_type='INTRADAY',
quantity=10,
price=0,
trigger_price=0,
validity='DAY',
after_market_order='False'
)
print(market_order)
# Place limit order
limit_order = dhan.place_order(
security_id='1333',
exchange_segment='NSE_EQ',
transaction_type='BUY',
order_type='LIMIT',
product_type='INTRADAY',
quantity=10,
price=100,
trigger_price=0,
validity='DAY',
after_market_order='False'
)
print(limit_order)
# Place StopLoss Order
SL_Buy_order = dhan.place_order(
security_id='1333',
exchange_segment='NSE_EQ',
transaction_type='BUY',
order_type='STOP_LOSS',
product_type='INTRADAY',
quantity=1,
price=110,
trigger_price=100,
validity='DAY',
after_market_order='False'
)
print(SL_Buy_order)
# Intraday daily minute charts
intra_data = dhan.intraday_daily_minute_charts('11536', 'NSE_EQ', 'EQUITY')
print(intra_data)
# Fetch all orders
dhan.get_order_list()
print(dhan.get_order_list())
# Get positions
dhan.get_positions()
# Get holdings
dhan.get_holdings()
# Get fund limits
dhan.get_fund_limits()
print(dhan.get_fund_limits())
Sample Code worked. But as suggested by you, Lot of corrections required in documentation.
Code as per recent documents not working.
One More thing why Code is running extrmely slow. Taking more than a minute …
What is the cause and solution for the same.
I ran the same sample code at my end and it took less than a second. You need to check at your end what is causing the delay.
Thank you @Market_Wizard for helping with the clarification here.
We have noted and will make the changes. For correlation ID, it is an optional field and can be added at user’s end if required.
yes, It is taking very long for first API call almost 1 min plus. subsequent API calls happening quickly
Hello @9985243221
Welcome to Dhan Community!
We have added some fixes in our python library - here. This will help with the delayed API response. Hence, we request you to reinstall the library in order to get updated version.
Hello @stanly_thomas
Our team is working on releasing next version of Python library which will include order slicing and couple of other APIs in the library as well. We will keep you updated here.
Dear Dhan team, it’s very good to use your python API. But most of the functions are not able to access as the parameter type mismatches. I want to remind you that providing an API is useless if you don’t provide clear documentation for the API. It is very difficult to use your API without documentation.
Please provide the documentation too
Hello @Dhanu
Welcome to Dhan Community! It’s exciting to see increasing no. of individual contributors and traders using DhanHQ APIs.
We are in the process of adding detailed documentation soon for our Python library as well on DhanHQ.
@Dhanu @stanly_thomas @bsjhala
We have added Python Library documentation along with the new library. Check out the detailed post here: