Documentation

Docs.

Add a dashboard to your site in a few minutes.

Getting started

Each template is a folder of plain HTML, CSS and JavaScript. There is nothing to install and no build step. It works on any website, and inside React, Vue, Next.js or WordPress.

What is in the download

Add it to a page

<link rel="stylesheet" href="portfolio-risk.css">
<div id="risk"></div>

<script src="risk-engine.js"></script>
<script src="portfolio-risk.js"></script>
<script>
  const dash = PortfolioRisk.mount(document.getElementById('risk'), yourData, { theme: 'light' });
</script>

The dashboard sizes itself to its container, so put it in a column of any width. Below about 640 pixels it switches to a phone layout.

Files for each template

TemplateLoad, in this orderMount
Portfolio riskportfolio-risk.css, risk-engine.js, portfolio-risk.jsPortfolioRisk.mount(el, data, options)
Broker bookmt.css, mt-ui.js, book-engine.js, broker-book.jsBrokerBook.mount(el, data, options)
SaaS metricsmt.css, mt-ui.js, saas-engine.js, saas-metrics.jsSaasMetrics.mount(el, data, options)

Your data

Each engine reads one plain JavaScript object. Load it from your API, a database or a file, then pass it to mount. Dates are ISO strings (2026-11-13) and months are 2026-11.

Portfolio risk

{
  name: 'Growth portfolio',
  riskFree: 0.065,                       // annual risk-free rate
  dates: ['2025-11-13', ...],            // trading days, oldest first
  benchmark: { name: 'NIFTY 50', prices: [21000, ...] },
  positions: [
    { symbol: 'TCS', name: 'Tata Consultancy Services', sector: 'IT',
      quantity: 60, prices: [3600, ...] }  // one price per date
  ]
}

Broker book

{
  name: 'Commercial book', asOf: '2026-11-13',
  lines: { Motor: { commission: 0.15 }, Health: { commission: 0.075 } },
  clients: [{ id: 'C001', name: 'Kaveri Textiles', industry: 'Manufacturing',
              insurer: 'Tata AIG', renewal: '2027-01-15',
              policies: [{ line: 'Motor', premium: 450000 }] }],
  claims: [{ client: 'C001', line: 'Motor', date: '2026-03-02',
             paid: 64000, outstanding: 12000 }]
}

SaaS metrics

{
  name: 'Acme', grossMargin: 0.8,
  months: ['2024-06', ...],                 // at least 13 months
  spend: { '2026-11': 240000 },             // sales and marketing spend
  customers: [{ id: 'A0001', plan: 'Growth',
                mrr: [0, 0, 199, 199, 249, ...] }]  // one value per month, 0 when not paying
}

Options and updates

OptionValuesDefault
theme'light' or 'dark''light'
window (Portfolio risk)63, 126, 252 or 504 trading days252
confidence (Portfolio risk)0.95 or 0.990.99
horizon (Portfolio risk)1 or 10 days1

mount returns an object. Call dash.update(newData) to redraw with fresh data, and on Portfolio risk dash.setTheme('dark') to switch theme from your own toggle.

Styling

All styles sit under the .mpr class, so they never leak into your site. Change the look by overriding its variables:

.mpr {
  --bg: #ffffff;        /* page behind the cards */
  --card: #ffffff;      /* card surface */
  --ink: #0b1220;       /* main text */
  --fill: #0b1220;      /* lines, bars and highlights */
  --h: 'Your Font', sans-serif;   /* headings and numbers */
  --b: 'Your Font', sans-serif;   /* body text */
}
.mpr[data-theme="dark"] { --bg: #000; --card: #111113; --ink: #f5f5f7; --fill: #f5f5f7; }

React and other frameworks

import { useEffect, useRef } from 'react';

export default function RiskPanel({ data }) {
  const ref = useRef(null);
  useEffect(() => {
    const dash = window.PortfolioRisk.mount(ref.current, data, { theme: 'light' });
    return () => { ref.current.innerHTML = ''; };
  }, [data]);
  return <div ref={ref} />;
}

Load the template's CSS and scripts once, in your layout or with next/script. In WordPress, paste the snippet from Getting started into a Custom HTML block.

Checking the maths

Every engine ships with its tests. With Node.js installed, run:

node test-engine.js
# 54 passed, 0 failed

The tests recompute each figure a second, independent way. Examples: drawdown by checking every peak and trough, beta against a regression slope, the MRR bridge balancing every month, and the simulated annual loss against its exact expected value.

The methods are listed in each dashboard's footnote: historical and parametric value at risk, Euler risk contributions, credibility-weighted loss ratios, compound Poisson simulation, cohort retention and bootstrap forecasts.

Help

Email support@moluscca.com. Include the template name and, if something looks wrong, a sample of the data you passed in. We reply within one working day.