Your Trading Rule Deserves Better Than Your Attention Span
A short guide to Trade APIs on HDFC InvestRight.
Priya writes code for a living.
She also trades. What bothers her is simple: she can automate everything at work, yet she still sits watching a chart at 9:45 AM because a setup might fire.
Her rules are solid. Her execution depends on whether she is at her desk.
The rules were never the problem. Priya was the gap between the rules and the market.
HDFC InvestRight Trade APIs close that gap by letting your account respond to code instead of mood.
If you are already on HDFC InvestRight, you already have access
No new trading account.
API access is free.
Go to developer.hdfcsec.com, register, and create your app. That gives you a key.
An app here is simply an identity for your code so HSL knows the requests are yours.
Everything stays familiar.
Orders placed by your code appear in your normal InvestRight order book.
Positions show in your usual portfolio.
Funds and margin behave exactly the same.
You are not changing platforms.
You are opening a second door to the same account.
What the APIs let you do
📊 See your account
Fetch holdings, positions, order book, trade book and available funds in code.
⚡ Place and manage orders
Buy, sell, modify and cancel across equity, F&O and commodity on supported exchanges.
📈 Read market data
Get last traded price and historical data.
🔁 Confirm executions
Read the order book after every action so your system knows the exact outcome.
Everything you can build starts from these four abilities.
Things people build
A custom terminal
Your instruments, your position sizing, your shortcuts. Not a screen designed for everyone else.
A risk guard
A watcher that alerts you when margin crosses a threshold, when a position hits your stop, or when you take more trades than your plan allows.
It never places orders. It is still the highest value tool most traders create.
A trading diary
Save orders and holdings every evening. After a few months you finally learn which setups work after costs and what you truly paid in brokerage.
A portfolio dashboard
Exposure, concentration, sector drift, realised and unrealised. Your numbers, your format.
Getting started: one evening
Step 1: Get your keys
Go to developer.hdfcsec.com, register and create your app. Store your key and secret safely.
Step 2: Get a session
Follow the login flow in the docs until you have a working token.
A token is a temporary pass that proves each request is from you.
Step 3: Read something
Make one call: fetch your holdings. Print them. You just read your portfolio in code.
Step 4: Write something
Place one real order for one share of something inexpensive. Cancel it.
That one order teaches you more than a week of reading.
Step 5: Build a watcher
Not a bot. A simple tool that checks your rules and messages you when they break.
It cannot lose money and it fixes the costliest habit most traders have.
Two habits worth keeping
Keep your API secret out of your repo
Obvious, often ignored.
Always verify executions
After each order, read back the order book.
Rejections and partial fills are normal.
Most automation failures come from loops that resend orders repeatedly after a connection drop.
One note on the rules
Retail algo trading in India runs under a SEBI framework.
Broker API–based algos must be registered and tagged, and order rate limits must be respected.
Use the official developer portal. Register properly.
Do not engineer around order rate limits. They protect the market and you.
Start today
Open the docs at developer.hdfcsec.com and make one holdings call work.
That is day one. Nothing more.
Priya’s rules were always good enough.
They just needed something more reliable than Priya’s schedule.
Prefer not to write code
You can subscribe to ready algorithmic strategies inside HDFC InvestRight or at algobulls.hdfcsec.com.
Disclaimer:
Investments in securities markets carry risk. Automated strategies carry execution, technology, and model risk. Read all documents carefully before investing. API features, availability, and charges may change. Refer to official documentation for current information.
Related Posts
Don't miss another Article
Subscribe to our blog for free and get regular updates right into your inbox.
Categories
newsletter
HSL Mobile App