global: snapshot part 12

This commit is contained in:
nym21
2026-03-21 12:20:55 +01:00
parent 573336ed80
commit 485f118a5f
6 changed files with 11964 additions and 822 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -24,19 +24,8 @@ use crate::distribution::metrics::ImportConfig;
use super::RealizedCore;
#[derive(Traversable)]
pub struct RealizedProfitFull<M: StorageMode = Rw> {
pub to_rcap: PercentPerBlock<BasisPoints32, M>,
}
#[derive(Traversable)]
pub struct RealizedLossFull<M: StorageMode = Rw> {
pub to_rcap: PercentPerBlock<BasisPoints32, M>,
}
#[derive(Traversable)]
pub struct RealizedNetPnl<M: StorageMode = Rw> {
pub to_rcap: PercentPerBlock<BasisPointsSigned32, M>,
#[traversable(wrap = "change_1m", rename = "to_rcap")]
pub change_1m_to_rcap: PercentPerBlock<BasisPointsSigned32, M>,
#[traversable(wrap = "change_1m", rename = "to_mcap")]
@@ -53,7 +42,6 @@ pub struct RealizedSopr<M: StorageMode = Rw> {
pub struct RealizedPeakRegret<M: StorageMode = Rw> {
#[traversable(flatten)]
pub value: FiatPerBlockCumulativeWithSums<Cents, M>,
pub to_rcap: PercentPerBlock<BasisPoints32, M>,
}
#[derive(Traversable)]
@@ -70,8 +58,6 @@ pub struct RealizedFull<M: StorageMode = Rw> {
#[traversable(flatten)]
pub core: RealizedCore<M>,
pub profit: RealizedProfitFull<M>,
pub loss: RealizedLossFull<M>,
pub gross_pnl: FiatPerBlockCumulativeWithSums<Cents, M>,
pub sell_side_risk_ratio: PercentRollingWindows<BasisPoints32, M>,
pub net_pnl: RealizedNetPnl<M>,
@@ -101,13 +87,6 @@ impl RealizedFull {
let core = RealizedCore::forced_import(cfg)?;
let profit = RealizedProfitFull {
to_rcap: cfg.import("realized_profit_to_rcap", Version::new(2))?,
};
let loss = RealizedLossFull {
to_rcap: cfg.import("realized_loss_to_rcap", Version::new(2))?,
};
// Gross PnL
let gross_pnl: FiatPerBlockCumulativeWithSums<Cents> =
cfg.import("realized_gross_pnl", v1)?;
@@ -115,7 +94,6 @@ impl RealizedFull {
// Net PnL
let net_pnl = RealizedNetPnl {
to_rcap: cfg.import("net_realized_pnl_to_rcap", Version::new(2))?,
change_1m_to_rcap: cfg.import("net_pnl_change_1m_to_rcap", Version::new(4))?,
change_1m_to_mcap: cfg.import("net_pnl_change_1m_to_mcap", Version::new(4))?,
};
@@ -128,7 +106,6 @@ impl RealizedFull {
// Peak regret
let peak_regret = RealizedPeakRegret {
value: cfg.import("realized_peak_regret", Version::new(3))?,
to_rcap: cfg.import("realized_peak_regret_to_rcap", Version::new(2))?,
};
// Investor
@@ -143,8 +120,6 @@ impl RealizedFull {
Ok(Self {
core,
profit,
loss,
gross_pnl,
sell_side_risk_ratio,
net_pnl,
@@ -298,32 +273,6 @@ impl RealizedFull {
)?;
}
// Profit/loss/net_pnl rel to realized cap
self.profit
.to_rcap
.compute_binary::<Cents, Cents, RatioCentsBp32>(
starting_indexes.height,
&self.core.minimal.profit.block.cents,
&self.core.minimal.cap.cents.height,
exit,
)?;
self.loss
.to_rcap
.compute_binary::<Cents, Cents, RatioCentsBp32>(
starting_indexes.height,
&self.core.minimal.loss.block.cents,
&self.core.minimal.cap.cents.height,
exit,
)?;
self.net_pnl
.to_rcap
.compute_binary::<CentsSigned, Cents, RatioCentsSignedCentsBps32>(
starting_indexes.height,
&self.core.net_pnl.block.cents,
&self.core.minimal.cap.cents.height,
exit,
)?;
// Gross PnL
self.gross_pnl.block.cents.compute_add(
starting_indexes.height,
@@ -351,16 +300,6 @@ impl RealizedFull {
exit,
)?;
// Peak regret rel to rcap
self.peak_regret
.to_rcap
.compute_binary::<Cents, Cents, RatioCentsBp32>(
starting_indexes.height,
&self.peak_regret.value.block.cents,
&self.core.minimal.cap.cents.height,
exit,
)?;
// Investor price ratio, percentiles and bands
self.investor
.price

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -41,7 +41,7 @@ import {
* @returns {AnyFetchedSeriesBlueprint}
*/
function netBaseline(s, unit) {
return baseline({ series: s, name: "Net P&L", unit });
return baseline({ series: s, name: "Net", unit });
}
// ============================================================================
@@ -61,7 +61,7 @@ function unrealizedOverview(profit, loss, netPnlUsd, title) {
name: "Overview",
title: title("Unrealized P&L"),
bottom: [
baseline({ series: netPnlUsd, name: "Net P&L", unit: Unit.usd }),
baseline({ series: netPnlUsd, name: "Net", unit: Unit.usd }),
dotted({
series: profit.usd,
name: "Profit",
@@ -119,7 +119,7 @@ function unrealizedBase(u, title) {
return [
unrealizedOverview(u.profit, u.loss, u.netPnl.usd, title),
{
name: "Net P&L",
name: "Net",
title: title("Net Unrealized P&L"),
bottom: [netBaseline(u.netPnl.usd, Unit.usd)],
},
@@ -227,7 +227,7 @@ function unrealizedTreeMid(u, title) {
return [
unrealizedOverview(u.profit, u.loss, u.netPnl.usd, title),
{
name: "Net P&L",
name: "Net",
title: title("Net Unrealized P&L"),
bottom: [netBaseline(u.netPnl.usd, Unit.usd)],
},
@@ -312,10 +312,9 @@ function nuplSeries(nupl) {
* @param {string} args.metricTitle
* @param {Color} args.color
* @param {(name: string) => string} args.title
* @param {{ percent: AnySeriesPattern, ratio: AnySeriesPattern }} [args.toRcap]
* @returns {PartialOptionsTree}
*/
function realizedMetricFolder({ pattern, metricTitle, color, title, toRcap }) {
function realizedMetricFolder({ pattern, metricTitle, color, title }) {
return [
{
name: "Compare",
@@ -353,19 +352,6 @@ function realizedMetricFolder({ pattern, metricTitle, color, title, toRcap }) {
}),
],
},
...(toRcap
? [
{
name: "% of Realized Cap",
title: title(`Realized ${metricTitle} (% of Realized Cap)`),
bottom: percentRatioBaseline({
pattern: toRcap,
name: metricTitle,
color,
}),
},
]
: []),
];
}
@@ -374,13 +360,12 @@ function realizedMetricFolder({ pattern, metricTitle, color, title, toRcap }) {
* @param {Object} args
* @param {NetPnlFullPattern | NetPnlBasicPattern} args.netPnl
* @param {(name: string) => string} args.title
* @param {{ percent: AnySeriesPattern, ratio: AnySeriesPattern }} [args.toRcap]
* @param {PartialOptionsTree} [args.extraChange] - Additional change items (% of Mcap, % of Rcap)
* @returns {PartialOptionsGroup}
*/
function realizedNetFolder({ netPnl, title, toRcap, extraChange = [] }) {
function realizedNetFolder({ netPnl, title, extraChange = [] }) {
return {
name: "Net P&L",
name: "Net",
tree: [
{
name: "Compare",
@@ -416,15 +401,6 @@ function realizedNetFolder({ netPnl, title, toRcap, extraChange = [] }) {
}),
],
},
...(toRcap
? [
{
name: "% of Realized Cap",
title: title("Net Realized P&L (% of Realized Cap)"),
bottom: percentRatioBaseline({ pattern: toRcap, name: "Net" }),
},
]
: []),
{ ...sumsTreeBaseline({ windows: mapWindows(netPnl.delta.absolute, (c) => c.usd), title: title("Net Realized P&L Change"), unit: Unit.usd }), name: "Change" },
{
name: "Growth Rate",
@@ -464,7 +440,7 @@ function realizedOverviewFolder({
bottom: [
baseline({
series: netPnl.sum[w.key].usd,
name: "Net P&L",
name: "Net",
unit: Unit.usd,
}),
dotted({
@@ -491,7 +467,7 @@ function realizedOverviewFolder({
dotted({
series: grossPnl.sum[w.key].usd,
name: "Gross",
color: colors.bitcoin,
color: colors.gross,
unit: Unit.usd,
defaultActive: false,
}),
@@ -502,7 +478,7 @@ function realizedOverviewFolder({
dotted({
series: peakRegret.sum[w.key].usd,
name: "Peak Regret",
color: colors.default,
color: colors.regret,
unit: Unit.usd,
defaultActive: false,
}),
@@ -539,7 +515,6 @@ function realizedSubfolderFull(r, title) {
realizedNetFolder({
netPnl: r.netPnl,
title,
toRcap: r.netPnl.toRcap,
extraChange: [
{
name: "% of Market Cap",
@@ -566,7 +541,6 @@ function realizedSubfolderFull(r, title) {
metricTitle: "Profit",
color: colors.profit,
title,
toRcap: r.profit.toRcap,
}),
},
{
@@ -576,15 +550,14 @@ function realizedSubfolderFull(r, title) {
metricTitle: "Loss",
color: colors.loss,
title,
toRcap: r.loss.toRcap,
}),
},
{
name: "Gross P&L",
name: "Gross",
tree: realizedMetricFolder({
pattern: r.grossPnl,
metricTitle: "Gross P&L",
color: colors.bitcoin,
color: colors.gross,
title,
}),
},
@@ -655,14 +628,6 @@ function realizedSubfolderFull(r, title) {
}),
],
},
{
name: "% of Realized Cap",
title: title("Peak Regret (% of Realized Cap)"),
bottom: percentRatioBaseline({
pattern: r.peakRegret.toRcap,
name: "Peak Regret",
}),
},
],
},
],
@@ -1102,7 +1067,7 @@ function groupedRealizedSubfolderFull(list, all, title) {
}),
},
{
name: "Gross P&L",
name: "Gross",
tree: groupedWindowsCumulativeUsd({
list,
all,
@@ -1177,7 +1142,7 @@ function groupedNuplCharts(list, all, title) {
function groupedUnrealizedMid(list, all, title) {
return [
{
name: "Net P&L",
name: "Net",
title: title("Net Unrealized P&L"),
bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) =>
baseline({

View File

@@ -173,6 +173,10 @@ export const colors = {
adjustedCreated: palette.lime,
adjustedDestroyed: palette.pink,
// Realized P&L
gross: palette.yellow,
regret: palette.pink,
// Ratios
plRatio: palette.yellow,