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 does not change global proxy environment variables by default, so later pip commands and unrelated Colab traffic stay direct. Your broker SDK keeps its normal URL, request body, and authorization headers; ServLoci only provides the network route.

For another proxy-aware library that is not based on requests or HTTPX, opt in to process and subprocess proxy variables with configure(..., export_env=True).

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.1.tar.gz (10.2 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.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trading_static_ip-0.3.1.tar.gz
  • Upload date:
  • Size: 10.2 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.1.tar.gz
Algorithm Hash digest
SHA256 51b8acea1813899a92dde386d46de2fa53c381a4162a706c058a5f765ec75444
MD5 5ca90039d98e806e04abec62a27b5e5c
BLAKE2b-256 58f228cabafc89fe6f51db62f490bb55dab5db5964579f077652f7ee92915904

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trading_static_ip-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26955184064f61b6c5dffa53c4165e99577584d588c4613817b042e362f6b585
MD5 4b516401170e3eb6c784e05fe7081595
BLAKE2b-256 f23ca4ffc0b902ff1a40f7c1ac581bc6f3b9c4a6bc97198f66b7275b03587f24

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