Track Indian portfolio holdings, create snapshots, and generate weekly news digests.
When Joseph provides holding updates (quantity changes, new purchases, avg price changes) and wants to maintain the tracking file and generate a dated portfolio snapshot. Also when generating the weekly portfolio news digest (every Sunday via cron). This is the recurring maintenance workflow β distinct from quarterly analysis (see portfolio-analysis).
wiki/wealth/invest/portfolio/tracking/holdings.csv β master holdings (source, code, ticker, name, qty, cost_price, asset_class)wiki/wealth/invest/portfolio/tracking/YYYY-MM-DD-portfolio.md β dated snapshotswiki/wealth/invest/portfolio/news/YYYY-Wnn-weekly-news.md β weekly news digests (ISO week number)1. Parse Joseph's update: fund/stock name, new units, new avg price, total invested value
2. Locate the matching row in holdings.csv (match by name or scheme code)
3. Patch the row: update qty and cost_price columns
4. Verify the patch landed correctly (read back the affected lines)
holdings.csv format:source,code,nse_ticker,yahoo_symbol,name,qty,cost_price,asset_class
portal.amfiindia.com/spages/NAVAll.txt (semicolon-delimited)Batch-fetch all tickers in one script. Do not make serial curl calls (times out).
1. Read holdings.csv for all quantities and cost prices
2. Compute weighted-average buy price for stocks held in both ICICI and Zerodha (e.g., Coal India, GAIL, NMDC)
3. Value = qty Γ CMP (stocks/ETFs) or units Γ NAV (MFs)
4. P&L = value - (qty Γ cost_price)
5. Asset allocation: stocks %, ETFs % (with gold/silver/index sub-breakdown), MFs %
6. Write YYYY-MM-DD-portfolio.md following the template (see references/snapshot-template.md)
1. GET https://fc.yahoo.com (ignore error, just need cookie)
2. GET https://query2.finance.yahoo.com/v1/test/getcrumb (returns crumb string)
3. Use http.cookiejar + urllib.request.build_opener to maintain session
4. Fetch: https://query2.finance.yahoo.com/v8/finance/chart/{ticker}?range=1d&interval=1d&crumb={crumb}
period1/period2 timestamps instead of range=1dhttps://portal.amfiindia.com/spages/NAVAll.txtScheme Code;ISIN Payout;ISIN Reinvest;Scheme Name;Plan;Option;NAV;Dateawk for speed (not Python line-by-line)cost_price is average buy price, not current pricestock, etf, mfA weekly digest covering news for ALL holdings (stocks, ETFs, MFs). Complements the price snapshot β snapshot tracks values, digest tracks events.
Every Sunday morning via cron. Covers the MonβSat trading week.
1. Read holdings.csv for the full portfolio (stocks, ETFs, MFs).
2. Fetch price data via yfinance for all stock/ETF tickers (5-day period for WoW change).
3. Fetch news β yfinance .news attribute returns empty for Indian (.NS) tickers. Use web_search as fallback. Focus searches on significant movers (>2% WoW change) to avoid noise. Search queries: "{stock name} India stock news September 2026".
4. Get market context β Nifty 50, crude oil, gold, silver, Nasdaq 100 levels and WoW change via yfinance.
5. Write digest to wiki/wealth/invest/portfolio/news/YYYY-Wnn-weekly-news.md (date = ISO week number of today).
.news is empty for Indian tickers β always use web_search fallback. Don't assume the API will work.wiki/wealth/invest/portfolio/news/ β one file per weekYYYY-Wnn-weekly-news.md (ISO week number of run date)See references/news-digest-template.md for the markdown structure.
references/yahoo-finance-api.md β crumb auth, endpoints, rate limitsreferences/amfi-nav.md β NAV file format, scheme code lookupreferences/snapshot-template.md β portfolio snapshot markdown templatereferences/news-digest-template.md β weekly news digest markdown template