Learn Algo Trading with Python | Codes | Youtube Series

Not a problem, you can attend in our office. Details to be shared shortly.

Does anybody has the code snippet for trailing implementation? Thanks

@RahulDeshpande Ji, Bangalore me kuch event ho toh please share karna. And @Tradehull_Imran Sir ko la paye toh bhag ke aa jayenge :grin:

1 Like

in market hours getting error while placing order
Pdb++) otm_ce_buy = tsl.order_placement(otm_ce_strike,‘NFO’, lots, 0, 0, ‘MARKET’, ‘BUY’, ‘MIS’)
Traceback (most recent call last):
File “/Users/parveenchugh/latest/Dhan_Tradehull_V2.py”, line 170, in order_placement
orderid = order[“data”][“orderId”]
~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: ‘orderId’
(Pdb++)
Traceback (most recent call last):
File “/Users/parveenchugh/latest/Dhan_Tradehull_V2.py”, line 170, in order_placement
orderid = order[“data”][“orderId”]
~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: ‘orderId’

Hello @Tradehull_Imran Sir,

At the time of trailing Stop Loss, I am using below code:

sl_orderid = 10224121852721
cancel_id = tsl.Dhan.cancel_order(sl_orderid)

Getting below error:
{'status': 'failure', 'remarks': {'error_code': 'DH-906', 'error_type': 'Order_Error', 'error_message': 'Order Is Cancelled.kindly Refresh Your Orderbook'}, 'data': {'errorType': 'Order_Error', 'errorCode': 'DH-906', 'errorMessage': 'Order Is Cancelled.kindly Refresh Your Orderbook'}}

What could be the reason behind this error?

Thanks,
Sudip Nath

Hi sir,

To calculate call and put option volumes in a running candle using Python

Hello sir
Use this code update your SL price

orderid = ‘12241210603927’
modified_order_id = tsl.modify_order(order_id=orderid,order_type=“LIMIT”,quantity=50,price=0.1,trigger_price=0)

1 Like

@Tradehull_Imran I still not getting the use of Dhan_websocket.py :frowning_face:
I can still write the algo w/o running it. ya? or Am I misunderstood the concept :thinking:

Cheers, Raj

Hi @vinay_kumaar
The code for SL and 1.5 target seems to be correct.

Hi @parveen_chugh

Either of the “otm_ce_strike/lots” values seems to be incorrect

sample code for order placement:

entry_orderid  = tsl.order_placement(tradingsymbol='NIFTY 19 DEC 24400 CALL' ,exchange='NFO', quantity=25, price=0, trigger_price=0, order_type='MARKET', transaction_type='BUY', trade_type='MIS')
sl_orderid     = tsl.order_placement(tradingsymbol='NIFTY 19 DEC 24400 CALL' ,exchange='NFO', quantity=25, price=29, trigger_price=30, order_type='STOPLIMIT', transaction_type='SELL', trade_type='MIS')

Also, do use this codebase file : Dhan_Tradehull_V2.py - Google Drive

Hi @Himansshu_Joshi

for placing order above freeze quantity use below code


order_ids      = tsl.place_slice_order(tradingsymbol="NIFTY 19 DEC 24400 CALL",   exchange="NFO",quantity=5000, transaction_type="BUY",order_type="LIMIT",trade_type="MIS",price=0.05)

Also, do use this codebase file : Dhan_Tradehull_V2.py - Google Drive

Hi @Arun_Rawat

It seems that the code is running on python 3.10 , we need to use python 3.8

See : https://www.youtube.com/watch?v=YAyIoDJYorA&list=PLnuHyqUCoJsPA4l9KRLrNpWLIfZ9ucLxx&index=8

codefiles : 2. Session2 - Installation.zip - Google Drive

1 Like

Hi @rohit2312

see : Learn Algo Trading with Python | Codes | Youtube Series - #1268 by Tradehull_Imran

sir all are ok
I also put trading symbol name and lots qty but same error, I also use latest v2.2
also sharing screenshot
Pdb++) otm_ce_buy = tsl.order_placement(otm_ce_strike,‘NFO’, lots, 0, 0, ‘MARKET’, ‘BUY’, ‘MIS’)
Traceback (most recent call last):
File “/Users/parveenchugh/latest/Dhan_Tradehull_V2.py”, line 140, in order_placement
orderid = order[“data”][“orderId”]
~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: ‘orderId’
(Pdb++) atm_ce_strike
‘NIFTY 19 DEC 24200 CALL’
(Pdb++) itm_ce_strike
‘NIFTY 19 DEC 24100 CALL’
(Pdb++) otm_ce_strike
‘NIFTY 19 DEC 24500 CALL’
(Pdb++) lots
2
(Pdb++)

otm_ce_buy = tsl.order_placement(‘NIFTY 19 DEC 24200 PUT’,‘NFO’, 1, 0, 0, 0, ‘MARKET’, ‘BUY’, ‘MIS’)
'Got exception in place_order as ‘BUY’

this is in latest v2.2

Hi @parveen_chugh

we need to send quantity for the order placement,
so use 25,50,75,100

otm_ce_strike = "NIFTY 19 DEC 24500 CALL"
quantity = 25
otm_ce_buy = tsl.order_placement(otm_ce_strike,'NFO', quantity, 0, 0, 'MARKET', 'BUY', 'MIS')

also, let me know if fixed tomorrow, as now it will give message
Market is Closed! Want to place an offline order?

Thanks Sir, solved

1 Like

Hi @Aijaz_Ahmad

use below example code to find how much margin is required for a pirticular order

margin = tsl.margin_calculator(tradingsymbol='ACC', exchange='NSE', transaction_type='BUY', quantity=2, trade_type='MIS', price=2180, trigger_price=0)
margin = tsl.margin_calculator(tradingsymbol='NIFTY 19 DEC 24400 CALL', exchange='NFO', transaction_type='SELL', quantity=25, trade_type='MARGIN', price=43, trigger_price=0)
margin = tsl.margin_calculator(tradingsymbol='NIFTY 19 DEC 24400 CALL', exchange='NFO', transaction_type='BUY', quantity=25, trade_type='MARGIN', price=43, trigger_price=0)
margin = tsl.margin_calculator(tradingsymbol='NIFTY DEC FUT', exchange='NFO', transaction_type='BUY', quantity=25, trade_type='MARGIN', price=24350, trigger_price=0)

Also, do use this codebase file : Dhan_Tradehull_V2.py - Google Drive

Hi @amitbalagi

we have upgraded our way to call ltp on a easier method

see solution link : Learn Algo Trading with Python | Codes | Youtube Series - #952 by Tradehull_Imran

Hi @SUDIP_NATH @Himansshu_Joshi @Aijaz_Ahmad

for cancel order issue, it seems that the code is using a older codebase version

Also, do use this codebase file : Dhan_Tradehull_V2.py - Google Drive

reference code to use

   orderid = '12241210603927'
   order_status = tsl.cancel_order(OrderID=orderid)