is this the correct way to retrieve open positions?
It returns there are open positions even when there are no open positions.
Am i making a mistake in the code.
Hello @Dev
Looks like you are just printing whether there are open positions or not instead of looking for what the open positions are.
You can also use print (open_pos)
to actually print the position details along.
Hi @Hardik ,
I am trying to retrieve if there are open positions or not.
I think the command dhan.get_positions() is to fetch all positions of the day not just open ones.
The wording in the API document confused me.
Can you let me know if there are commands to:
- check if there are any open positions
or - close all open positions at one go
Thanks,
Hello @Dev
Yes, you got it right!
- No, you can simply filter out from the JSON based on
positionType
. - This you will have to do at your end only, there is no Exit All API available as of now.
Thanks Hardik
1 Like