global: snapshot

This commit is contained in:
nym21
2026-01-31 17:39:48 +01:00
parent 8dd350264a
commit ff5bb770d7
116 changed files with 13312 additions and 9530 deletions
+9 -40
View File
@@ -1,7 +1,7 @@
/** Moving averages section */
import { price } from "../series.js";
import { createRatioChart, createZScoresFolder, formatCohortTitle } from "../shared.js";
import { createPriceRatioCharts } from "../shared.js";
import { periodIdToName } from "./utils.js";
/**
@@ -66,39 +66,6 @@ function buildEmaAverages(colors, ma) {
}));
}
/**
* Create price with ratio options (for moving averages)
* @param {PartialContext} ctx
* @param {Object} args
* @param {string} args.title
* @param {string} args.legend
* @param {EmaRatioPattern} args.ratio
* @param {Color} args.color
* @returns {PartialOptionsTree}
*/
export function createPriceWithRatioOptions(
ctx,
{ title, legend, ratio, color },
) {
const pricePattern = ratio.price;
return [
{
name: "Price",
title,
top: [price({ metric: pricePattern, name: legend, color })],
},
createRatioChart(ctx, { title: formatCohortTitle(title), pricePattern, ratio, color }),
createZScoresFolder(ctx, {
title,
legend,
pricePattern,
ratio,
color,
}),
];
}
/** Common period IDs to show at top level */
const COMMON_PERIODS = ["1w", "1m", "200d", "1y", "200w", "4y"];
@@ -176,10 +143,11 @@ export function createAveragesSection(ctx, movingAverage) {
// Common periods at top level
...commonAverages.map(({ name, color, ratio }) => ({
name,
tree: createPriceWithRatioOptions(ctx, {
ratio,
title: `${name} ${label}`,
tree: createPriceRatioCharts(ctx, {
context: `${name} ${label}`,
legend: "average",
pricePattern: ratio.price,
ratio,
color,
}),
})),
@@ -188,10 +156,11 @@ export function createAveragesSection(ctx, movingAverage) {
name: "More...",
tree: moreAverages.map(({ name, color, ratio }) => ({
name,
tree: createPriceWithRatioOptions(ctx, {
ratio,
title: `${name} ${label}`,
tree: createPriceRatioCharts(ctx, {
context: `${name} ${label}`,
legend: "average",
pricePattern: ratio.price,
ratio,
color,
}),
})),
+2 -3
View File
@@ -1,8 +1,7 @@
/** Market section - Main entry point */
import { localhost } from "../../utils/env.js";
import { Unit } from "../../utils/units.js";
import { candlestick, line, price } from "../series.js";
import { line, price } from "../series.js";
import { createAveragesSection } from "./averages.js";
import { createReturnsSection } from "./performance.js";
import { createMomentumSection } from "./momentum.js";
@@ -21,7 +20,7 @@ import {
*/
export function createMarketSection(ctx) {
const { colors, brk } = ctx;
const { market, supply, price: priceMetrics } = brk.metrics;
const { market, supply } = brk.metrics;
const {
movingAverage,
ath,
+18 -6
View File
@@ -52,7 +52,7 @@ export function createDcaVsLumpSumSection(ctx, { dca, lookback, returns }) {
/**
* @param {string} name
* @param {ShortPeriodKey | LongPeriodKey} key
* @param {AllPeriodKey} key
*/
const costBasisChart = (name, key) => ({
name: "Cost Basis",
@@ -71,7 +71,10 @@ export function createDcaVsLumpSumSection(ctx, { dca, lookback, returns }) {
],
});
/** @param {string} name @param {ShortPeriodKey | LongPeriodKey} key */
/**
* @param {string} name
* @param {AllPeriodKey} key
*/
const daysInProfitChart = (name, key) => ({
name: "Days in Profit",
title: `${name} Days in Profit`,
@@ -85,7 +88,10 @@ export function createDcaVsLumpSumSection(ctx, { dca, lookback, returns }) {
],
});
/** @param {string} name @param {ShortPeriodKey | LongPeriodKey} key */
/**
* @param {string} name
* @param {AllPeriodKey} key
*/
const daysInLossChart = (name, key) => ({
name: "Days in Loss",
title: `${name} Days in Loss`,
@@ -99,7 +105,10 @@ export function createDcaVsLumpSumSection(ctx, { dca, lookback, returns }) {
],
});
/** @param {string} name @param {ShortPeriodKey | LongPeriodKey} key */
/**
* @param {string} name
* @param {AllPeriodKey} key
*/
const maxDrawdownChart = (name, key) => ({
name: "Max Drawdown",
title: `${name} Max Drawdown`,
@@ -113,7 +122,10 @@ export function createDcaVsLumpSumSection(ctx, { dca, lookback, returns }) {
],
});
/** @param {string} name @param {ShortPeriodKey | LongPeriodKey} key */
/**
* @param {string} name
* @param {AllPeriodKey} key
*/
const maxReturnChart = (name, key) => ({
name: "Max Return",
title: `${name} Max Return`,
@@ -129,7 +141,7 @@ export function createDcaVsLumpSumSection(ctx, { dca, lookback, returns }) {
/**
* @param {string} name
* @param {ShortPeriodKey | LongPeriodKey} key
* @param {AllPeriodKey} key
*/
const stackChart = (name, key) => ({
name: "Stack",