jugaad-py / jugaad-trader

Unofficial python client for Zerodha
https://marketsetup.in/documentation/jugaad-trader/
157 stars 112 forks source link

[Discussion] How to place stop loss limit and trailing stop loss in kite api? #63

Closed st271 closed 3 weeks ago

st271 commented 3 weeks ago

This is not related to jtrader but want to ask how can we place stop loss limit and trailing stop loss in kite api.

Presently I believe we cannot put stop loss orders while buying an asset. For long trades, first we need to buy it after then we have to put sell order with stop loss.

BUY

order_id = kite.place_order(tradingsymbol="INFY",
                                    exchange=kite.EXCHANGE_NSE,
                                    transaction_type=kite.TRANSACTION_TYPE_BUY,
                                    quantity=10,
                                    variety=kite.VARIETY_REGULAR,
                                    order_type=kite.ORDER_TYPE_MARKET,
                                    product=kite.PRODUCT_MIS,
                                    validity=kite.VALIDITY_DAY)

SELL

order_id = kite.place_order(tradingsymbol="INFY",
                                    exchange=kite.EXCHANGE_NSE,
                                    transaction_type=kite.TRANSACTION_TYPE_SELL,
                                    quantity=10,
                                    variety=kite.VARIETY_REGULAR,
                                    order_type=kite.ORDER_TYPE_SL,
                                    product=kite.PRODUCT_MIS,
                                    validity=kite.VALIDITY_DAY,
                                    stoploss=1810,)
  1. Is this the right approach for putting stop loss?
  2. How do we trail the stop loss?