Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

How to set up a static IP for mStock API usage

Last updated on 7 hours ago
K
KevinMember
Posted 7 hours ago
Since you are developing an algo trading system (with Python, real-time LTP & volume, training model etc.), having a stable IP is favourable. Here are the recommended steps:

Choose a network environment with a fixed public IP

If you are running your system from home/office broadband, contact your ISP and ask for a static public IP plan (not dynamic) so your outbound traffic always bears the same IP.

Alternatively, host your trading backend on a cloud VM/instance and allocate a reserved/public static IP (e.g., on AWS, Google Cloud, Azure, DigitalOcean).

Ensure all your API traffic (to m.Stock) originates from that single public IP (or a small set of whitelisted IPs if allowed).

This helps with order-flow consistency, whitelisting, and regulatory compliance (algo trading, low latency, etc.).

Contact m.Stock / your account manager / API onboarding team

Ask: “Do you support whitelisting static IPs for API requests (especially order execution)?”

Provide your static IP(s) and ask them to register that IP so that your server traffic is permitted.

Confirm if they allow secondary/back-up IPs in case you move to another server or have failover.

Ask if there is any minimum latency requirement or region preference (for low latency algo trading).

Keep documentation of the IP registration (date, IP, account, scope of usage etc).

Configure your trading backend to use that IP and secure the path

In your Python/pyqt/automation stack you build, ensure that all outbound API calls go out via the static IP (i.e., your server’s main NIC/public interface).

Make sure that you are not accidentally using some proxy or NAT that changes the public IP.

Use environment variables (as you already do) to store API key/secret etc. Eg:

MSTOCK_API_KEY=your_key
MSTOCK_API_SECRET=your_secret
MSTOCK_STATIC_IP=xx.xx.xx.xx


When deploying, monitor your server’s public IP occasionally (e.g., via curl https://ipinfo.io/ip) to confirm it hasn’t changed.

Test order-placement and error handling

Before going live with your model (scalping, volume/LTP based) test placing orders via API from your static IP.

If you get “IP not allowed” or “unauthorised source” type errors, you’ll know the static IP needs to be registered with m.Stock.

Add logic in your code to log API errors (especially authentication or network errors) and if needed alert you when the IP has changed unexpectedly.

Maintain & document your setup

Ensure the static IP remains unchanged (if your plan changes with ISP, or you shift cloud provider, update m.Stock).

Keep track of any modifications: e.g., if you shift to a different server/IP, contact m.Stock to update whitelisting.

For your algo system (you mentioned continuous learning, daily retraining), downtime due to IP mismatch would hurt — so plan for redundancy if possible.
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.
Sign In
Not a member yet? Click here to register.
Forgot Password?
Users Online Now
Guests Online 4
Members Online 0

Total Members: 19
Newest Member: bokovac