Skip to content

Banking, insurance and financeBI, AI and ML for the business

Portfolio risk and correlations

A diversified portfolio stays diversified only while correlations hold. Muvia reads fund prices minute by minute, a Python function works out volatility and drawdown, Analysis aligns the spikes, and the committee sees the correlation flip sign before the monthly statement does.

Illustrative scenario: it describes a typical case, not a customer project.

Diversification breaks exactly when you need it.

Equities and bonds usually offset each other, and the portfolio is built on that. In a crisis the correlation can flip sign within days, and a monthly statement shows it once the loss is already made.

Seeing it in time takes frequent prices, volatility and drawdown worked out the same way every time, and a way to compare spikes with each other. The committee needs the numbers with an explanation, not a spreadsheet to decode.

Who it's for
Risk managers, portfolio managers, the investment committee and quantitative analysts.
Fund prices from the market-data provider's REST API, positions from the securities system on SQL Server and risk limits in Excel flow into Muvia, where the team's function works out volatility and drawdown; out come a fund dashboard, the Analysis of the spikes, an alarm on the limits and the notebook for the committee.

In Muvia, step by step

Real product screens, recorded on a project with sample data.

1 of 5

The video · A diversified portfolio stays diversified only while correlations hold. Muvia reads fund prices minute by minute, a Python function works out volatility and drawdown, Analysis aligns the spikes, and the committee sees the correlation flip sign before the monthly statement does.

What you get

One definition of risk
Volatility and drawdown always come from the same function: committee, portfolio managers and risk managers read the same numbers.
A spike compared with the others
Overlaid episodes show whether today's looks like the earlier ones or not, in shape and in length.
A shifting correlation shows
The dashboard shows when equities and bonds stop offsetting each other, while it happens.
A note for the committee, not a spreadsheet
Numbers, charts and the proposal arrive in one document, rebuilt on fresh data.

For the technical team

How it is built in Muvia

  1. 1

    Connect prices and positions

    Prices arrive from a REST API on a schedule, positions from the securities system with an incremental copy. Every source becomes a table you can query.

  2. 2

    Work out risk in Python

    A function works out each fund's bands, annualised volatility over a rolling window and drawdown from the peak. A flow runs it on a schedule and writes the results to a managed table.

  3. 3

    Align the spikes in Analysis

    The Layers view overlays high-volatility episodes on the moment they start: today's spike is compared with past ones by shape and length. The team's notes stay on the chart.

  4. 4

    Follow the correlation

    A dashboard puts hourly candles, fund volatility and the rolling correlation between equities and bonds side by side; an alarm opens when volatility breaks its limit.

  5. 5

    Write the note for the committee

    A notebook with text, numbers and charts tells what changed and the proposed reallocation, and becomes a PDF for the committee.

Python function

import numpy as np

MINUTES_PER_YEAR = 252 * 510  # trading days times trading minutes

def transform(inputs, params, ctx):
    df = inputs["rows"].sort_values(["fund", "minute"])
    w = params["window_minutes"]
    price = df.groupby("fund")["price"]
    df["return"] = price.transform(lambda p: np.log(p).diff())
    df["annual_volatility"] = df.groupby("fund")["return"].transform(
        lambda r: r.rolling(w).std() * np.sqrt(MINUTES_PER_YEAR))
    df["drawdown"] = df["price"] / price.cummax() - 1
    mean = price.transform(lambda p: p.rolling(w).mean())
    std = price.transform(lambda p: p.rolling(w).std())
    df["upper_band"], df["lower_band"] = mean + 2 * std, mean - 2 * std
    ctx.logger.info("funds processed: %d", df["fund"].nunique())
    return {"rows": df}
Volatility, drawdown and bands worked out fund by fund with the same function: committee and portfolio managers read the same numbers.
The data it needs
  • Fund prices by the minute, read from the market-data provider's REST API
  • Portfolio positions and weights, from the securities system on SQL Server
  • Volatility and drawdown limits per fund, from an Excel file
Parts of Muvia used

Bring us a question you can't answer today.

We start from a real question your business has and walk the path from source to dashboard with your systems, not a demo dataset.