DEV Community

Cover image for How I Built a Portfolio Risk & Return Tracker with EODHD
Kevin Meneses González
Kevin Meneses González

Posted on • Originally published at Medium

How I Built a Portfolio Risk & Return Tracker with EODHD

Most retail investors track their portfolio in a spreadsheet.

Some upgrade to a free app that shows total value and daily change. That's it.

Neither tells you the numbers that actually matter: your annualized volatility, your Sharpe ratio, your beta against the market, your maximum drawdown, how correlated your positions really are with each other.

Institutional investors have had this for decades. Retail investors get a pie chart.

If you're:

  • managing your own portfolio across multiple brokers,
  • building a fintech side project,
  • or just tired of guessing how risky your holdings actually are,

this matters.

The spreadsheet problem

Excel is where most portfolios go to die.

You start with a clean sheet. One column per position, one row per transaction. It works — for about three months.

Then you add a new broker account. Then you start tracking dividends separately. Then a formula breaks because you inserted a row in the wrong place, and you don't notice until your total is off by 4%.

Spreadsheets don't calculate volatility, beta, or drawdown by default. You'd have to build those formulas yourself, pull historical prices manually, and keep them updated — forever, by hand.

Most people don't. So they end up managing a portfolio without knowing its actual risk profile.

The paid-tool problem

The other option is a paid portfolio tracker or a Bloomberg-style terminal.

These solve the calculation problem. They don't solve the trust problem.

  • Your position sizes, tickers, and entry prices sit on a third-party server.
  • You pay a monthly fee for metrics that are, mathematically, not complicated.
  • Many of these tools are optimized to upsell you into their brokerage or premium tier, not to give you a neutral view of your risk.

Sharpe ratio, beta, drawdown, correlation — these aren't proprietary black-box models. They're well-defined formulas. Paying $30/month to have someone else run them on your data, on their servers, is a trade-off a lot of people make without questioning it.

The real problem isn't a lack of financial data. It's a lack of a tool that computes real risk metrics, locally, without asking you to hand your portfolio to a third party.

Vault: a portfolio tracker that runs in your browser

I built Vault, an open source portfolio tracker with React 19 and Vite that uses the EODHD API to pull real market data and calculate six metrics that any serious investor should be tracking:

  • Returns — portfolio performance vs. S&P 500, indexed and per-position
  • Diversification — position weights and concentration (Herfindahl-Hirschman Index)
  • Risk — annualized volatility, Sharpe ratio, beta vs. market, 95% daily VaR
  • Drawdown — underwater curve and maximum historical drawdown
  • Correlations — Pearson correlation matrix between your holdings
  • Sector exposure — GICS sector breakdown from EODHD fundamentals

No backend. No account. No server storing your positions.

Everything runs in the browser, and your portfolio is saved in localStorage — on your machine, not on mine.

A quick note on EODHD

I've used EODHD across several projects before this one, mainly because of three things:

  1. One API key covers historical prices, fundamentals, and search — no juggling three different providers
  2. The free tier is generous enough to actually build and test a real project on it
  3. Response format is consistent across endpoints, which cuts down on glue code

If you want to follow along or fork Vault, you'll need a key — get one free here.

How the calculations actually work

All the math lives in a single file: src/utils/finance.js. No external statistics libraries — every formula is implemented from scratch.

Time-weighted returns

Each day is weighted by the previous day's closing value. This matters more than it sounds: without it, adding a new position mid-month distorts your daily portfolio return.

Volatility and Sharpe ratio

Standard deviation of daily returns, annualized with √252, then converted to a Sharpe ratio against a configurable risk-free rate.

Here's the core of it, simplified to Python for clarity:

import numpy as np

def annualized_volatility(daily_returns):
    return np.std(daily_returns) * np.sqrt(252)

def sharpe_ratio(daily_returns, risk_free_rate=0.02):
    excess_returns = np.array(daily_returns) - (risk_free_rate / 252)
    return (np.mean(excess_returns) / np.std(daily_returns)) * np.sqrt(252)
Enter fullscreen mode Exit fullscreen mode

Beta

Covariance of portfolio returns against the S&P 500 (GSPC.INDX on EODHD), divided by the benchmark's variance.

Drawdown

Percentage drop from the running peak of a growth-indexed curve (base 100). This is the number that tells you what it would have actually felt like to hold this portfolio through its worst stretch.

Correlation matrix

Pairwise Pearson coefficient between assets, aligned by date. This is the metric most retail portfolios get wrong without knowing it — five stocks can feel diversified and still move together 90% of the time.

Concentration (HHI)

Herfindahl-Hirschman Index applied to position weights. One number that tells you how concentrated you actually are, beyond "I have 12 positions so I'm diversified."

From here, the same building blocks extend into:

  • automated risk alerts
  • portfolio rebalancing scripts
  • backtesting engines

What it looks like in practice

You add a position, EODHD's Search + EOD endpoints autocomplete the ticker and the closing price on your purchase date.

From there, Vault renders your returns curve against the S&P 500, your correlation heatmap, and your sector exposure pulled straight from fundamentals data.

No manual formula-building. No re-entering prices when a position updates.

Key takeaways

  • Portfolio risk metrics (Sharpe, beta, drawdown, correlation) aren't proprietary — they're standard formulas most tools just gatekeep behind a paywall
  • Running them client-side means your positions never leave your browser
  • EODHD's Search, EOD, and Fundamentals endpoints cover everything needed to build this without stitching together multiple data providers

Try it yourself

git clone https://github.com/Kevinelectronics/portafoliotracker.git
cd portafoliotracker
npm install
Enter fullscreen mode Exit fullscreen mode

Add your EODHD key to .env, run npm run dev, and add your first position.

Get your free EODHD API key
Vault runs entirely on EODHD's Search, EOD, and Fundamentals endpoints — no backend, no paywall on the metrics.
Get your EODHD API key

If you're a software or API company looking to explain your product through high-quality educational content — not marketing fluff — feel free to connect with me on LinkedIn.

Need technical content like this for your product?
kevinmeneses.com


Looking for technical content for your company? I can help — LinkedIn · kevinmenesesgonzalez@gmail.com

Top comments (0)