How to place stop loss for MTM?

Stop loss orders can be placed for a given scrip but not for overall open positions.

Is there is possibility to do it to limit overall loss or overall profit for the portfolio?

With an api_algo you can create a condition based exit on pnl

1 Like

Can you elaborate it more in detail?

1 Like

Can someone please advise how to put stoploss for overall MTM basis.
Eg I want to exit my positions when my overall MTM loss on my open positions is 10k
& similarly I want to exit all open positions once my overall p&l for the open positions is 20K

1 Like

MTM based square off is something no brokers provide.

We will have to build a custom conditions/logic based algorithm using zerodha’s kite api, in python, php, C language etc.

The code is to be developed based on fetching the existing positions, check order book for executed orders, fetch buy price, sell price, points difference between them to assume in profit/loss, filter out failed orders due to broker error, exchange error, margin error etc, exception handling due to delay of execution of our square off orders, slippage etc. On top of if, freak trades, a hidden ghost.

It is literally a complex piece of code. It took me more than a month to develop and run it through multiple scenarios to make it bug proof. I did things in python and I thought I cracked it, later after a 5 months of gap, a freak trade screwed up all the logics, which was later fixed.

Please DM if you need, ofcourse there is a price for it, and it’s not cheap.

Understood, thanks!
I use Hdfc securities, can your code be implemented for hdfcsec?

This should be pretty easy. kite.positions api will return enough data. just use chatgpt and get the api to reverse open positions. dont waste money!!

What would be the estimate cost for this custom code, I am interested - How can I contact you

i think zerodha has something called kill switch