I have difficulty in placing forever order through python
Can some one post sample of forever buy and sl order
I have difficulty in placing forever order through python
Can some one post sample of forever buy and sl order
Hi @Nishad
Request structure for placing forever order is here: Dhan API
docs are here: Forever Order - DhanHQ Ver 2.0 / API Document
sl_order_id = tsl.order_placement(stock_name, ‘NSE’, qty, 0, sl_price, ‘STOPMARKET’, ‘SELL’, ‘CNC’) should i use 'OCO" instead of ‘CNC’
Is this correct
Hey @Nishad
Looks like you are using the TSL library. @Tradehull_Imran will be better able to assist you.
CNC is for product type, which means carry forward trade. What is the error that you are getting here?
While placing equty order I want to place forever order for sl
Can u give an example not possible with tsl Liberary?
@Tradehull_Imran if qty > 0:
order_id = tsl.order_placement(stock_name, ‘NSE’, qty, 0, 0, ‘MARKET’, ‘BUY’, ‘CNC’)
sl_price = round(ltp_data * 0.98, 1)
sl_order_id = tsl.order_placement(stock_name, ‘NSE’, qty, 0, sl_price, ‘STOPMARKET’, ‘SELL’, ‘CNC’)
watchlist.remove(stock_name)
traded_watchlist.add(stock_name)
message = f"✅ Traded {stock_name}\nOrder ID: {order_id}\nSL Order ID: {sl_order_id}"
pprint(message)
send_telegram_message(message)
except Exception as e:
error_msg = f"❌ API Error for {stock_name}: {e}"
pprint(error_msg) convert this order into forever order especially sl