
Chapter 5 | 2 min read
Deploying Your Algo for Live Trading
Going live doesn’t mean jumping in with all your savings. It means **letting your code start watching live markets, generating signals, and eventually placing trades.
Let’s walk through the basics of how to go from backtest to real trade.
Step-by-step Plan to Deploy
Step 1: Use a Broker API (once you're confident)
Almost all major brokers in India offer APIs that let you:
- Fetch live prices
- Place orders
- Track positions
These APIs usually need:
-
API Key – A unique code provided by your broker when you register for API access. Think of it as your account’s ID for the program.
-
Secret Key – Like a password for your API key, used to verify that the request is really coming from you. Keep this private.
-
Access Token (generated daily) – A short-lived “entry pass” that allows your program to stay connected to your broker’s system for the day. You’ll need to regenerate this every trading day for security reasons.
Once you have access, you can use Python packages like requests (to send data), websocket-client (to stream live market data), or your broker’s SDK (ready-made tools to place orders, fetch data, and manage trades).
Note: You can search for “[your broker] API Python” online to explore documentation for your respective broker
Note: You can search for “[your broker] API Python” online to explore documentation for your respective broker
Step 2: Schedule Your Algo
Use schedule or time modules in Python to run your code every few seconds or minutes.
Example:
import time
#while market_is_open
check_price_and_place_order()
Note:
This snippet is a basic framework for running trading logic in a loop at fixed intervals during market hours:
-
import time loads Python’s built-in time module, allowing delays between code executions.
-
The commented-out while market_is_open: indicates a loop that would keep running as long as the market is open.
-
check_price_and_place_order() is a placeholder for the function that would fetch prices, check strategy conditions, and place orders.
This pattern is common for live algo trading where you need to execute checks periodically rather than continuously hammering the data source.
You can host this on:
-
Your local PC – Run your code on your own computer, but keep it switched on during market hours so it can execute trades without interruption.
-
A VPS/cloud server – A rented online computer (paid service) that stays on 24×7, allowing your trading bot to run even when your personal PC is off.
-
Platforms that support algo hosting – Special services provided by some brokers or third-party providers where you can upload your trading code and they handle the hosting and execution for you.
Step 3: Add Alerts and Logging
Don’t just fire orders silently. Always:
- Log each action in a file
- Send yourself alerts (email, Telegram, WhatsApp) for each trade
- Add print statements to track progress
Step 4: Go Live Slowly
Start small:
- Trade with minimum capital
- Monitor execution speed, slippage, and bugs
- Keep backup capital and don’t panic during volatility
Most algo traders fail not because of bad logic — but because of:
- Overconfidence
- Poor risk management
- Technical glitches
Final Safety Checklist
- Is your code tested thoroughly?
- Have you run it in paper mode?
- Do you have internet + power backup?
- Is capital allocation limited?
- Can you monitor/stop it quickly if needed?
If yes — welcome to the world of real algo trading 🚀
In the next module, we’ll explore common algo strategies — momentum, mean reversion, pairs trading and more.
Recommended Courses for you
Beyond Stockshaala
Discover our extensive knowledge center
Learn, Invest, and Grow with Kotak Videos
Explore our comprehensive video library that blends expert market insights with Kotak's innovative financial solutions to support your goals.













