Skip to content

dhan portfolio

Read portfolio state and convert or exit positions. Live action on convert and exit-all — both require a static-IP whitelist on the Dhan side and the --yes flag.

Subcommand Dhan endpoint Purpose Flags
dhan portfolio holdings GET holdings Show holdings.
dhan portfolio positions GET positions Show positions.
dhan portfolio convert --file <json> --yes Live action POST positions/convert Convert a position between product types. Requires static IP whitelisting. --file (req), --yes (req)
dhan portfolio exit-all --yes Live action DELETE positions Exit all open positions at market price. Requires static IP whitelisting. --yes (req)
Terminal window
dhan portfolio holdings --json --no-color
dhan portfolio positions --json --no-color

The conversion payload is a JSON object sent as the request body. The CLI auto-injects dhanClientId into the top-level JSON body if it isn’t already present.

Terminal window
dhan portfolio convert --file convert.json --yes --json --no-color

(Schema is per DhanHQ v2 positions/convert. Refer to Dhan’s API docs for the full field set.)

Terminal window
dhan portfolio exit-all --yes --json --no-color

Sends DELETE positions to Dhan, which exits every open position at market price. This is irreversible — only run from explicit operator intent.