Dhan hq Algo trading API Response Messages

Hello there I just make a simple Algo that will just fetch data from screener sites and then place order and I didn’t see any error but the response I get is different in both testing and in both testing I just checked in Dhan app the order is showing in the app as rejected and now I’m planning to add fund in my Dhan account but before doing it with real money just want to make sure that everything was perfect so I will attached the response msg I get yesterday morning at 9:15

Response 1:
Order Response: {‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘RS-9005’, ‘message’: ‘Transaction Fails’}, ‘data’: ‘’}
()

Response 2:
Order Response: {‘status’: ‘success’, ‘remarks’: ‘’, ‘data’: {‘orderId’: ‘522406251211148’, ‘orderStatus’: ‘TRANSIT’}}

(So after testing today morning at 9:15 I get the same response as response 1 but I can also see the trades in my Dhan app with rejected status (due to insufficient fund cause I didn’t want to add funds before the testing results) but right now I when run some final checks I noticed that I get different response but also I checked in Dhan app and the trade was also appears in orders tab with failed status) I will attache now few screenshots please help
Me to understand this scenario why I get different messages in response and if trade is executing without any problem then why it is showing different response messages
(Please if possible reply me guys as soon as possible cause i want to add fund in my account testing this algo with real money )
well i cant attache more then one images and more then one url so i uploaded all three images in github and i will add my github repo link so you can see all my three images

Hello @Hardik-dev

Welcome to Dhan Community!

On this, your order is in Transit means that the order is successfully received. Whereas, in case of Transaction Fails, it usually is because of incorrect order parameters.

Can you send me the JSON for both of these orders so that the same can be checked and verified once?

thank you for the help brother and let me share you the details you needed
here is the code of place order
“try:
logging.info(“Placing order…”)
response = dhan.place_order(
security_id=‘873451’,
exchange_segment=dhan.NSE_FNO,
transaction_type=dhan.BUY,
quantity=175,
order_type=dhan.MARKET,
product_type=dhan.INTRA,
price=0
)
logging.info(“Order placed successfully.”)
print(f"Order Response: {response}”)
except Exception as e:
logging.error(“Error placing order: %s”, e)
print(f"Error placing order: {e}“)”
so the id used for place order is 873451
and the symbol is for this id TCS 27 JUN 3850 CALL
and i tried 3-4 times using this security id but everytime i get error and when i change the security id for hdfcbank then my order is placed
seccurity id 2023680
symbol name HDFCBANK 27 JUN 1710 PUT
so when i try to place order in hdfc 1710 put then my code will placing order successfully without any issue and i also checked the lot size in case if i make mistake but it is also correct
“try:
logging.info(“Placing order…”)
response = dhan.place_order(
security_id=‘2023680’,
exchange_segment=dhan.NSE_FNO,
transaction_type=dhan.BUY,
quantity=550,
order_type=dhan.MARKET,
product_type=dhan.INTRA,
price=0
)
logging.info(“Order placed successfully.”)
print(f"Order Response: {response}”)
except Exception as e:
logging.error(“Error placing order: %s”, e)
print(f"Error placing order: {e}“)”
and now let me share you some more screenshot with excat log massage so you can help me better way so here is the github repo like that will contain the logs and reports of the todays date so here is the url

final words for failed order place
so error message “TRANSACTION FAIL”
SECURITY ID: 873451
SYMBOL NAME: TCS 27 JUN 3850 CALL
LOT SIZE: 175

SECURITY ID: 875018
SYMBOL NAME: ONGC 27 JUN 267.5 PUT
LOT SIZE: 1925

SUCCESSFUL ORDER IDS
SECURITY ID: 128204
SYMBOL: TITAN 27 JUN 3400 PUT

SECURITY ID: 90206
SYMBOL: HDFCBANK 27 JUN 1700 PUT

so i didnt change any code i only just change security id and lot size in my code and still i got errors on some security ids and with some of the security ids it works without any issue and below is the json of the failed order

{
“SEM_EXM_EXCH_ID”: “BSE”,
“SEM_SEGMENT”: “D”,
“SEM_SMST_SECURITY_ID”: “875018”,
“SEM_INSTRUMENT_NAME”: “OPTSTK”,
“SEM_EXPIRY_CODE”: “0”,
“SEM_TRADING_SYMBOL”: “ONGC-Jun2024-267.5-PE”,
“SEM_LOT_UNITS”: “1925.0”,
“SEM_CUSTOM_SYMBOL”: “ONGC 27 JUN 267.5 PUT”,
“SEM_EXPIRY_DATE”: “2024-06-27 15:30:00”,
“SEM_STRIKE_PRICE”: “267.50000”,
“SEM_OPTION_TYPE”: “PE”,
“SEM_TICK_SIZE”: “5.0000”,
“SEM_EXPIRY_FLAG”: “M”,
“SEM_EXCH_INSTRUMENT_TYPE”: “OPTSTK”,
“SEM_SERIES”: “”,
“SM_SYMBOL_NAME”: “ONGCOPT”
}

{
“SEM_EXM_EXCH_ID”: “BSE”,
“SEM_SEGMENT”: “D”,
“SEM_SMST_SECURITY_ID”: “873451”,
“SEM_INSTRUMENT_NAME”: “OPTSTK”,
“SEM_EXPIRY_CODE”: “0”,
“SEM_TRADING_SYMBOL”: “TCS-Jun2024-3850-CE”,
“SEM_LOT_UNITS”: “175.0”,
“SEM_CUSTOM_SYMBOL”: “TCS 27 JUN 3850 CALL”,
“SEM_EXPIRY_DATE”: “2024-06-27 15:30:00”,
“SEM_STRIKE_PRICE”: “3850.00000”,
“SEM_OPTION_TYPE”: “CE”,
“SEM_TICK_SIZE”: “5.0000”,
“SEM_EXPIRY_FLAG”: “M”,
“SEM_EXCH_INSTRUMENT_TYPE”: “OPTSTK”,
“SEM_SERIES”: “”,
“SM_SYMBOL_NAME”: “TCSLOPT”
}

well :rofl: :rofl: :rofl: :rofl: :rofl: :rofl:
i think i found the problem :sweat_smile: :sweat_smile: :sweat_smile: :sweat_smile: :sweat_smile:
why it is showing “TRANSATION FAIL” error but let’s make sure that it’s the lsat peace of the puzzle :rofl: :rofl: :rofl: :rofl: :rofl: :rofl:
i noticed the security id is for BSE stock and in my place order code i select NSE
“exchange_segment=dhan.NSE_FNO,”
but still thank you for the help brother (@Hardik ) cause if you didn’t ask for json to shayad abhi bhi me kahi aur hii dekhta rehta thank you so much brother

Hello brother I improved my code after I noticed mistake from my previous response and now my algo placed two orders below is security id and symbol name

  1. Security id: 105236
    2.symbol name: HCLTECH 27 JUN 1420 CALL
  2. ⁠ security id: 57161
  3. ⁠ symbol name: TATASTEEL 27 JUN 173 CALL

And i will attach one screenshot of my terminal with response message TRANSIT but when i opened my dhan app i cant see the open position for few minutes and then between 9:17 to 9:22 i found those two order in order tab with failed status and the reason of the failed is same for both order i will mention it below

For hcl tech
1.HCLTECJ 27 JUN 1420 CALL
RMS:6224062716606:Transactions Are Blocked For This Scrip

for tata steel
TATASTEEL 27 JUN 173 CALL
RMS:2224062717006:Transactions Are Blocked For This Scrip

and here is github link where i uploaded all my dhan app screenshots of order tabs and failed error messages and please help me to resolve this issue cause this time tried algo trading with real money and please reply fast atleast one time in day so we can make some progress to make this algo work
thank you

my demate account details for algo trading

client ID: 1101921938

demat ID/ BO ID
1208340017383528

Hello @Hardik-dev

Stock Options are not allowed for trade on the day of expiry as part of the RMS policy and the higher margin obligations. This is the reason why these orders were rejected.

Thank you for the help :+1:t2: and the second reply i did where I accidentally use id of BSE that is the reason of transaction fail right so everything is good to go ?

1 Like