Preparing to comply with SEBI's retail algo rules (Static IP, ratelimits, order types)

Matti
Matti edited March 27 in General
Static IP registration is live on the Kite Connect developer dashboard. You have until April 1 to do so. Log in to developers.kite.trade, go to your profile page, and enter your static IP under the "IP Whitelist" section.

What's changing from April 1

  • All order requests from an unregistered IP will be rejected. This applies to all Kite Connect users who place orders via the API, regardless of order frequency.
  • A strict 10 orders-per-second rate limit will apply. Requests exceeding this will receive a 429 response. To place more than 10 orders per second, you will need the strategy registered with the stock exchange.
  • Market orders will require market protection. Orders placed with market protection set to "0" will be rejected. Learn more. (This is mandated by the exchanges for all algo orders)
  • MCX does not support IOC (Immediate-or-Cancel) orders in the algo segment.
  • Order slicing should be capped at a maximum of 10 slices to stay in line with the 10 orders-per-second limit.

A few things worth knowing

  • The IP applies across all apps on your Kite Connect account.
  • Sharing of IPs is permitted between family members (spouse, dependent children, and dependent parents) as per the regulation. Violation may result in the developer account being suspended.
  • Only order endpoints are will be validated against the static IP. All other API endpoints — WebSocket data, order book, positions, etc. — remain accessible from any IP.
  • If you don't yet have a static IP, you'll need to acquire one from an ISP, cloud provider (AWS, GCP, etc.), or a VPN/VPC service before April 1.
  • Tusshar18
    Tusshar18 edited March 25
    @Matti, I want a clarification on this:::: Market orders will require market protection. Orders placed with market protection set to "0" will be rejected.


    I want a clarification on this, since all the orders are executed from my UI, and the range is set before trades are executed, and all are market orders placed based on candle close of previous minute along with stop losses placed the second after executing the order

    Moreover, strategies also include short straddle, for which the SL is placed in the system, not visible in the order book, but it is there, how to proceed with this

    For this do I need to make changes in the code?
  • SpacemanSpiff
    @Matti
    I want to test this without risking live trades too much.
    Some questions on behaviour before April 1 once i register static ips.

    Are orders requests getting rejected from unregistered IP before April 1 ?
    How do we test that its working ?

    Do we have IP update frequency restrictions before April 1 ?
    Can we remove it if facing any issue and will that take effect immediately ?
  • RS6006
    @Matti

    Sharing of IPs is permitted between family members => But I am getting "The IP address(es) you are trying to add are already linked to another account. Each IP address can only be linked to one account." error when I try to add the same IP in family member account.
  • yogeshs
    You need to do that in single developer profile I think.
  • subrah
    subrah edited March 26
    I have configured IP in profile page.
    Is there any API i call call from the my System to check whether the IP is configured correctly ?

    eg. GET /static_ip/config

    When called from correct system, It should return.
    {
    "status": "success",
    "data": "The static IP (x.x.x.x) configured is valid."
    }
    When called from different system, i should return error.
    {
    "status": "error",
    "data": "The static IP (x.x.x.x) configured is not valid. Your current IP is (y.y.y.y)"
    }
    I hope this option will solve @SpacemanSpiff 's problem.
    I do not want to check this configuration in live orders.
    Hoping for a solution before enabling the restriction.
    @Matti
  • RS6006
    @yogeshs, but with one profile page, how can we share with other family members, their zerodha account is different.. IP should be able to share between two different profile
  • yogeshs
    You can add multiple zerodha accounts in single developer profile.
  • knightrider
    @Matti - URGENT MATTER ! Seems like the market_protection parameter is still not there in 5.0.1 [python]

    This can become a huge problem if not fixed URGENTLY.
  • yogeshs
    Not sure about market protection impact from 1st apr.
    Whats the impact on Java kite connect ?
  • scaars13
    It seems like market_protection is not even introduced as a param in python sdk
    https://github.com/zerodha/pykiteconnect/blob/6b7b7621e575411921b506203b526bf275a702c7/kiteconnect/connect.py#L336-L352

    Is it accurate to infer that any market order placed from April 1 using python sdk would start failing . Am I missing something because this seems like a serious oversight
  • yogeshs
    Even I am not sure how this will be taken care. I hope zerodha will take care of such orders coming from api key
  • scaars13
    If this doesn’t get fixed before April 1 which it probably won't, I think kite._post or kite._put can be utilized as a workaround.

    Not ideal though, these are internal methods, so treat this as temporary and have to be revalidated after SDK updates but still better than rewriting entire code from python sdk to http
  • knightrider
    @scaars13 @yogeshs - Someone has already opened a PR for it (I think it should work, I'll be testing it tomorrow).
    https://github.com/zerodha/pykiteconnect/pull/218

    If you're using requirements.txt for python, just replace kiteconnect with this:
    https://github.com/pepalguru/pykiteconnect/archive/89e3b432110ab05b03cd740f8afd40caa18f9ece.zip
  • rsingha
    If needed, I can provide VPN access with high-speed internet and static IP addresses for your developer accounts at a very low cost.
  • RS6006
    Market protection max is 20% right ? Options move 20% in milli seconds.. not sure how this works in real
  • Sravanthi_bh
    @Tusshar18

    Market orders must now have market protection—orders with “0” will be rejected. So yes, you’ll need to update your order placement logic to include this.

    Any market order must comply with this rule.

    For your current setup:
    • If market orders are being placed via API, you’ll need to update the code to include a suitable market protection percentage.
    • If orders are placed via UI/manual flow, ensure the same is configured appropriately in the order placement settings.
  • Sravanthi_bh
    @RS6006
    Sharing IP across accounts:
    Static IP is configured at the developer profile level. You can add multiple Zerodha accounts under the same developer profile, and the configured IP will apply across them. answered here.

    @knightrider @scaars13 @yogeshs
    Market protection
    1. Market orders must include a non-zero market protection value, otherwise they will be rejected starting April 1.
    2. This requirement applies across all APIs/SDKs.
    3. We’re aware of the concerns regarding SDK support and are working to add this across all libraries at the earliest.
  • yogeshs
    Are you saying that you are still working on the sdk support for this when the cut off date for market protection orders is 1st Apr.?
    This is serious problem, from 1st Apr, the market orders via SDK will start failing (as existing SDK does not provide any option to set market protection in the market orders).
  • RS6006
    @knightrider,
    An easier way is to update local kiteconnect.py and make the PR changes (just oneline) incase anyone is not interested to make version upgrades from kiteconnect4 -> kiteconnect5
  • Tusshar18
    @Sravanthi_bh how does market protection impact options trading in selling side, considering there is no major price fluctuation while the order is executed in a particular range
  • adarsh1392
    @Sravanthi_bh @Matti I have added the market_protection field , but started getting error this morning as of Mar-27.
    KiteConnect.place_order() got an unexpected keyword argument 'market_protection'
  • Sravanthi_bh
    Sravanthi_bh edited March 27
    @Tusshar18
    Market protection sets a limit on how far the execution price can deviate from the current market price for market orders.
    For options selling, it helps prevent execution at significantly lower prices during sudden spikes or low liquidity.Learn more.
  • Tusshar18
    @Sravanthi_bh _bh but if I am setting up an entry range for both ce and pe, and it is defined and cannot deviate from that, then why is it necessarry in options, also considering the entry parts to be related to candle close of the previous minute
  • knightrider
    @RS6006 - Yea, but, as a standard practice, it's not recommended to update the site-packages manually. Especially if the system is docker containerised, it becomes unnecessary burden to update the package in a manual way.

    Btw, during my testing today, the PR doesn't seem to work either, the market_protection parameter is ignored by the backend it seems.

    Requesting @kiteapi @kiteconnect to look into this matter quickly because only 2 trading days are left before this becomes a bigger problem for Zerodha !

    cc: @scaars13 @yogeshs
  • knightrider
    @adarsh1392 - You might not have updated the place_order() in kiteconnect.py to accept that parameter.
  • Sravanthi_bh
    @Tusshar18 Market protection acts as a final safeguard at execution level, ensuring the order doesn’t get filled at an extreme price during sudden volatility or illiquidity.
    So, irrespective of your entry logic, this needs to be included for all market orders.
  • Nivas
    Nivas edited March 27
    I have added the market_protection field , but started getting error this morning as of Mar-27.
    KiteConnect.place_order() got an unexpected keyword argument 'market_protection'
    @adarsh1392 At present, market protection is supported in the raw HTTP API, as well as the Java and .NET SDKs. You may encounter this error if the market_protection parameter is not yet available in the SDK you are using.

    We are actively working on extending this support across all libraries, and it is expected to go live this weekend.
  • adarsh1392
    adarsh1392 edited March 27
    @knightrider - I have added the market_protection = 2 flag in my order placements. Still getting error.
    @Nivas - Is there an ETA by which market_protection flag will be enabled for python sdk? All my orders are failing this morning.
  • knightrider
    @Nivas @Sravanthi_bh - Can we please get clarity on the ETA? There are only 1.5 trading days left before 1st April (Tuesday is a holiday). Thanks !
  • knightrider
    @adarsh1392 - It's not about adding parameter while calling the method, the definition of the place_order() in kiteconnect.py [kiteconnect package] needs to accept that parameter right. I was talking about that.
  • adarsh1392
    yes understood. We all are scrambling for the same thing lol. Traders are ready, zerodha is not!
  • knightrider
    @adarsh1392 - Maybe they'll take cognisance of this issue once they see their brokerage go down quite significantly !

    @kiteapi @kiteconnect
  • knightrider
    Good news @adarsh1392 @RS6006 @scaars13 @yogeshs !
    Market protection parameter is working with the PR:
    https://github.com/zerodha/pykiteconnect/pull/218

    Earlier, I mentioned that it did not work because I was receiving {"market_protection": 0} in the order response, but, when I checked the orders on web ui, it shows a shield for those orders (shields is a symbol of market protection). So, we can use that fix till the time zerodha updates their kiteconnect package to support the market_protection parameter.
  • yogeshs
    I will need this feature for Java kite connect
  • CNN523
    If my API is placing more than 10 orders per second. Let say 15 orders are placed. Is it going to cancel the 5 orders and the new limit of 10 orders will be given for next second if I have not registered my strategy.
  • Arockiya_r
    @adarsh1392 @knightrider Market protection will be added in all SDKs by tonight or tomorrow.
  • knightrider
    @Arockiya_r - Please make sure to consider the case of modify_order() when I'm trying to modify an existing LIMIT-SL order to MARKET order. Thank you !
  • Arockiya_r
    I do not want to check this configuration in live orders.
    How do we test that its working ?
    @subrah @SpacemanSpiff March 31st is a holiday; we are discussing taking this validation live on that date. Once it is live, you can verify it by placing AMO orders.
  • adarsh1392
    Thanks for the update @Arockiya_r
  • Arockiya_r
    Please make sure to consider the case of modify_order() when I'm trying to modify an existing LIMIT-SL order to MARKET order.
    When you convert from a limit to a market protection order?
  • CNN523
    If my API is placing more than 10 orders per second. Let say 15 orders are placed. Is it going to cancel the 5 orders and the new limit of 10 orders will be given for next second if I have not registered my strategy.
  • knightrider
    knightrider edited March 27
    @Arockiya_r - Example:
    - I have an trigger-pending SL-LIMIT order
    - Sometimes, before hitting the trigger, I need to square the order off the position. In that case, instead of cancelling the existing trigger-pending SL-LIMIT order and creating a new market order for squaring off my position, I just modify the existing trigger-pending SL-LIMIT order to a MARKET order. I do that by using modify_order() method in kiteconnect.py. So, I need to have a market protection parameter for that method as well.
  • Arockiya_r
    Arockiya_r edited March 27
    I do that by using modify_order() method in kiteconnect.py. So, I need to have a market protection parameter for that method as well.
    This parameter will be available for modification as well.
  • knightrider
    @Arockiya_r - Awesome ! Thanks a lot !!
  • Arockiya_r
    If my API is placing more than 10 orders per second. Let say 15 orders are placed. Is it going to cancel the 5 orders and the new limit of 10 orders will be given for next second if I have not registered my strategy.
    10 orders will be placed, and 5 orders will be blocked with a 429 response.
Sign In or Register to comment.