Skip to main content

trading-static-ip

Monkey-patch the HTTP traffic generated by official Python broker libraries so it exits through your dedicated ServLoci IPv6.

Install

pip install trading-static-ip

The PyPI distribution is named trading-static-ip; the Python import remains servloci so existing code stays compatible.

One-token broker SDK patch

Generate an access token in the ServLoci portal and verify the broker once. Call configure before importing or constructing the broker SDK:

from servloci import configure

configure(token="sl_live_...", broker="dhan")

# Import/create the official broker client after configure().
from dhanhq import dhanhq
dhan = dhanhq(client_id="YOUR_DHAN_CLIENT_ID", access_token="YOUR_DHAN_TOKEN")

# Existing SDK calls now use your ServLoci static IP without URL rewrites.
orders = dhan.get_order_list()

configure patches existing and future requests.Session objects, plus new HTTPX Client and AsyncClient objects. It also exports standard SOCKS proxy environment variables for other proxy-aware libraries. Your broker SDK keeps its normal URL, request body, and authorization headers; ServLoci only provides the network route. Call it before constructing the broker client.

Environment-variable setup is equally small:

export SERVLOCI_TOKEN='sl_live_...'
export SERVLOCI_BROKER='dhan'
import os
from servloci import configure

configure(
    token=os.environ["SERVLOCI_TOKEN"],
    broker=os.environ["SERVLOCI_BROKER"],
)

The SOCKS route supports Dhan, Kite (Zerodha), Groww, FYERS, Upstox, ICICI Direct, and Kotak Neo's approved dynamic production origins.

To restore the original HTTP transports and environment:

from servloci import unconfigure
unconfigure()

Explicit HTTP forwarder

For scripts that do not use a broker library, Client remains available. It forwards supported order/trade paths through /api/v1:

from servloci import Client

client = Client(token="sl_live_...", broker="dhan")
response = client.get(
    "/v2/orders",
    headers={"access-token": "YOUR_DHAN_ACCESS_TOKEN"},
)
response.raise_for_status()

Legacy SOCKS credentials

The original helper remains backwards compatible:

pip install 'trading-static-ip[socks]'
import servloci

servloci.configure(
    api_key="dhan:1000000001",
    api_secret="YOUR_SOCKS_PASSWORD",
)

# Import the broker SDK only after configure().
from dhanhq import dhanhq

The legacy api_key + api_secret call uses the same transport patches and remains available for existing deployments.

Security

  • Treat sl_live_... as a password; never commit or log it.
  • Access tokens are displayed once, stored server-side only as SHA-256 hashes, and can be rotated or revoked in the portal.
  • The SOCKS server permits only the verified broker's approved HTTPS hosts.
  • The explicit application forwarder remains restricted to documented order/trade paths.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trading_static_ip-0.3.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trading_static_ip-0.3.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file trading_static_ip-0.3.0.tar.gz.

File metadata

  • Download URL: trading_static_ip-0.3.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for trading_static_ip-0.3.0.tar.gz
Algorithm Hash digest
SHA256 97849c5e622c714e5cf0f3492c1c09af6da907fc9b7dc17f36917dec00ebbdff
MD5 58cb9a4891f22af8de80d359707575a7
BLAKE2b-256 9e58c0210749ff630a481b729d3422b3d59db3fac0629eedbc23f53dc3e0ef4e

See more details on using hashes here.

File details

Details for the file trading_static_ip-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for trading_static_ip-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf93a5a4c8ad7f2636ae51523d799807f86c61347ac58225d1e60a0670e74a60
MD5 64462a2f91080db53834eddb89b433e7
BLAKE2b-256 f99627859d2a5a7c6e1de20359d24c5ed99a5b803cfa34974767629000ae5d0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page