Skip to content

Order

dhanhq._order

Classes

Order

Order(dhan_context)
Functions
cancel_order
cancel_order(order_id)

Cancel a pending order in the orderbook using the order ID.

Parameters:

Name Type Description Default
order_id str

The ID of the order to cancel.

required

Returns:

Name Type Description
dict

The response containing the status of the cancellation.

get_order_by_correlationID
get_order_by_correlationID(correlation_id)

Retrieve the order status using a field called correlation_id.

Parameters:

Name Type Description Default
correlation_id str

The correlation_id provided during order placement.

required

Returns:

Name Type Description
dict

The response containing order status.

get_order_by_id
get_order_by_id(order_id)

Retrieve the details and status of an order from the orderbook placed during the day.

Parameters:

Name Type Description Default
order_id str

The ID of the order to retrieve.

required

Returns:

Name Type Description
dict

The response containing order details and status.

get_order_list
get_order_list()

Retrieve a list of all orders requested in a day with their last updated status.

Returns:

Name Type Description
dict

The response containing order list status and data.

modify_order
modify_order(order_id, order_type, leg_name, quantity, price, trigger_price, disclosed_quantity, validity)

Modify a pending order in the orderbook.

Parameters:

Name Type Description Default
order_id str

The ID of the order to modify.

required
order_type str

The type of order (e.g., LIMIT, MARKET).

required
leg_name str

The name of the leg to modify.

required
quantity int

The new quantity for the order.

required
price float

The new price for the order.

required
trigger_price float

The trigger price for the order.

required
disclosed_quantity int

The disclosed quantity for the order.

required
validity str

The validity of the order.

required

Returns:

Name Type Description
dict

The response containing the status of the modification.

place_order
place_order(security_id, exchange_segment, transaction_type, quantity, order_type, product_type, price, trigger_price=0, disclosed_quantity=0, after_market_order=False, validity='DAY', amo_time='OPEN', bo_profit_value=None, bo_stop_loss_Value=None, tag=None, should_slice=False)

Place a new order in the Dhan account.

Parameters:

Name Type Description Default
security_id str

The ID of the security to trade.

required
exchange_segment str

The exchange segment (e.g., NSE, BSE).

required
transaction_type str

The type of transaction (BUY/SELL).

required
quantity int

The quantity of the order.

required
order_type str

The type of order (LIMIT, MARKET, etc.).

required
product_type str

The product type (CNC, INTRA, etc.).

required
price float

The price of the order.

required
trigger_price float

The trigger price for the order.

0
disclosed_quantity int

The disclosed quantity for the order.

0
after_market_order bool

Flag for after market order.

False
validity str

The validity of the order (DAY, IOC, etc.).

'DAY'
amo_time str

The time for AMO orders.

'OPEN'
bo_profit_value float

The profit value for BO orders.

None
bo_stop_loss_Value float

The stop loss value for BO orders.

None
tag str

Optional correlation ID for tracking.

None

Returns:

Name Type Description
dict

The response containing the status of the order placement.

place_slice_order
place_slice_order(security_id, exchange_segment, transaction_type, quantity, order_type, product_type, price, trigger_price=0, disclosed_quantity=0, after_market_order=False, validity='DAY', amo_time='OPEN', bo_profit_value=None, bo_stop_loss_Value=None, tag=None)

Place a new slice order in the Dhan account.

Parameters:

Name Type Description Default
security_id str

The ID of the security to trade.

required
exchange_segment str

The exchange segment (e.g., NSE, BSE).

required
transaction_type str

The type of transaction (BUY/SELL).

required
quantity int

The quantity of the order.

required
order_type str

The type of order (LIMIT, MARKET, etc.).

required
product_type str

The product type (CNC, MIS, etc.).

required
price float

The price of the order.

required
trigger_price float

The trigger price for the order.

0
disclosed_quantity int

The disclosed quantity for the order.

0
after_market_order bool

Flag for after market order.

False
validity str

The validity of the order (DAY, IOC, etc.).

'DAY'
amo_time str

The time for AMO orders.

'OPEN'
bo_profit_value float

The profit value for BO orders.

None
bo_stop_loss_Value float

The stop loss value for BO orders.

None
tag str

Optional correlation ID for tracking.

None

Returns:

Name Type Description
dict

The response containing the status of the slice order placement.