Chartsv26.10.18
API reference

Portfolio kit API (@unifin/chart-kit-portfolio)

Generated reference of 57 public symbols of @unifin/chart-kit-portfolio, grouped by kind and ordered as in the sources.

Generated from the package entry packages/chart-kit-portfolio/src/index.ts. Names are reachable through @unifin/chart-kit-portfolio; use your editor for full signatures - this page carries the map.

Functions (38)

SymbolWhat it does
correlationGridLabels plus a square correlation matrix to a heatmap grid. The value is clamped to -1..1, a non-finite cell stays neutral (not tinted) and the diagonal is forced to 1 - a correlation matrix that disagrees with itself is a data error, not a figure. With an asymmetric input the upper triangle wins, because that is the triangle the labels read against.
paintCorrelationMatrixPaints the correlogram: the shared heatmap painter with the diverging tone.
riskContributionsRelative risk contributions of the weights under the covariance matrix. The covariance is symmetrised first (a covariance matrix is symmetric by definition, and a host that feeds half of it should not change the answer), the weights are normalised to sum one, and a portfolio with zero variance has no decomposition at all - the function returns [] instead of dividing by zero. A non-finite weight or matrix entry drops the asset.
paintRiskDecompositionDraws the contributions as signed columns from zero: the tone follows the sign (a hedged asset contributes negatively) and the bar geometry comes from the analytic series family. Returns the number of painted columns.
monteCarloConeSimulates paths geometric random walks and returns the median path plus the nested confidence bands. steps below one, paths below one, a non-finite start or a non-positive volatility return an empty cone (the caller paints the no-data state); volatility = 0 collapses every band onto the drift path.
monteCarloJobSame simulation in flat typed arrays for a worker: the job is structured-clone safe and its buffers can be transferred instead of copied. The math is one implementation - monteCarloCone and monteCarloJob differ only in the shape they hand back, so a host may compute in a worker and validate in the main thread without divergence.
coneFromJobPoints the painter as before, rehydrated from a job result (once per result).
monteCarloJobTransferablesBuffers of a job, for postMessage(job, transferables): each buffer appears once, so a host never lists the same array twice (a duplicate transfer list is rejected by the structured clone algorithm).
paintMonteCarloConePaints the cone through the fan chart of the analytic family.
attributionRowsRows of an attribution table. The share is the step value over the largest span of the bridge, so a negative step reads as a negative share; the cumulative column is the running level of waterfallSpans and therefore ends on the bridge total. A step with a non-finite value never reaches this table (the span builder drops it), and a bridge without usable steps is an empty table rather than an exception.
allocationSharesShares of the entries; non-finite or negative values count as zero.
allocationColorTheme palette cycled across the slices (accent, growth, warn, fall, muted).
treemapRectsBinary partition treemap: the list is split at the cumulative midpoint and the split axis alternates with depth (own implementation, no foreign code).
paintTreemap-
paintStackedBarPaints a horizontal stacked bar; returns the segment count.
paintAllocationDonutPaints the allocation donut. The ring is drawn as pie slices with the inner circle punched out by the theme background; without arc in the context the painter degrades to a stacked bar of the same width as the diameter.
benchmarkCurvesIndexes both series to 100 and pairs them as analytic samples.
paintBenchmarkCurvesPaints the benchmark first and the portfolio on top; returns the points.
monthlyHeatmapBuilds the rectangular grid from monthly returns (any order).
monthlyGridAdapter to the shared heatmap family (, ): the kit grid maps onto HeatmapGridLike so hosts can paint it with paintHeatmapGrid instead of the kit-local painter. Missing months become zeros (painted as nothing); the intensity cap carries over.
paintReturnsHeatmapPaints the grid: cells, month headers (EN letters) and year labels.
periodReturnsSimple period-over-period returns of a value series (length - 1 items).
cumulativeReturnCumulative return of the series: last over first minus one.
indexToBaseIndexes the series to the given base value (default 100).
drawdownSeriesDrawdown from the running peak for every point (0 or negative).
maxDrawdownMaximum drawdown of the series (negative number or zero).
mean-
varianceSample variance (n - 1 denominator).
annualizedVolatilityAnnualised volatility: sample standard deviation times sqrt(periods).
sharpeRatioSharpe ratio: annualised mean excess return over its annualised volatility.
sortinoRatioSortino ratio: annualised mean excess return over the annualised downside deviation (root mean square of the negative excess returns).
covarianceCovariance of two equal-length series (sample denominator).
betaBeta of the asset returns against the benchmark returns.
relativeStrengthRelative strength of indexed series: asset index over benchmark index.
buildPositionRowsInput order is kept: sorting is the host's controlled step.
underwaterPointsDrawdown points in percent: x is the sample index, y is 0 or negative.
underwaterZeroLineZero line paired with the drawdown points for the band fill.
paintUnderwaterPaints the underwater ribbon (0..drawdown) and its outline.

Types (14)

SymbolWhat it does
MonteCarloSpecMonte Carlo cone of the portfolio kit ( / CHT-22-17, §1-2): the quantile bands of simulated price paths. The generator is seeded, so the same spec always yields the same cone - a scenario chart that changes on every repaint would be unreadable and unverifiable. The simulation is a scenario, never a forecast.
MonteCarloBands-
MonteCarloJobFlat, transferable cone: the same simulation in typed arrays, so a host can run it in a worker and hand the buffers over without a per-point copy (monteCarloJobTransferables). The painter consumes the point form, built once per result with coneFromJob.
AttributionRowAttribution table of the portfolio kit ( / CHT-22-18, §2): the steps of a performance bridge as table rows - the step value, its share of the bridge, the running level and the kind of the step. The base arithmetic stays in waterfallSpans, so the table and the waterfall can never disagree.
AllocationEntry-
AllocationShareOne slice: value, its share of the total and the cumulative range 0..1.
TreemapRect-
DonutOptions-
BenchmarkCurves-
MonthlyReturn-
HeatmapGrid-
HeatmapPaintOptions-
PositionEntry-
PositionRow-

Constants (5)

SymbolWhat it does
CORRELATION_MAXCorrelation is bounded by definition, so the diverging scale is 1.
MONTE_CARLO_PATH_LIMITUpper bound on the simulated paths; a bigger request is clamped, not refused.
MONTE_CARLO_DEFAULT_PATHSDefault path count of a cone that stays inside the frame budget.
MONTE_CARLO_LEVELSQuantile levels of the bands, widest first (80% then 50%).
POSITION_COLUMNSPositions columns of the portfolio kit; the host renders and sorts them.

On this page