Raven Trader: My Fully Autonomous, AI-Powered Stock Trading Bot

sam9s

Well-Known Member
Joined
Aug 25, 2009
Messages
5,258
Points
113
Hey everyone! Some of you might remember my earlier post about Raven — my AI-powered media server assistant that manages my entire self-hosted media stack via Telegram. That post got a great response, and a lot of you were interested in the OpenClaw framework I used.

Well, I've been busy. This time, I built something even crazier.

I built a fully autonomous AI trading bot for the Indian stock market.


What is Raven Trader?​


Raven Trader is an AI system that trades stocks on the NSE/BSE autonomously. No human intervention required.


It runs 24/5 on my VPS, connects to Angel One (my brokerage) via their SmartAPI, and makes its own buy/sell decisions based on multi-agent AI research. Every morning at 7 AM, it sends me a Telegram briefing with what it did, what it's holding, and how the portfolio is performing.


I don't approve trades. I don't pick stocks. I just read the report.


The important context: I have literally zero trading experience. Never traded a stock in my life before this project. This entire system was designed and architected using AI (Claude as my solution architect), and coded by AI (Claude Code as my developer). I acted as the project manager.

Why I Built It​


I watched a YouTube experiment where two guys (Nate Herk and Samin) each gave $10,000 to their AI trading bots and let them compete for 30 days. The S&P 500 dropped 8.5% during that period. Nate's bot lost only $19. Samin's lost about $375. Both outperformed the market.
The kicker? Nate's winning bot had the simplest prompt: "You are a wealth adviser. Spin up a team. Do your best." No complex strategy. Just AI autonomy with guardrails.

That's when I decided to build one for the Indian market.

How It Works (Under the Hood)​


Raven Trader is a Python application running as a systemd service on my Hostinger VPS (the same one running my media server Raven).

The Architecture:

The bot has 6 AI sub-agents, each analyzing the market from a different perspective:


🔍 Technical Analyst — Reads price action, moving averages, RSI, MACD, Bollinger Bands, volume patterns. Pure chart analysis.

📊 Fundamental Analyst — Evaluates company health: PE ratios, debt levels, revenue growth, sector outlook. Uses GPT-4o for analysis.

📰 Sentiment Analyst — Scrapes financial news via Google News RSS and runs sentiment analysis through an LLM. Gauges whether news is bullish or bearish.

💰 Smart Money Tracker — Monitors FII/DII flows (Foreign and Domestic Institutional Investor activity), bulk/block deals on NSE, and SEBI insider trade disclosures. When the big money is buying, this agent notices.

⚖️ Risk Officer — The gatekeeper. Validates every trade recommendation against strict rules: position size limits, cash reserve requirements, daily loss limits, sector concentration caps. If a trade violates any rule, it's rejected.

🎯 Chief Strategist — The orchestrator. Collects signals from all 5 agents, weighs them (Technical 25%, Fundamental 25%, Sentiment 20%, Smart Money 20%, Market Regime 10%), and makes the final call. Only trades with 70%+ aggregate confidence get executed.

The Execution Loop:

Every hour during market hours (9:30 AM to 2:30 PM IST):
  1. Screen Nifty 100 stocks through liquidity and quality filters
  2. Run all 6 agents on the top candidates
  3. Aggregate signals and calculate confidence scores
  4. Risk Officer validates approved trades
  5. Execute trades via Angel One SmartAPI

Every 5 minutes: update all holding prices and check stop losses.

Risk Management (the most important part):
  • 7% hard stop loss per position (non-negotiable — if a stock drops 7%, sell it)
  • Trailing stop activates at +10% gain, trails at 5% below peak
  • 15% of portfolio always in cash reserve
  • Max 7 open positions at any time
  • Max 20% of portfolio in any single stock
  • 3% daily loss limit (trading halts if breached)
  • 5% weekly loss limit (enters "defensive mode" — no new trades for 48 hours)

Brokerage:Angel One SmartAPI — free API access, zero brokerage on equity delivery trades. The bot's VPS static IP is registered with Angel One for API compliance (required since April 2026 per SEBI/NSE guidelines).

Database:PostgreSQL (via self-hosted Supabase on my VPS) with a dedicated raven_trader schema. Tracks every order, every signal, every portfolio snapshot. Complete audit trail.

Notifications:Telegram bot sends:
  • Trade execution alerts (real-time)
  • "Position in the green" celebrations 😎
  • Daily briefing at 7:00 AM
  • Weekly deep-dive report on Sundays at 7:00 PM
  • Critical alerts (loss limits breached, auth failures)

Day 1 Results (Paper Trading)​

I'm running in paper trading mode for 30 days — real market data, simulated money, zero risk. The bot started with ₹10,000.

What it bought on Day 1:
  • Stock 1 : 24 shares @ ₹312.83 avg → Already profitable (+0.6%)
  • Stock 2 : 3 shares @ ₹389.44 → In the green (+0.5%)
  • Stock 3 : 1 share @ ₹1,067.68 → Slight dip (-0.1%)
Portfolio after Day 1: ₹9,991.30 (down ₹8.70 including transaction costs)

The bot picked infrastructure/power stocks — which makes sense given the current market conditions and FII flows into that sector. I didn't tell it to do that. It figured it out on its own.
 
Last edited by a moderator:
Something I am seeing in Flesh. Many Tweets just say agents for trading, you are showing how its done. Thanks again explaining in detail. Thread subscribed. Keep rolling!
 
Thanx for sharing...Its really interesting and am definitely hooked...What kind of subscriptions are you using for this ? Also you mentioned openclaw...From what I can see, you are using agentic AI frameworks....But where exactly does openclaw fit into this ? Are you going to opensource this after some time ???? It would become highly popular I think ....If you want some more testers, I'm more than willing.
 
Thanx for sharing...Its really interesting and am definitely hooked...What kind of subscriptions are you using for this ? Also you mentioned openclaw...From what I can see, you are using agentic AI frameworks....But where exactly does openclaw fit into this ? Are you going to opensource this after some time ???? It would become highly popular I think ....If you want some more testers, I'm more than willing.
Thanks brother i am using a combination of Claude Plus account and GPT Plus account so i keep shifting between these two it is a little pain but then that is the only way i can save cost i still cannot afford taking pro or max plan. so that will answer your question about the subscription. Coming to open claw it's not yet wired in as it was wired in on my other media server ai project right now it is just one-sided communication like my Raven Trader just sends me updates on my Telegram. I cannot communicate back. that is where open claw will come into the picture but that's not a priority in this project because i don't really want to communicate with my bot here i just want my bot to trade intelligently and bring me profits and share updates so i might not wire in open claw in this project

coming to your third question making it open source brother you know how much people die for an effective trading algorithm if i open source this then i am literally sharing my algorithm out in the world for everybody to use to do their trading ☺️ cant do that....on the contrary i was planning to license it and then if it works nicely then sell it for a price...

coming to your last question about testers yes definitely i will ..... i am running my own company ravensolutions.in ...... i'm not sure if i can share the website link here but it's simple go to a new tab type ravensolutions.in and you should see it so in that case if i ever need to do some testing definitely i'll contact you.
 
Moderator Note:

With due respect to the OP and FMs who are interested in this thread, we would like to caution that this thread is by a FM who by his own admission has minimal experience in Stock Markets and Trading. Please be aware that using AI without knowledge of the under pining software has risk. Combining AI with Stock Market investing increases the risk. The decision to allow this topic is under review by the moderators.

Please continue to follow this thread discussion only as an informative discussion on AI.
The original post has been edited to replace the names of stocks to avoid any issues.

Regards


.
 
coming to your third question making it open source brother you know how much people die for an effective trading algorithm if i open source this then i am literally sharing my algorithm out in the world for everybody to use to do their trading ☺️ cant do that....on the contrary i was planning to license it and then if it works nicely then sell it for a price...

Quick reality check before you go too deep. Do you know what 'making it available for licensing' actually involves in India now? Assuming your algo doesn't disclose its logic to users (which is what you said), SEBI classifies it as a black-box algo, and the path is roughly:
  • Get a SEBI Research Analyst license. NISM-Series-XV certification, ongoing compliance, annual audits, maintain research rationale for every call. And this isn't a one-time thing, it's a perpetual compliance load.
  • Empanel with NSE/BSE as an algo provider. Separate process, separate paperwork, separate due diligence.
  • Partner with a broker who's willing to take you on as an agent (they become the principal, you're the agent). They'll do their own due diligence on your algo and your compliance posture. Not every broker will say yes.
  • Get exchange approval for the strategy itself. Every algo needs an Algo ID. Every modification needs re-approval. You can't just push code changes like a normal software product.
  • Build the compliant infrastructure — static IP whitelisting, OAuth + 2FA, unique order tagging, audit logs for every order, kill switch, grievance handling. This is real engineering work, not a weekend project.
  • Maintain detailed research/trading thesis reports for the black-box logic. SEBI can ask to see them. So the 'I won't tell anyone how it works' plan doesn't work with the regulator; you just don't tell the users.
Don't get me wrong. I hope the algo works out and you make a pile. SEBI is totally fine with you running it for yourself and your immediate family, so there's a real path even without the full licensing circus. The reason I'm writing this is that 'I'll license it but I won't tell you how it works' is a much bigger undertaking in India than it sounds, and I'd rather you know the road before you start walking it.

Regards,
Arun
 
Quick reality check before you go too deep. Do you know what 'making it available for licensing' actually involves in India now? Assuming your algo doesn't disclose its logic to users (which is what you said), SEBI classifies it as a black-box algo, and the path is roughly:
  • Get a SEBI Research Analyst license. NISM-Series-XV certification, ongoing compliance, annual audits, maintain research rationale for every call. And this isn't a one-time thing, it's a perpetual compliance load.
  • Empanel with NSE/BSE as an algo provider. Separate process, separate paperwork, separate due diligence.
  • Partner with a broker who's willing to take you on as an agent (they become the principal, you're the agent). They'll do their own due diligence on your algo and your compliance posture. Not every broker will say yes.
  • Get exchange approval for the strategy itself. Every algo needs an Algo ID. Every modification needs re-approval. You can't just push code changes like a normal software product.
  • Build the compliant infrastructure — static IP whitelisting, OAuth + 2FA, unique order tagging, audit logs for every order, kill switch, grievance handling. This is real engineering work, not a weekend project.
  • Maintain detailed research/trading thesis reports for the black-box logic. SEBI can ask to see them. So the 'I won't tell anyone how it works' plan doesn't work with the regulator; you just don't tell the users.
Don't get me wrong. I hope the algo works out and you make a pile. SEBI is totally fine with you running it for yourself and your immediate family, so there's a real path even without the full licensing circus. The reason I'm writing this is that 'I'll license it but I won't tell you how it works' is a much bigger undertaking in India than it sounds, and I'd rather you know the road before you start walking it.

Regards,
Arun
Thanks, brother, for the heads up. Of course, I did not know anything about any of these things, which is obvious, since I have never even traded in my entire life. This is something I just did because of my love for technology and AI. Why not try to use it here as well?

Inspiration came from two of my most beloved YouTubers who create and make videos on AI and AI automation. Once that stage is reached where I actually start thinking about doing something like this, I will definitely contact you. Of course, I will do my due diligence and my research as well, assuming that after three to four months, the algo actually makes me profit. Up until now, I have reached almost 3% profit on all three trades my bot did on paper money, so let's wait and watch. :)
 
Quick reality check before you go too deep. Do you know what 'making it available for licensing' actually involves in India now? Assuming your algo doesn't disclose its logic to users (which is what you said), SEBI classifies it as a black-box algo, and the path is roughly:
  • Get a SEBI Research Analyst license. NISM-Series-XV certification, ongoing compliance, annual audits, maintain research rationale for every call. And this isn't a one-time thing, it's a perpetual compliance load.
  • Empanel with NSE/BSE as an algo provider. Separate process, separate paperwork, separate due diligence.
  • Partner with a broker who's willing to take you on as an agent (they become the principal, you're the agent). They'll do their own due diligence on your algo and your compliance posture. Not every broker will say yes.
  • Get exchange approval for the strategy itself. Every algo needs an Algo ID. Every modification needs re-approval. You can't just push code changes like a normal software product.
  • Build the compliant infrastructure — static IP whitelisting, OAuth + 2FA, unique order tagging, audit logs for every order, kill switch, grievance handling. This is real engineering work, not a weekend project.
  • Maintain detailed research/trading thesis reports for the black-box logic. SEBI can ask to see them. So the 'I won't tell anyone how it works' plan doesn't work with the regulator; you just don't tell the users.
Don't get me wrong. I hope the algo works out and you make a pile. SEBI is totally fine with you running it for yourself and your immediate family, so there's a real path even without the full licensing circus. The reason I'm writing this is that 'I'll license it but I won't tell you how it works' is a much bigger undertaking in India than it sounds, and I'd rather you know the road before you start walking it.

Regards,
Arun
Hi Arun, what you are referring to is SEBI's circular on algo regulations
https://www.sebi.gov.in/legal/circu...l-investors-in-algorithmic-trading_91614.html

One needs RA license when the orders exceed 10 per second. If one is working on HFT: High Frequency Trading, SEBI mandates that one empanel their algo, where it is assigned an ID. For retail traders, who have don't exceed that threshold, it is not necessary to register their algo. Yes, black-box and white-box algo distinction comes next.
 
Hey everyone! Some of you might remember my earlier post about Raven — my AI-powered media server assistant that manages my entire self-hosted media stack via Telegram. That post got a great response, and a lot of you were interested in the OpenClaw framework I used.

Well, I've been busy. This time, I built something even crazier.

I built a fully autonomous AI trading bot for the Indian stock market.


What is Raven Trader?​


Raven Trader is an AI system that trades stocks on the NSE/BSE autonomously. No human intervention required.


It runs 24/5 on my VPS, connects to Angel One (my brokerage) via their SmartAPI, and makes its own buy/sell decisions based on multi-agent AI research. Every morning at 7 AM, it sends me a Telegram briefing with what it did, what it's holding, and how the portfolio is performing.


I don't approve trades. I don't pick stocks. I just read the report.


The important context: I have literally zero trading experience. Never traded a stock in my life before this project. This entire system was designed and architected using AI (Claude as my solution architect), and coded by AI (Claude Code as my developer). I acted as the project manager.

Hey Sam, good to see you exploring this space. I can see that enthusiasm. I've been at this for over nine months now. It is an exciting space, now that we have agentic AI helping us. I've been deeply engaged with building two autonomous trading systems - both in the Derivates and Equity segment.

My coding workflow has increased 100x. What would take months or years, now takes days or hours. We can now build intensive trading systems and test them with a simple prompt. And there are workflows like Andrej Karpathy's Auto Research, which can continuously do backtests and refine itself until you get positive P&L. They will keep working until they achieve the results.

I can understand your excitement, but you need to seriously backtest this. What is the XIRR/CAGR, Win:Loss Ratio, Max DrawDown, Sharpe ratio, etc? They do matter, and can show whether your system is actually making money in the longer term. And also consider slippage, brokerage, STT, GST that will eat up the profits and compound losses. Backtests usually take it in account.
 
Hey Sam, good to see you exploring this space. I can see that enthusiasm. I've been at this for over nine months now. It is an exciting space, now that we have agentic AI helping us. I've been deeply engaged with building two autonomous trading systems - both in the Derivates and Equity segment.

My coding workflow has increased 100x. What would take months or years, now takes days or hours. We can now build intensive trading systems and test them with a simple prompt. And there are workflows like Andrej Karpathy's Auto Research, which can continuously do backtests and refine itself until you get positive P&L. They will keep working until they achieve the results.

I can understand your excitement, but you need to seriously backtest this. What is the XIRR/CAGR, Win:Loss Ratio, Max DrawDown, Sharpe ratio, etc? They do matter, and can show whether your system is actually making money in the longer term. And also consider slippage, brokerage, STT, GST that will eat up the profits and compound losses. Backtests usually take it in account.
Hi Brother,

Well I will be honest. I do not know most of the things you have written :) as I am not even a novice trader .. lol this project is for fun, if it succeeds well and good, if it doesn't, well no harm in trying ... up untill now the bot is performing really good. all of my 3 stocks are above 3% now. For 30 days it will be just paper trading, if all looks ok, then a marginal amount of actual money will be invested and will wait for another 30 days ... if till that time bot performance is consistent, then yes I might think of pumping some substantial amount. by that time I would have enough confidence that bot logic is consistent

About your calculations, below is what my bot has configured as a safety net ..

Per-stock: hard 7% stop loss (non-negotiable, no "it'll bounce back" thinking) + a trailing stop that kicks in at +10% gain. The trailing stop follows the price up but never moves down, so it locks in profits without capping them.
Per-portfolio: 15% of capital always held as cash reserve, max 7 open positions at a time, max 5 new buys per day. Keeps things sane.
Circuit breakers: 3% daily loss → no new buys the rest of the day. 5% weekly loss → "defensive mode" kicks in. No buying for 48 hours, all trailing stops tighten to 3%. Basically, a timeout so the bot doesn't revenge-trade.
For unexpected stuff, the most underrated thing IMO is the hourly thesis review. Every hour the bot re-runs its full analysis on every stock it's holding. If the reasoning for being in that stock weakens (confidence drops below 40%), it sells regardless of P&L. "Thesis changed, get out." That's what protects against the slow-motion blow-ups — the kind where a stock bleeds 20% over 2 weeks while you tell yourself "just one more day."
So stops handle fast drops, thesis review handles slow ones. Not claiming it survives a 2008 perfectly — nothing does — but the whole design philosophy is "take many small losses instead of one big one."

I could not have created that net or done that kind of calculation in a million years ... :D I am just trusting my bot, in 2 to 3 months if that trust remains consistent, then I will start to play with some actual cash ...

On the technical front, I know what I am doing and I am using Andrej Karpathy's Auto Research :)

About that license thing, again, no idea what was discussed, however, when I reach that point, I will dive into my usual research and see where it takes me :)
 
Wharfedale Linton Heritage Speakers in Walnut finish at a Special Offer Price. BUY now before the price increase.
Back
Top