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

Matti
Matti edited March 30 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. This includes SL-M orders. 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.
  • DaneshBansal
    Zerodha Team: Pls reconfirm my following understanding based on understanding of various discussions and documnetation.

    1.0 Whenever we place a new Market order- A NON ZERO Market_protection parameter value MUST be defined.
    2.0 If I set this value as -1, auto protection limits specified by Zerodha will be applied
    3.0 Whenever I want to modify a market order, I dont need to specify the market-protection parameter again.
    4.0 Whenever I modify a LIMIT order as a Market Order, market_protection value should be redefined.
    5.0 Can I specify the Market_protection parameter value for LIMIT/SL orders also so that when I modify these orders as Market orders, the value is already there?

  • Matti
    @DaneshBansal
    1. Yes.
    2. Yes
    3. Yes. However, if you placed a market order, even with market protection, it will most likely execute immediately. If it remains pending, you'd modify it as a Limit order.
    4. Correct.
    5. No, Market protection is only applicable to market and SLM orders.
  • DaneshBansal
    @Matti@, regarding modification of limit order to market order, market_protection is not available as per API documentation. The list of available parameters is as follows. Pls clarify.

    Regular order parameters¶
    parameter
    order_type
    quantity
    price
    trigger_price
    disclosed_quantity
    validity
  • knightrider
    knightrider edited March 30
    @Matti - I also have the same problem as @DaneshBansal. My SL limit to MARKET order is not getting market protected despite specifying the market_protection field in modify_order() method in python.
  • Arockiya_r
    Arockiya_r edited March 30
    regarding modification of limit order to market order, market_protection is not available as per API documentation. The list of available parameters is as follows.
    What SDK are you referring to?
  • Arockiya_r
    My SL limit to MARKET order is not getting market protected despite specifying the market_protection field in modify_order() method in python.
    We are checking this.
  • yogeshs
    Can someone please update if we are going to get the zerodha kiteconnect Java SDK change for market protection before 1st April?
  • Matti
    @yogeshs the SDKs have already been updated.
  • yogeshs
    Hi
    Thanks.
    Just checked.
    You guys have updated the code in the GitHub repository but release is not created for the new version.
    Anyways, that solves the problem.
    Thank you.
  • Arockiya_r
    @DaneshBansal This has not yet been updated in the KTIE Connect documentation, but all libraries are up to date. The user can use it.

    @knightrider verified: the limit-to-market protection is working fine. Please refer to the Python update here.
  • knightrider
    @Arockiya_r - Strange ! My orders when converted from SL-LIMIT to MARKET (with market_protection=-1) do not show the shield icon in the orders. Instead, those seem to be executed as LIMIT orders. Can you please check why is that?
  • Arockiya_r
    After changing the order type, the shield icon might not display for some users due to backend limitations, but market protection conversion still works. Market protection orders will be shown as limit orders only, regardless of the shield icon.
  • knightrider
    @Arockiya_r - Okay ! Thanks for the prompt and detailed explanation ! Cheers !!
  • DaneshBansal
    DaneshBansal edited March 30
    Hi Zerodha team: Kindly reconfirm the followimg :

    a) While placing SL/Limit orders, market_protection parameter value does not need to be defined at all, not even 0 Value.

    b) You shall be implementing static IP validation and market_protection parameters by tonight so that we can test tomorrow.

    Thanks
  • jack
    Does only data feed requests from API requires static IP ?
  • nebudotcom
    How many static IPs can I configure on my account? How often can I change them?
  • knightrider
    knightrider edited March 31
    @Arockiya_r - Is the static IP check in production? I can still place AMO orders without registering any IP.
  • yogeshs
    yogeshs edited March 31
    I have configured the IPv6 IPs in the profile on kite app but I am getting below error while executing the order.
    IP xxx.xxx.xx.xxx is not allowed to place orders for this app.
    The IP in the error is IPv4. Why this error is coming?

    @Arockiya_r
  • Arockiya_r
    While placing SL/Limit orders, market_protection parameter value does not need to be defined at all, not even 0 Value.
    Market protection is technically a limit order, this is not applicable to limit/SL.
    You shall be implementing static IP validation and market_protection parameters by tonight so that we can test tomorrow.
    You can test it today @DaneshBansal
    Does only data feed requests from API requires static IP ?
    only order endpoints are will be validated against the static IP
  • knightrider
    @Arockiya_r - I can still place AMO orders from an unregistered IP. Are you sure that the validation check is already there in your production environment?
  • deepak163299
    @Matti @Arockiya_r I would like to understand how the order rate limit of 10 orders per second is applied when multiple apps share a static IP in the Kite developer account. Specifically, if I have three separate trading family apps under one Kite developer account and single IPv4 Static IP, and all three apps are using the same static IP, does the rate limit of 10 orders per second apply per app individually, or is it a total limit shared across all three apps for that Static IP? In other words, do all three apps combined have to stay within the 10 orders per second limit, or is each app allowed its own 10 orders per second?

    In simple:
    - All apps under same kite developer account can send individually 10 Orders/sec same static IP and after limit we will get error_429, or
    - all apps under the same kite developer account can send combined rate limit order of 10 order per second, mean totally we have a max potential to send 30 orders per second means 10 orders by each app

    Kindly clarify my confusion for that particular issue
  • Arockiya_r
    I can still place AMO orders from an unregistered IP. Are you sure that the validation check is already there in your production environment?
    If you enter an IP, the validation works. If the static IP field is empty, the validation is not applied. This will be added after the commodity market today.
  • Arockiya_r
    @deepak163299 10 OPS is account-specific, regardless of the number of app
  • knightrider
    @Arockiya_r - Cool ! It seems to be working. Thanks !
  • DaneshBansal
    DaneshBansal edited March 31
    Thanks
  • deepak163299
    @Arockiya_r is account specific meaning is the kite developer account specific or client code specific

    Means the apps created inside the kite developer account no matters how many apps are created just we have combined order rate limit is 10 order per second for the combined apps.

    Let suppose I have three family apps in same kite developer account and
    - app 1 is trying to placing 6 order per second
    - app 2 is trying to placing 8 orders per second
    - app 3 is trying to placing seven orders per second

    All the orders is trying to placing at the same second time frame, how many orders will be go to open status and how many will be rejected according to the office same time same
  • Arockiya_r
    kite client ID specific.
  • yogeshs

    I have configured the IPv6 IPs in the profile on kite app but I am getting below error while executing the order.
    IP xxx.xxx.xx.xxx is not allowed to place orders for this app.
    The IP in the error is IPv4. Why this error is coming?

    @Arockiya_r @Matti
    Can you guys please advice, this error will block complete flow.
  • Arockiya_r
    @yogeshs

    Please verify whether the order request is transmitted using IPv4 or IPv6, and update the respective IP address accordingly. If the request is sent via IPv4 but the IPv6 address has been updated in the developer profile, the IP validation will not pass.
  • yogeshs
    yogeshs edited March 31
    @Arockiya_r thanks for the reply

    I think that's what is happening. The cloud instance has both IPv4 and ipv6, developer profile is configured with IPv6 and seems kite connect sdk is transmitting the request using IPv4.
    How do we control this while using Java kite connect ? Are their any guidelines on this ? Is that option available in Java kite connect sdk ?
  • Arockiya_r
    seems kite connect sdk is transmitting the request using IPv4
    This is not controlled at the KiteConnect library/SDK level. The SDK will use the network path and source IP chosen by the client environment. For static IP validation, what matters is the actual outgoing IP address from which the request reaches the broker. So this needs to be handled on the client’s infrastructure/network side by identifying the egress IP being used and updating the correct IPv4 or IPv6 whitelisted IP accordingly.
  • sodha_rakesh
    sodha_rakesh edited 4:18AM
    Does the market protection rule also apply to MCX Commodity contracts for algo/API orders?

    “Market orders will require market protection. Orders placed with market protection set to ‘0’ will be rejected. This includes SL-M orders. (This is mandated by the exchanges for all algo orders)”

    If this rule does not apply to MCX Commodities, will the API accept market orders (or SL-M orders) if I send a non-zero market protection value?
  • hanzzo
    Were users alerted to this change in any way or only through this post on this forum??
  • yogeshs
    @Arockiya_r
    If there are multiple accounts configured on the application to use java kite connect sdk, and its running on same cloud instance, how system can set the different ipv6 for different account as your java sdk does not support modifying the http client config.
    Does that mean one will have to use their own http client, instead of yours sdk for order placement?
  • Arockiya_r
    Does the market protection rule also apply to MCX Commodity contracts for algo/API orders?
    yes.
    will the API accept market orders (or SL-M orders) if I send a non-zero market protection value?
    Yes, market with market protection is allowed.
  • AmitManna99
    @Matti
    1. I'm using Kite Publisher Offsite order execution, do I also need to update Static IP, otherwise my order will be rejected?
    2. Since I place Market Order, today my orders are getting rejected saying "Market Orders placed through API need Market Protection". But I don't see any market_protection parameter on your documentation here. I tried to pass it, but that's also not working. Any solution for me?
  • ShreyaPratik
    @AmitManna99 I am also facing similar issue
    first - ❌ Order placement failed: Market orders without market protection are not allowed via API. Please set market protection or use a Limit order.

    After I used market_protection=-1

    ❌ Order placement failed: KiteConnect.place_order() got an unexpected keyword argument 'market_protection'
  • Arockiya_r
    @ShreyaPratik, Please check if you have updated the SDK. Update to the latest version; it should be working.
  • Arockiya_r
    @AmitManna99
    1. Not applicable to the kite publisher.
    2. The market order not allowed rule is also not applicable to the publisher.
  • adarsh1392
    adarsh1392 edited 7:34AM
    @Arockiya_r I updated kitekonnect python library using pip install --upgrade. And it installed kiteconnect-5.1.0. Is this the latest version with market_protection param ?

    Ok, just checked github, 5.1.0 it is.
  • AmitManna99
    @Arockiya_r
    1. Do you mean Market Orders are not allowed for Publisher API?
    2. Because when I'm trying to place MARKET Order, I'm getting error saying - "Market orders without market protection are not allowed via API. Please set market protection or use a Limit order."
    3. When I'm placing LIMIT order, I see limit price automatically become zero when it's going to kite.zerodha.com/connect/basket
  • visasimbu
    What is maximum value we can send as market_protection ?
  • Arockiya_r
    @AmitManna99 I am checking this.
  • visasimbu
    visasimbu edited 7:55AM
    When i send 100 as market_protection for the option premium around 65, the order got rejected with reason as invalid price. What is the logic or check in zerodha end ? Then i sent order with market protection as 20, then it got executed. Can someone throw light on this to understand better.
  • AmitManna99
    Update on my previous comment:
    When I'm placing LIMIT order, I see limit price automatically become zero when it's going to kite.zerodha.com/connect/basket
    I'm able to place LIMIT orders now. Actually the mistake was, my server was sending the limit price, however the HTML Page logic was removing it manually before making POST call to basket page. Since, I used to place MARKET order earlier, I forgot to remove the logic.

    However, the other two points remains a question:
    1. Do you mean Market Orders are not allowed for Publisher API?
    2. Because when I'm trying to place MARKET Order, I'm getting error saying - "Market orders without market protection are not allowed via API. Please set market protection or use a Limit order."
  • Nivas
    1. Do you mean Market Orders are not allowed for Publisher API?
    2. Because when I'm trying to place MARKET Order, I'm getting error saying - "Market orders without market protection are not allowed via API. Please set market protection or use a Limit order."
    @AmitManna99, please share your API key via DM to check and assist you further.
  • Hawk123
    Anyone kindly suggest a dedicated- static ip VPN service which is reliable and affordable. Ty.
  • tuxred
    @Hawk123 .. You may look for a VPS service instead. However ... Reliable and affordable ... achieving both is very very rare. So you have to decide which is a must and which one is good to have. Choose your vps accordingly.
  • Hawk123
    @tuxred i manually place customised orders from excel..
    Not automated trading..
    Vpn is the only way i can think of. Static ip via ISP is needless and expensive.
    Dedicated static ip - VPN service is what I'm looking for.
  • Tusshar18
    @Hawk123, If you travel and trade from different places, its better to get static IP from cloud providers like AWS, coz if you take the same from your network provider, you have to be either physically present there or remotely process orders through third party apps like Anydesk
Sign In or Register to comment.