DEV Community

shakti tiwari
shakti tiwari

Posted on

Brain Markets: My Second Book on AI, Neuroscience, and the Future of Indian Markets

Brain Markets: My Second Book on AI, Neuroscience, and the Future of Indian Markets

DOYR | Not financial/legal/tax advice. For educational purposes only.


If Right Brain Wins was about psychology, Brain Markets is about what comes next.

After writing the first book, I kept asking myself: "OK, right-brain trading helps me not lose money. But how do I actually gain an edge in a market where 95% of traders are fighting over the same scraps?"

The answer: AI + neuroscience + Indian markets.

Not the "AI will replace traders" hype. Not the "use GPT-4 to pick stocks" nonsense.

But something more practical: how to combine human intuition with machine intelligence to build a system that's better than either alone.

Brain Markets is that system.


What Is Brain Markets?

Brain Markets is a book that sits at the intersection of three fields:

  1. Neuroscience — How the human brain makes decisions under uncertainty
  2. Artificial Intelligence — How machines can augment human pattern recognition
  3. Indian Markets — NSE, BSE, FII flows, retail participation, algo trading regulation

Core thesis: The future of trading is not human vs AI. It's human + AI.

And Indian retail traders who master this collaboration first will have an unprecedented edge.


Why I Wrote Brain Markets

The Gap

After Right Brain Wins, I started getting emails:

"Your framework helped me stop losing. But how do I actually WIN consistently?"

Good question. Psychology prevents losses. But wins require edge.

The Realization

Traditional edges are disappearing:

  • Technical indicators = everyone uses them, no edge
  • Fundamental analysis = institutional investors have 100x better data
  • Tips = scams
  • algo trading = expensive, not for retail

But there's one edge most retail traders ignore:

AI + human intuition = superhuman decision-making.

The Book's Promise

By the end of Brain Markets, you'll have:

Skill Application
Local LLM sentiment analysis Analyze 100 news headlines in 2 seconds
Vector search for patterns Match current market to historical scenarios
Hybrid signal systems Combine AI + technical + intuition
Mobile AI workstation Run everything on Android/Termux
Backtesting AI models Validate before live trading
Risk management AI-augmented but human-decided

Chapter Breakdown

Part 1: The Neuroscience of Markets (Chapters 1-4)

Chapter 1: How Your Brain Trades (And Why It Fails)

  • Amygdala hijack in markets
  • Dopamine addiction to trading
  • Confirmation bias in stock picking
  • Loss aversion and its hidden costs

Chapter 2: The AI-Augmented Brain

  • What AI does well: pattern matching, speed, data processing
  • What humans do well: intuition, context, ethics
  • The collaboration model: AI proposes, human disposes
  • Case study: nse_ai_agent architecture

Chapter 3: Local LLMs for Trading

  • Why cloud AI is wrong for real-time trading
  • Ollama, Llama 3.2, Phi-3 on Android
  • Building sentiment analyzer on your phone
  • Privacy, latency, cost advantages

Chapter 4: Vector Search and Historical Memory

  • ChromaDB for news pattern matching
  • "This feels like 2020" → find what happened next
  • Building your own market memory bank

Part 2: Building AI Trading Systems (Chapters 5-8)

Chapter 5: Data Pipeline for NSE

  • Fetching live quotes, option chains, FII/DII
  • Web scraping with ethical considerations
  • NSE blocking and workarounds
  • Building resilient data fetchers

Chapter 6: Sentiment Analysis Engine

  • LLM prompt engineering for financial news
  • Fallback systems when AI fails
  • Scoring sentiment: 1-10 scale
  • Combining with technical indicators

Chapter 7: Backtesting AI Strategies

  • Why 99% backtest accuracy means nothing
  • Walk-forward analysis
  • Out-of-sample testing
  • Avoiding overfitting

Chapter 8: Risk Management with AI

  • AI-assisted position sizing
  • Dynamic stop loss based on volatility
  • Portfolio-level risk monitoring
  • The human override rule

Part 3: The Indian Market Context (Chapters 9-12)

Chapter 9: NSE Specifics for AI Trading

  • Lot sizes, expiry cycles, settlement
  • FII/DII flow patterns
  • PCR, OI, IV quirks in Indian markets
  • Regulatory constraints (SEBI, algo trading rules)

Chapter 10: Retail Participation Boom

  • Why 2024-2026 saw 3 crore new demat accounts
  • What this means for market efficiency
  • Opportunities for AI-augmented retail traders
  • Risks of crowd behavior

Chapter 11: The Future of Indian Algo Trading

  • SEBI's proposed regulations
  • How local AI tools fit in
  • Democratization vs institutionalization
  • What changes in next 5 years

Chapter 12: Case Studies from nse_ai_agent

  • 6-month live trading results
  • What worked: LLM + momentum combo
  • What didn't: LLM alone, far OTM options
  • Performance attribution

Part 4: The Human Element (Chapters 13-16)

Chapter 13: When AI Fails

  • Black swan events
  • News that LLMs can't interpret
  • When to override AI signals
  • Building antifragile systems

Chapter 14: Ethics of AI Trading

  • Market manipulation risks
  • Fair access to AI tools
  • Responsible AI development
  • The case for open-source trading tools

Chapter 15: Building Your AI Trading Workflow

  • Step-by-step setup on Termux/Android
  • Choosing the right LLM for your phone
  • Scheduling with cron
  • Monitoring and maintenance

Chapter 16: The Next 10 Years

  • Human-AI collaboration standard
  • What skills matter most
  • Why retail traders have advantage over institutions
  • The future of work in trading

What Makes Brain Markets Different

Feature Brain Markets Other AI Trading Books
Context Indian markets (NSE/BSE) US markets
Platform Termux/Android (free) Desktop/cloud (expensive)
AI approach Local LLMs (private, free) Cloud APIs (costly, slow)
Transparency Open-source code included Black-box strategies
Honesty Shows losses, limitations Only shows wins
Accessibility Written for retail traders Written for quants/developers
Philosophy Human + AI collaboration AI replaces humans

Free Chapter: Building Your First LLM Sentiment Analyzer

From Chapter 6: Sentiment Analysis Engine.


The Problem

You're a retail trader. You have:

  • ₹1 lakh capital
  • A phone
  • No Bloomberg terminal
  • No team of analysts

Institutional traders have:

  • 100+ analysts reading news 24/7
  • AI systems processing 10,000 articles/minute
  • Real-time sentiment feeds

Can you compete?

Yes. With local LLMs.


The Solution: 2-Hour Build

What you'll build:

  • A script that fetches 20 NSE news headlines
  • Sends them to a local LLM (Llama 3.2 3B)
  • Gets back: BULLISH/BEARISH/NEUTRAL + score 1-10
  • Combines with technical signals
  • Sends Telegram alert

Time: 2 hours. Cost: ₹0.


Step 1: Install Ollama

# On Termux
pkg install ollama -y
ollama serve &
ollama pull llama3.2:3b
Enter fullscreen mode Exit fullscreen mode

Step 2: Write the Analyzer

import requests
import json

class SentimentAnalyzer:
    def __init__(self, model="llama3.2:3b"):
        self.model = model
        self.url = "http://localhost:11434/api/generate"

    def analyze(self, headlines):
        prompt = f"""Analyze these Indian market news headlines for sentiment.

Headlines:
{chr(10).join(f"- {h}" for h in headlines)}

Respond with JSON:
{{"sentiment": "BULLISH/BEARISH/NEUTRAL", "score": 1-10, "reasoning": "2 sentences"}}"""

        response = requests.post(self.url, json={
            "model": self.model,
            "prompt": prompt,
            "stream": False,
            "options": {"temperature": 0.1, "num_predict": 150}
        }, timeout=30)

        result = json.loads(response.text)
        return json.loads(result['response'])
Enter fullscreen mode Exit fullscreen mode

Step 3: Test It

analyzer = SentimentAnalyzer()

headlines = [
    "Nifty opens higher on strong FII inflows",
    "RBI keeps repo rate unchanged",
    "IT stocks drag on global concerns",
    "Q2 results: TCS beats, Infosys misses"
]

result = analyzer.analyze(headlines)
print(f"Sentiment: {result['sentiment']} ({result['score']}/10)")
# Output: Sentiment: BULLISH (7/10)
Enter fullscreen mode Exit fullscreen mode

Step 4: Combine with Technicals

class HybridSignal:
    def __init__(self):
        self.sentiment_analyzer = SentimentAnalyzer()
        self.technical_weight = 0.7
        self.sentiment_weight = 0.3

    def generate_signal(self, technical_signal, headlines):
        sentiment = self.sentiment_analyzer.analyze(headlines)
        sentiment_score = sentiment['score'] / 10
        tech_score = technical_signal['confidence']

        final_score = (tech_score * self.technical_weight) + (sentiment_score * self.sentiment_weight)

        if final_score > 0.6:
            return "STRONG BUY"
        elif final_score > 0.3:
            return "BUY"
        elif final_score < -0.6:
            return "STRONG SELL"
        elif final_score < -0.3:
            return "SELL"
        else:
            return "HOLD"
Enter fullscreen mode Exit fullscreen mode

The Book's Impact

Who's Reading It:

Reader Type What They Get
Python developers Complete code, architecture, deployment
Traders AI augmentation without replacing judgment
Students Career path in AI + finance
Open-source contributors nse_ai_agent on GitHub
Curious minds Future of markets, human-AI collaboration

How to Get Brain Markets

Formats Available:

Format Price Where
eBook (PDF) ₹249 optiontradingwithai.in
eBook (EPUB) ₹249 optiontradingwithai.in
Paperback ₹449 Amazon KDP
Audiobook Coming soon

Bonus with Purchase:

  • ✅ Complete nse_ai_agent source code
  • ✅ 50+ Python scripts for NSE data
  • ✅ Ollama setup guide for Android
  • ✅ Private Telegram community
  • ✅ Monthly live Q&A sessions

The Mission: Democratize AI Trading Tools

Right Brain Wins costs ₹199. Brain Markets costs ₹249. Combined: less than most people spend on one bad tip from a Telegram group.

Why?

Because information asymmetry is the biggest barrier in Indian markets. If you can't afford a ₹50,000 Bloomberg terminal or ₹2,000/month for Kite Connect, you shouldn't be excluded from professional-grade tools.

nse_ai_agent is free.
These books are affordable.
The knowledge should be accessible.

That's not a marketing strategy. That's a mission.


Connect With Shakti Tiwari


Published on Dev.to | Tags: #brainmarkets #aitrading #nse #llm #termux #books #fintech


Author

Shakti Tiwari is an AI/quant trader and open-source developer from Chandigarh. He is the author of Right Brain Wins and Brain Markets, and maintains the nse_ai_agent project for Termux/Android. He writes about the intersection of AI, neuroscience, and Indian markets.

Top comments (0)