J
Documentation

Documentation

Complete reference for the Jhaveri Intelligence Platform

Platform Overview

The Jhaveri Intelligence Platform is a fund manager's decision support system that combines technical analysis alerts from TradingView with model portfolio management. It processes webhook signals, tracks FM actions, and provides portfolio analytics — all from a single dashboard.

Alert System

Receives TradingView webhooks, presents to FM for action, tracks performance of approved/denied signals.

Model Portfolios

Create strategies, record buy/sell transactions, track NAV, benchmark against NIFTY, compute XIRR/CAGR.

Data Sources
Data TypeSourceFrequency
Live Stock Prices (CMP)Yahoo Finance APIv8 chart endpointReal-time (on page load)
EOD Stock PricesYahoo Financevia yfinance (Python)Daily at 3:30 PM IST
Index Data (NIFTY, BANKNIFTY)Yahoo Finance^NSEI, ^NSEBANK symbolsDaily at 3:30 PM IST
TradingView AlertsWebhookTradingView POST to /webhook/tradingviewReal-time
Portfolio TransactionsManual entry by Fund ManagerOn-demand
LIQUIDCASE maps to LIQUIDBEES.NS on Yahoo Finance. This is the Nippon India ETF Liquid BeES — India's most liquid overnight fund ETF. CMP displayed is the real-time market price from Yahoo, not a synthetic value.
Ticker to Yahoo Finance Symbol Mappings

Portfolio tickers are mapped to Yahoo Finance symbols for price fetching. Default mapping: TICKERTICKER.NS (NSE). Special mappings below:

Portfolio TickerYahoo SymbolDescription
LIQUIDCASELIQUIDBEES.NSNippon India ETF Liquid BeES (overnight fund)
CPSEETFCPSEETF.NSCPSE ETF
METALETFMETALIETF.NSICICI Prudential Metal ETF
SENSEXETFSENSEXETF.NSSensex ETF
All othersTICKER.NSNSE equity default
Portfolio Calculations

Cost Basis (Weighted Average)

When buying more of an existing holding, cost is averaged. Standard for Indian equity markets.

new_avg_cost = (old_total_cost + new_buy_value) / new_total_qty
total_cost = quantity × avg_cost

Unrealized P&L

unrealized_pnl = (CMP - avg_cost) × quantity
unrealized_pnl_pct = ((CMP / avg_cost) - 1) × 100

Realized P&L (on SELL)

realized_pnl = (sell_price - avg_cost) × sell_qty
realized_pnl_pct = ((sell_price / avg_cost) - 1) × 100

Total Return

total_return = (current_value - total_invested + realized_pnl) / total_invested × 100

XIRR (Extended Internal Rate of Return)

Annualized return accounting for timing of cash flows. Computed using Newton-Raphson method.

Cash flows:
  BUY transactions = negative (money out)
  SELL transactions = positive (money in)
  Current portfolio value = positive (on today's date)

Solve for r: ∑ CF_i / (1 + r)^((d_i - d_0) / 365) = 0

CAGR (Compound Annual Growth Rate)

end_value = current_value + cumulative_realized_pnl
CAGR = ((end_value / start_cost) ^ (1 / years) - 1) × 100

Max Drawdown

Largest peak-to-trough decline in portfolio value from the NAV time series.

For each point in NAV series:
  running_max = max(running_max, nav_value)
  drawdown = (nav_value - running_max) / running_max × 100
max_drawdown = min(all drawdowns)

Alpha (vs Benchmark)

alpha = portfolio_return_pct - benchmark_return_pct

benchmark_return = (nifty_latest - nifty_at_first_nav) / nifty_at_first_nav × 100

Portfolio Weight

weight_pct = (holding_current_value / total_portfolio_value) × 100
NAV (Net Asset Value) Methodology

NAV is computed daily for each portfolio using end-of-day closing prices. The NAV time series powers the performance chart.

Daily NAV Computation

For each holding in portfolio:
  value = quantity × EOD_close_price (from IndexPrice table)
  If no price found, falls back to avg_cost

total_value = sum of all holding values
total_cost = sum of (quantity × avg_cost) for all holdings
unrealized_pnl = total_value - total_cost
realized_pnl_cumulative = sum of realized P&L from all SELL transactions up to date

Benchmark Normalization

The NIFTY benchmark is normalized to make it comparable on the same chart as portfolio returns.

benchmark_value = portfolio_cost_at_start × (nifty_today / nifty_at_start)

This shows: "What if the same money was invested in NIFTY?"

Chart Mode: Percentage Returns

The performance chart displays percentage returns from the first data point (period start). All three lines — Portfolio, Cost Basis, and NIFTY — start at 0% for easy comparison. Hover shows both % return and absolute values.

Automated Schedule
Time (IST)TaskDescription
3:30 PMEOD Price FetchFetches closing prices for all tracked indices and stocks
3:35 PMNAV ComputationComputes daily NAV for all active portfolios using EOD prices
Real-timeWebhook ProcessingTradingView alerts processed immediately on receipt
On-demandLive Price FetchHoldings page fetches live CMP from Yahoo Finance on each load
Alert System

TradingView sends alerts via webhook. The FM reviews each alert and takes action (Approve/Deny). Approved alerts can have trade parameters, chart analysis, and FM notes attached.

Alert Fields

  • Ticker — NSE symbol from TradingView
  • Timeframe — Chart interval (1D, 4H, 1H, etc.)
  • Signal Direction — BULLISH / BEARISH / NEUTRAL
  • OHLCV — Open, High, Low, Close, Volume at alert time
  • Alert Data — Custom message from TradingView strategy

FM Action Fields

  • Action Call — BUY / SELL / RATIO (for pair trades)
  • Priority — IMMEDIATELY / WITHIN A WEEK / WITHIN A MONTH
  • Entry Range — Low and high entry price targets
  • Stop Loss & Target — Risk management levels
  • Chart Analysis — AI-generated 8-point technical analysis
  • FM Notes — Free-form fund manager commentary

Alert Performance Tracking

After approval, the platform tracks price movement from the alert price to current market price, calculating P&L for each approved signal. This helps evaluate signal quality over time.

Microbaskets

Microbaskets are curated stock baskets with weighted constituents. They can be managed standalone or added as portfolio instruments for NAV tracking.

CSV Upload Format

Baskets are created via CSV upload with the following columns:

basket_name, ticker, company_name, weight(%), price, quantity

Portfolio size is auto-computed from price × quantity for each constituent. Buy price is tracked per constituent for cost basis calculations.

Basket as Portfolio Instrument

Baskets can be added to portfolios using the MB_ prefix (e.g., MB_MOMENTUM) with instrument type BASKET during portfolio creation. The basket's NAV is computed from its constituent prices and used as the instrument price in the portfolio.

Unit Computation

When portfolio_size is set:
  units = weight% × portfolio_size / price

NAV is computed in background from constituent EOD prices.
Recommendation Engine

The recommendation engine analyses 15 NSE sector indices against a benchmark (NIFTY 50 by default) to identify sectors with relative outperformance or underperformance.

Sector Indices & Periods

Each sector index is evaluated across 5 time periods with a configurable outperformance threshold:

Periods: 1W, 1M, 3M, 6M, 12M
Method: ratio = sector_return / benchmark_return
Threshold: configurable (e.g., ratio > 1.05 = outperforming)

Top Stocks & ETF Mapping

  • Top stocks per sector shown with market cap, P/E ratio, and 52-week range
  • ETF mapping for 7 sectors — BANKBEES, ITBEES, CPSE, JUNIORBEES, GOLDBEES, NIFTYBEES, METALIETF
  • Batch-optimized — approximately 15 DB queries per generate request
Navigation

The sidebar navigation includes live badge counts that update automatically, providing at-a-glance awareness of pending items.

Badge Counts

  • Trade Center — red badge showing the count of pending (unreviewed) alerts
  • Actionables — red badge showing the count of triggered stop-loss or target-price alerts

Auto-Refresh

Badge counts are fetched via SWR hooks and automatically refresh every 30 seconds, so the FM always sees up-to-date pending item counts without manual page reloads.

USDINR Returns

Currency pair returns are inverted to reflect the Indian investor's perspective on rupee strength or weakness.

Inversion Logic

USDINR rising (82 → 87): displayed as NEGATIVE (INR weakening)
USDINR falling (87 → 82): displayed as POSITIVE (INR strengthening)

This inversion is applied to both absolute and ratio returns across all time periods. A rising USDINR rate means each dollar costs more rupees, which is unfavourable for Indian investors — hence shown in red.

Technical Architecture
LayerTechnology
FrontendNext.js 16 + TypeScript + Tailwind CSS + shadcn/ui
Backend APIPython FastAPI (single server on port 8000)
DatabasePostgreSQL (RDS Mumbai) / SQLite (local dev)
ORMSQLAlchemy
ChartsRecharts (area, line, pie)
SchedulingAPScheduler (CronTrigger for daily tasks)
DeploymentAWS EC2 Mumbai (Docker via GitHub Actions CI/CD)
Market Datansetools (live 135+ indices) + yfinance (historical + stocks) + NSE API (sector constituents)

Jhaveri Intelligence Platform v3 — Built for Jhaveri Securities & Ventures