Dhan-hq API Algo Trading

Hello Team,

I am seeking assistance with the following requirements for a client project involving the Nifty50 indices:

  1. Data Fetching:
  • I need to fetch open-high and open-low data for all Nifty50 stocks. The requirement is to identify stocks where the open price is equal to the high price (O=H) and where the open price is equal to the low price (O=L).
  • The data fetching process should be highly efficient, ideally fetching the required information for all stocks within milliseconds to seconds.
  1. Order Execution:
  • When the market opens, if a stock meets the O=H condition, an order should be placed to sell 100 quantities in intraday at the market price. A stop loss should be added if possible; otherwise, we will monitor the price and manually exit if the condition breaks.
  • Similarly, if a stock meets the O=L condition, an order should be placed to buy 100 quantities in intraday at the market price with a stop loss.
  • My client requires that these orders be executed as close to the market open as possible, ideally within 1-3 seconds after the market opens.
  1. Order Management:
  • If adding a small stop loss for sell orders is not feasible, we need a mechanism to continuously monitor the last traded price (LTP) and exit the order if the open-high condition breaks using the order ID.
  • I need code snippets for placing buy and sell orders, as well as for exiting orders using the order ID.
  1. Efficiency and Speed:
  • My client needs to ensure that up to 30 orders can be executed within 1-3 seconds of the market opening. Thus, a highly efficient logic for fetching open-high and open-low data and executing orders swiftly is crucial.

I would greatly appreciate any help in developing an optimal solution to meet these requirements, including sample Python code for the following:

  • Fetching O=H and O=L data for all Nifty50 stocks.
  • Placing buy and sell orders with stop losses.
  • Order should be in intraday.
  • Exiting orders using order IDs.

Thank you in advance for your assistance.

Best regards,
Hardik

1 Like