π Project Story: PortfolioIQ (HackNova 1.0)
π The Inspiration: Why PortfolioIQ?
In the volatile landscape of the NSE (National Stock Exchange), many retail investors fall into the "Equal-Weight Trap"βthe assumption that buying a bit of everything is the safest bet. During our research for the 2023β2024 period, we noticed that high-performance sectors like Pharma were often overshadowed by stagnant blue-chips.
Our team was inspired to build a tool that moves beyond "blind diversification" toward Data-Driven Conviction. We wanted to answer one critical question: Can we mathematically prove that a concentrated, risk-adjusted portfolio is superior to a passive index?
π οΈ How We Built It: The Technical Journey
We developed PortfolioIQ as a modular quantitative pipeline using Python (Pandas, Matplotlib, Seaborn). The project followed a strict four-task lifecycle:
- Data Engineering: We used
yfinanceto extract 2 years of OHLCV data. A core challenge was building a custom NSE-aware trading calendar to filter out non-trading weekdays and "Mohurat Trading" sessions. - Risk Modeling: We calculated the Annualised Return ($R_a$) and Annualised Volatility ($\sigma_a$) using the standard finance convention of 252 trading days: $$R_a = (1 + \mu_{daily})^{252} - 1$$ $$\sigma_a = \sigma_{daily} \times \sqrt{252}$$
- The Filter: We implemented a Sharpe Ratio ($S$) threshold using a $6.5\%$ Risk-Free Rate ($R_f$) as our hurdle: $$S = \frac{R_a - R_f}{\sigma_a}$$
- Portfolio Optimization: We utilized Correlation Heatmaps to identify "Sector Blocks" and rebalanced weights to favor assets with the highest return per unit of risk, creating our high-alpha Portfolio B.
π§ Challenges We Faced (And Overcame)
- The "Dirty Data" Problem: Raw data often contains stock splits or dividends that appear as massive "crashes." We solved this by implementing an 8-point Quality Audit (TC1-TC8) to flag and auto-correct price jumps greater than $50\%$.
- The Lagging Indicator Trap: We realized that Simple Moving Averages (SMA) are lagging. A "Golden Cross" often happens after the initial price surge. To solve this, we used SMAs only for Trend Confirmation rather than our primary entry trigger.
- Over-Concentration Risk: Initially, our model over-weighted IT stocks due to their high returns. We had to manually implement Sector Ceilings to ensure the portfolio remained diversified across Banking and Pharma.
π§ What We Learned
- Risk-Adjusted Value: We learned that a stock with $40\%$ return and $30\%$ volatility is often objectively worse than a stock with $25\%$ return and $10\%$ volatility.
- Correlation is King: Diversification only works if your assets don't move in lockstep. The IT sector's $0.69$ internal correlation taught us the necessity of de-coupling our trades.
- Clean Data > Complex Models: $80\%$ of financial analysis is data cleaning. Without our Task 1 audit, our final results would have been "garbage in, garbage out."
π― The Final Verdict
By the end of the competition, our Strategic Portfolio B achieved a Sharpe Ratio of 2.28, compared to the Nifty 50βs 0.72. This project proved that in finance, the math doesn't
Log in or sign up for Devpost to join the conversation.