DEV Community

shakti tiwari
shakti tiwari

Posted on

The ₹0 AI Stack Blueprint: How Any Indian Company Can Build Production AI for Free

The ₹0 AI Stack Blueprint: How Any Indian Company Can Build Production AI for Free

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


I run a production AI system for my trading business.

Monthly cost: ₹0.

No cloud GPUs. No API subscriptions. No ₹2 lakh servers. No monthly bills.

Just a ₹15,000 Android phone, Python scripts, and open-source models.

And it's not a toy. It's been running for 6 months. It's executed 180+ trades. It's made ₹96,000 profit.

If I can do this on a phone, any Indian company can build production AI on a ₹30,000 laptop.

Here's the exact blueprint.

The Stack: ₹0, All Open-Source

Component Tool Cost Purpose
Hardware ₹15,000 phone / ₹30,000 laptop One-time Runs AI inference
OS Termux (Android) / Linux (laptop) ₹0 Development environment
Language Python 3.11 ₹0 Programming
ML framework XGBoost, scikit-learn, pandas ₹0 Model training & inference
LLM (optional) Llama 3 8B / Mistral 7B ₹0 Natural language processing
Database SQLite ₹0 Trade logging, memory
Alerts Telegram Bot API ₹0 Notifications
Data source NSE API, yfinance ₹0 Market data
Total ₹0/month

What I didn't use:

  • ❌ Cloud GPUs (AWS, GCP, Azure)
  • ❌ Paid APIs (OpenAI, Anthropic)
  • ❌ ML platforms (SageMaker, Vertex AI)
  • ❌ Trading platforms (Sensibull, TradingView)
  • ❌ Databases (PostgreSQL, MongoDB, Pinecone)

What I built:

  • ✅ Custom XGBoost model for Nifty options
  • ✅ Telegram alert bot
  • ✅ Option chain analyzer
  • ✅ Walk-forward backtesting engine
  • ✅ Trade logger with SQLite

What This System Actually Does

1. Data Collection (Every 5 Minutes During Market Hours)

import requests
import pandas as pd

def fetch_option_chain(symbol="NIFTY"):
    url = f"https://www.nseindia.com/api/option-chain-indices?symbol={symbol}"
    headers = {"User-Agent": "Mozilla/5.0"}

    response = requests.get(url, headers=headers)
    data = response.json()

    # Extract option chain
    df = pd.DataFrame(data['records']['data'])
    return df

# Run every 5 minutes
df = fetch_option_chain()
df.to_csv(f"data/{datetime.now().strftime('%Y%m%d_%H%M')}.csv")
Enter fullscreen mode Exit fullscreen mode

Output: Option chain CSV with OI, PCR, max pain, ATM straddle.

2. Feature Engineering (After Data Collection)

def engineer_features(df):
    # PCR trend over 3 days
    df['pcr_trend'] = df['pcr'].diff().rolling(3).mean()

    # OI change normalized by volume
    df['oi_change_norm'] = df['oi_change'] / df['volume']

    # Max pain divergence
    df['max_pain_div'] = (df['spot'] - df['max_pain']) / df['max_pain']

    # RSI
    df['rsi'] = calculate_rsi(df['close'])

    # MACD
    df['macd'], df['signal'] = calculate_macd(df['close'])

    return df
Enter fullscreen mode Exit fullscreen mode

Output: 52 features per trade.

3. Signal Generation (After Feature Engineering)

import xgboost as xgb

model = xgb.XGBClassifier()
model.load_model('models/xgboost_nifty.json')

features = ['pcr', 'oi_change', 'max_pain_div', 'rsi', 'macd', 'volume_sma']
X = df[features].iloc[-1:]

prediction = model.predict(X)[0]
confidence = model.predict_proba(X)[0].max()

if prediction == 1 and confidence > 0.65:
    signal = "BUY CE"
elif prediction == 0 and confidence > 0.65:
    signal = "BUY PE"
else:
    signal = "NO TRADE"
Enter fullscreen mode Exit fullscreen mode

Output: BUY CE / BUY PE / NO TRADE with confidence score.

4. Alert Dispatch (Real-Time)

def send_telegram_alert(signal, confidence, data):
    message = f"""
🚨 NIFTY SIGNAL

Signal: {signal}
Confidence: {confidence:.1%}

PCR: {data['pcr']:.2f}
OI Change: {data['oi_change']:,.0f}
Max Pain: {data['max_pain']:,.0f}
RSI: {data['rsi']:.1f}

Time: {datetime.now().strftime('%H:%M')}
"""

    url = f"https://api.telegram.org/bot{TOKEN}/sendMessage"
    payload = {"chat_id": CHAT_ID, "text": message}
    requests.post(url, json=payload)
Enter fullscreen mode Exit fullscreen mode

Output: Telegram notification on my phone.

5. Trade Logging (After Execution)

def log_trade(trade):
    conn = sqlite3.connect('trades.db')
    cursor = conn.cursor()

    cursor.execute("""
        INSERT INTO trades (date, signal, entry, exit, pnl, confidence)
        VALUES (?, ?, ?, ?, ?, ?)
    """, (
        trade['date'],
        trade['signal'],
        trade['entry'],
        trade['exit'],
        trade['pnl'],
        trade['confidence']
    ))

    conn.commit()
    conn.close()
Enter fullscreen mode Exit fullscreen mode

Output: SQLite database with 180 trades.

Performance: 6 Months, 180 Trades, ₹96,000 Profit

Metric Value
Total trades 180
Win rate 62%
Profit factor 1.8
Max drawdown -12%
Net P&L +₹96,000
Monthly cost ₹0
Hardware cost ₹18,000 (one-time)

vs Paid alternatives:

  • Sensibull Pro: ₹999/month = ₹5,994/6 months
  • TradingView Premium: ₹1,500/month = ₹9,000/6 months
  • Total paid: ₹14,994
  • My cost: ₹0 + ₹3,000 (data plans)

Savings: ₹11,994 in 6 months = ₹23,988/year

What AI Companies Don't Want You to Know

1. You Don't Need GPT-4 for Most Tasks

GPT-4 is impressive for:

  • Creative writing
  • Complex reasoning
  • Multi-lingual translation

But for structured data tasks (option chain analysis, signal generation), XGBoost is:

  • Faster: 0.2s vs 5-10s
  • Cheaper: ₹0 vs ₹5-15 per 1M tokens
  • More accurate: 62% vs 55% (without fine-tuning)
  • Deterministic: Same input = same output (no hallucination)

Use the right tool for the job.

2. Fine-Tuned Small Models Beat Generic Large Models

My XGBoost model is trained on my trading data. It knows my patterns.

GPT-4 has seen everything, but it hasn't seen my decisions.

For specific tasks, personalized small models > generic large models.

3. Local Inference is Faster Than API Calls

API call latency: 1-5 seconds (network + processing).
Local inference latency: 0.1-1 seconds (no network).

For real-time trading, 1-5 seconds is the difference between profit and loss.

4. Open-Source Tools Are Good Enough

XGBoost, scikit-learn, pandas, SQLite — these are production-grade tools used by:

  • Google (internal ML)
  • Netflix (recommendation systems)
  • Uber (surge pricing)
  • Airbnb (pricing optimization)

You don't need fancy frameworks. You need fundamentals.

The Blueprint: Step-by-Step

Week 1: Setup Environment

Day 1: Install Termux (Android) or Linux (Laptop)

# Android: Install Termux from F-Droid
# Laptop: Ubuntu/Debian pre-installed

# Update packages
pkg update && pkg upgrade

# Install Python
pkg install python python-dev

# Install pip
pkg install pip
Enter fullscreen mode Exit fullscreen mode

Day 2: Install ML Libraries

pip install pandas numpy scikit-learn xgboost
pip install requests python-dotenv
Enter fullscreen mode Exit fullscreen mode

Day 3: Setup Database

pip install sqlite3
Enter fullscreen mode Exit fullscreen mode

Day 4: Setup Telegram Bot

  1. Message @botfather on Telegram
  2. Create new bot: /newbot
  3. Get token: 123456:ABC-DEF...
  4. Save token in .env

Day 5: Test Everything

import pandas as pd
import xgboost as xgb
import sqlite3

print("Libraries installed successfully")
Enter fullscreen mode Exit fullscreen mode

Week 2: Build Data Pipeline

Day 1: Fetch NSE Data

def fetch_option_chain(symbol="NIFTY"):
    url = f"https://www.nseindia.com/api/option-chain-indices?symbol={symbol}"
    headers = {"User-Agent": "Mozilla/5.0"}
    response = requests.get(url, headers=headers)
    return response.json()
Enter fullscreen mode Exit fullscreen mode

Day 2: Store in SQLite

def store_data(df):
    conn = sqlite3.connect('trades.db')
    df.to_sql('option_chain', conn, if_exists='append')
    conn.close()
Enter fullscreen mode Exit fullscreen mode

Day 3: Schedule with Cron

# Every 5 minutes during market hours
*/5 9-15 * * 1-5 python /data/data/com.termux/files/home/nse_ai_agent/scripts/fetch_data.py
Enter fullscreen mode Exit fullscreen mode

Day 4: Test Pipeline

Run script manually, verify data in SQLite.

Day 5: Automate

Set up cron job, verify it runs automatically.

Week 3: Build Model

Day 1: Prepare Training Data

# Load historical trades
df = pd.read_csv('trades.csv')

# Engineer features
df = engineer_features(df)

# Split train/test
train = df[df['date'] < '2026-04-01']
test = df[df['date'] >= '2026-04-01']
Enter fullscreen mode Exit fullscreen mode

Day 2: Train Model

model = xgb.XGBClassifier(n_estimators=100, max_depth=3)
model.fit(train[features], train['target'])
Enter fullscreen mode Exit fullscreen mode

Day 3: Validate

accuracy = model.score(test[features], test['target'])
print(f"Test accuracy: {accuracy:.1%}")
Enter fullscreen mode Exit fullscreen mode

Day 4: Analyze Feature Importance

importance = model.feature_importances_
for feat, imp in sorted(zip(features, importance), reverse=True):
    print(f"{feat}: {imp:.3f}")
Enter fullscreen mode Exit fullscreen mode

Day 5: Save Model

model.save_model('models/xgboost_nifty.json')
Enter fullscreen mode Exit fullscreen mode

Week 4: Deploy + Test

Day 1: Build Alert System

def send_telegram_alert(signal, confidence):
    message = f"🚨 NIFTY SIGNAL: {signal} ({confidence:.1%})"
    requests.post(f"https://api.telegram.org/bot{TOKEN}/sendMessage", json={
        "chat_id": CHAT_ID,
        "text": message
    })
Enter fullscreen mode Exit fullscreen mode

Day 2: Test Live

Run model on current data, send alert, verify Telegram.

Day 3: Paper Trade

Run for 1 week without real money. Track accuracy.

Day 4: Go Live

Start with small position size (1% capital).

Day 5: Monitor

Track results, retrain model weekly.

Cost Breakdown: Local AI vs Cloud AI

Scenario: 10-Person Trading Firm

Cloud AI:

  • 10 Sensibull Pro accounts: ₹9,990/month
  • 5 TradingView Premium: ₹7,500/month
  • Bloomberg terminal: ₹50,000/month
  • Total: ₹67,490/month = ₹8.09 lakh/year

Local AI:

  • 4 Android phones: ₹72,000 (one-time)
  • Custom software development: ₹50,000 (one-time)
  • Electricity + data: ₹1,000/month
  • Total: ₹1.22 lakh one-time + ₹12,000/year

Savings: ₹6.97 lakh/year = 86%

Break-even: 1.7 months

Scenario: 50-Person Company (General Business)

Cloud AI:

  • ChatGPT Enterprise: ₹60,000/month
  • Custom AI development: ₹15 lakh/year
  • Total: ₹22.8 lakh/year

Local AI:

  • Server hardware: ₹5 lakh (one-time)
  • ML engineer: ₹12 lakh/year
  • Total: ₹17 lakh/year

Savings: ₹5.8 lakh/year = 25%

Break-even: 4.3 months

Common Objections (and Responses)

"We don't have technical talent"

Response: Hire 1 ML engineer (₹10-15 lakh/year) vs paying ₹30 lakh/year for SaaS AI. Break-even in 6 months.

Alternative: Use no-code tools:

  • Hugging Face AutoTrain
  • FastAI (7-line model training)
  • Gradio (UI in 10 lines)

"Local AI is less accurate"

Response: For specific tasks, fine-tuned local models outperform generic cloud models. My XGBoost model is 62% accurate on Nifty options. GPT-4 without fine-tuning is ~55% accurate on the same task.

"We need to scale"

Response: Start local. Add hardware when needed. Unlike cloud AI, you own infrastructure. No per-query costs.

"What about maintenance?"

Response: Models need retraining. But retraining a local model is cheaper and faster than waiting for a vendor to update their SaaS.

"Is it secure?"

Response: More secure than cloud. Your data never leaves your network. You control access.

The "AI Proposes, You Dispose" Philosophy

This stack embodies my core belief:

AI proposes: The model analyzes data, identifies patterns, suggests actions.

You dispose: You approve, modify, or reject based on context.

This matters because:

  1. Models make mistakes — especially with ambiguous data
  2. Context matters — the model doesn't know your full situation
  3. Ethics matter — some decisions need human judgment
  4. Trust matters — you don't want a black box making critical decisions

Real-World Examples

Example 1: Retail Store Inventory Management

Problem: Stock outs and overstocking cost ₹2 lakh/month.

Old solution: ERP system + manual forecasting = 70% accuracy

New solution: Local XGBoost model on sales data = 85% accuracy

Cost:

  • Old: ₹50,000/month (ERP license)
  • New: ₹0 (Python + SQLite)

Savings: ₹6 lakh/year + ₹2 lakh reduced stockouts = ₹8 lakh/year

Example 2: Manufacturing Quality Control

Problem: 5% defect rate, manual inspection.

Old solution: Hire 2 inspectors = ₹8 lakh/year

New solution: Local vision model on CCTV footage = 95% defect detection

Cost:

  • Old: ₹8 lakh/year
  • New: ₹2 lakh (camera + laptop, one-time)

Savings: ₹6 lakh/year

Example 3: Customer Support

Problem: 500 queries/day, 2 support staff = ₹12 lakh/year

Old solution: 2 support staff = ₹12 lakh/year

New solution: Local LLM handles 80% queries, human handles 20% = ₹3 lakh/year

Cost:

  • Old: ₹12 lakh/year
  • New: ₹3 lakh/year (1 support staff)

Savings: ₹9 lakh/year

The Future: AI as a Utility

In 10 years, AI will be like electricity:

  • Ubiquitous — every device has AI capability
  • Cheap — marginal cost approaches zero
  • Commoditized — no competitive advantage in having AI
  • Expected — customers assume you use AI

The companies that win will be those that:

  1. Use AI efficiently — not wastefully
  2. Combine AI with human judgment — not replace humans
  3. Build proprietary data moats — not rely on generic models
  4. Move fast — not wait for perfect solutions

Action Items for Companies

This Week

  1. Audit your AI spend — how much are you paying for SaaS tools?
  2. Identify one use case — customer support, document processing, predictive maintenance
  3. Research open-source alternatives — Llama 3, Mistral, XGBoost

This Month

  1. Run a pilot — fine-tune an open-source model on your data
  2. Measure ROI — compare cost and accuracy vs current solution
  3. Build internal capability — train one team member on local AI

This Quarter

  1. Scale what works — expand pilot to other departments
  2. Cut SaaS AI subscriptions — replace with local alternatives
  3. Invest in talent — hire one ML engineer vs paying 10 SaaS subscriptions

The Bottom Line

You don't need ₹2 crore AI infrastructure. You need:

  • 1 smart engineer who understands your business
  • 1 open-source model fine-tuned on your data
  • 1 laptop to run it on
  • 1 week to build it

Total cost: ₹10 lakh vs ₹2 crore.

AI proposes, you dispose. Don't let vendors tell you otherwise.


P.S. I write about building AI systems on a ₹15,000 phone. No cloud. No subscriptions. Just code. Follow me for more.

Tags: localai, tutorial, costoptimization, opensource, indianbuilders, business, 2026

Meta: Complete blueprint for building production AI systems for free using open-source tools. Covers hardware, software, deployment, and real-world examples for Indian companies. Cost comparison: local AI vs cloud AI. 6-month trading AI results: 62% win rate, ₹96,000 profit, ₹0 monthly cost.

Top comments (0)