Static IP How-to New

Route Your Algo Through a Static IP: Proxy Setup and Verification for Indian Broker APIs

Most guides stop at “whitelist your static IP.” That is half the job. The other half is making sure your orders actually leave from that IP. This guide shows how to route a script through your static IP, prove it, and check it every morning before the market opens.

TS
TradeSteady Algo
Published: 8 min read

In This Article

  1. Whitelisting Is Not Routing
  2. Who Makes the Call to Your Broker?
  3. Step 1: Prove the Proxy Gives You the IP
  4. Step 2: Route the Right Calls
  5. Step 3: Create the Session From the Same IP
  6. Step 4: A Pre-Market Check
  7. Timeouts: Do Not Resend Blindly
  8. Troubleshooting
  9. Frequently Asked Questions

1. Whitelisting Is Not Routing

Whitelisting writes your static IP into your broker’s developer portal. It changes nothing about where your script sends its requests from. If the script runs on your laptop and calls the broker directly, the request leaves from your home or office IP, and the broker rejects it, even though your whitelist is perfect.

That is the single most common reason people say “I whitelisted it and it still fails.” The fix is to send the request through the static IP. A TradeSteady static IP comes with HTTP and SOCKS5 proxy credentials for exactly this: your script talks to the proxy, the proxy talks to the broker, and the broker sees your static IP.

Already using TradeSteady for webhooks? Then your orders are routed through the static IP automatically and you can skip this guide. It is for people who run their own scripts. If you want the rules and the whitelisting steps first, start with the whitelisting guide.

2. Who Makes the Call to Your Broker?

The question that decides everything is simple: which machine sends the order request to the broker? That machine’s outbound IP is the one the broker checks.

Your setupThe broker seesWhat to do
TradingView alert → TradeSteady → broker Your static IP Nothing. Routed automatically
Your own script on a laptop or home PC Your home or office IP Route through the proxy (this guide)
Your own script on a cloud server The server’s IP Whitelist that IP, or route through the proxy
A third-party algo platform The platform’s IP Ask the platform which IP to whitelist

Running your script on a laptop and routing it through the proxy is the cheapest, simplest case: no server to rent, patch or monitor. The rest of this guide covers it.

3. Step 1: Prove the Proxy Gives You the IP

Before you touch your broker, check that your proxy really exits from your static IP. Put the proxy credentials from your dashboard into a quick test that asks an IP-echo service what address it sees.

With curl:

curl -x "socks5h://USER:PASS@HOST:PORT" https://api.ipify.org

Or in Python, comparing the direct and proxied results side by side:

# pip install "requests[socks]"
import requests

PROXY = "socks5h://USER:PASS@HOST:PORT"   # from your TradeSteady dashboard
EXPECTED = "YOUR.STATIC.IP"               # the IP shown in your dashboard
proxies = {"http": PROXY, "https": PROXY}

def egress_ip(proxies=None):
    r = requests.get("https://api.ipify.org", proxies=proxies, timeout=10)
    r.raise_for_status()
    return r.text.strip()

print("direct :", egress_ip())            # your own network's IP
print("proxied:", egress_ip(proxies))     # must equal EXPECTED

The proxied line must match the IP in your dashboard exactly. The direct line should be different. If both lines show the same address, your code is not using the proxy.

Treat the proxy credentials like a password. Anyone holding them can send traffic from your IP. Keep them in an environment variable or a secrets manager, never in your code or in git. If you think they have leaked, tell support straight away.

The socks5h scheme (with the h) makes the proxy resolve hostnames too, so name lookups do not leave from your own network. requests needs the requests[socks] extra for SOCKS.

4. Step 2: Route the Right Calls

Once the test passes, send your broker calls through the same proxy. With requests, a single session does it:

import requests

session = requests.Session()
session.trust_env = False        # ignore proxy environment variables
session.proxies.update(proxies)  # every call on this session uses the static IP

# Use this session for the broker's ORDER calls (and for creating the
# session/token, if your broker ties it to the IP).
resp = session.post(BROKER_ORDER_URL, json=order, headers=auth_headers, timeout=15)

Two points matter here:

5. Step 3: Create the Session From the Same IP

Some brokers tie your login session to the IP it was created from. Kotak Neo says so on its developer page: order APIs accept requests only from a whitelisted IP with a session created from that same IP. If the session came from a different address you get error 1037 (session IP mismatch), and a non-whitelisted IP returns 100008.

The safe habit, for any broker:

  1. Create the token or session through the proxy, so it is born on the static IP.
  2. Place orders through the same proxy.
  3. After you add or change a whitelisted IP, generate a fresh token. An older one can keep failing.
Check the change rules first. Several brokers lock or limit IP changes. Dhan locks the IP for 7 days after you set it, Zerodha allows one change per calendar week, and Kotak Neo allows one change every 7 days. Because the static IP never changes, you set it once, but get it right the first time: copy it from the dashboard, do not retype it.

6. Step 4: A Pre-Market Check

A static IP is meant to be boring, but your setup can still drift: a proxy setting removed in a refactor, a credential rotated, a new machine without the extra installed. Catch it before the first order, not after a missed trade. Add a check that stops the script if the egress IP is wrong:

import sys

def preflight():
    seen = egress_ip(proxies)
    if seen != EXPECTED:
        sys.exit(f"Egress IP is {seen}, expected {EXPECTED}. Not trading.")

preflight()   # run before the first order of the day

Two details make this check honest. It fails closed: if the proxy is down or the IP does not match, the script stops, and it does not quietly fall back to a direct connection. And it runs on the same machine and code path that will place the orders, not on a different laptop.

7. Timeouts: Do Not Resend Blindly

A proxy adds a hop, so give requests a sensible timeout (the examples use 10 to 15 seconds). But a timeout is not a failure. The order may have reached the broker and the reply may simply have been lost.

8. Troubleshooting

SymptomLikely causeFix
Proxied IP in the test differs from your dashboard IP Wrong or old credentials, or the IP has expired Re-copy the credentials and check expiry in the dashboard
Proxied and direct IPs are the same The proxy is not being applied Set it on the session or SDK, and ignore proxy environment variables with trust_env = False
HTTP 407 from the proxy Username or password is wrong, or has stray characters Re-copy it. Special characters in the password may need URL-encoding
Broker says IP not whitelisted The order call is not going through the proxy, or the IP was added after your token was issued Print the egress IP inside the order path, then regenerate the token
Kotak Neo error 1037 Session created from a different IP Create the session through the proxy, then order through it
Works in testing, fails from your server The server has IPv6 and prefers it for outbound traffic Route through the proxy, which always exits over your IPv4

For broker-specific error codes and every cause we know of, read “IP Not Whitelisted”: why your broker keeps rejecting API orders.

9. Frequently Asked Questions

What is the difference between whitelisting an IP and routing through it?

Whitelisting tells your broker which address to trust. Routing is what makes your orders actually leave from that address. If your script is not routed through the static IP, it sends from wherever it runs, and the broker rejects it even though the whitelist is correct.

Do I need to route market data through the proxy as well?

Usually not. Brokers such as Kotak Neo document that only place, modify and cancel order calls are checked against the IP, while data and websocket calls are not. Confirm this for your broker, and route only the calls that need it.

Should the login or token request go through the proxy too?

Yes, for brokers that tie the session to the IP. Kotak Neo, for example, requires the session to be created from the same IP that sends the orders, and returns error 1037 otherwise. Generate your token or session through the same proxy, and generate a fresh one after any IP change.

Which proxy type should I use, HTTP or SOCKS5?

Either works with a TradeSteady static IP. SOCKS5 is the simpler choice for most scripts. Use whichever your HTTP client supports best.

My order request timed out. Is it safe to send it again?

No. A timeout does not mean the order failed. It may have reached the broker. Check your order book first, then decide. Resending blindly can double your position.

Do I need to do any of this if I use TradeSteady for webhooks?

No. Orders placed through TradeSteady are routed through your static IP automatically. This guide is for people who run their own scripts.

Get a Static IP With Proxy Credentials

Dedicated Indian IPv4 with HTTP and SOCKS5 proxy credentials — ₹499/month, or ₹4,499/year on the limited-time yearly plan (till 31 Dec 2026)
Same IP on renewal • Works with Zerodha, Dhan, Fyers, Angel One, Upstox, Groww & more

Buy Static IP

Need help? Chat with us on WhatsApp

Share this article:

Related

Disclaimer · Terms · Privacy · FAQ