general: snapshot

This commit is contained in:
k
2024-06-30 17:01:15 +02:00
parent 9905eff383
commit b7e8cbea20
68 changed files with 1725 additions and 1535 deletions
+11 -26
View File
@@ -4,8 +4,8 @@ import {
} from "../../datasets/consts/address";
import { liquidities } from "../../datasets/consts/liquidities";
import { colors } from "../../utils/colors";
import { applySeriesList, SeriesType } from "../apply";
import { createCohortPresetList } from "../templates/cohort";
import { applyMultipleSeries, SeriesType } from "../templates/multiple";
export function createPresets({
scale,
@@ -22,12 +22,9 @@ export function createPresets({
description: "",
icon: IconTablerWallet,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: `Total Non Empty Address`,
color: colors.bitcoin,
@@ -45,12 +42,9 @@ export function createPresets({
description: "",
icon: IconTablerSparkles,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: `New Addresses`,
color: colors.white,
@@ -67,12 +61,9 @@ export function createPresets({
description: "",
icon: IconTablerArchive,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: `Total Addresses Created`,
color: colors.bitcoin,
@@ -90,12 +81,9 @@ export function createPresets({
description: "",
icon: IconTablerTrash,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: `Total Empty Addresses`,
color: colors.darkWhite,
@@ -191,12 +179,9 @@ export function createAddressCountPreset<Scale extends ResourceScale>({
title: `${name} Address Count`,
icon: IconTablerAddressBook,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Address Count",
color,
+357
View File
@@ -0,0 +1,357 @@
import { createRWS } from "/src/solid/rws";
import { createChart } from "../lightweightCharts/chart/create";
import { applyPriceSeries } from "../lightweightCharts/chart/price";
import { chartState } from "../lightweightCharts/chart/state";
import { setWhitespace } from "../lightweightCharts/chart/whitespace";
import { createAreaSeries } from "../lightweightCharts/series/creators/area";
import {
createBaseLineSeries,
DEFAULT_BASELINE_COLORS,
} from "../lightweightCharts/series/creators/baseLine";
import { createHistogramSeries } from "../lightweightCharts/series/creators/histogram";
import { createSeriesLegend } from "../lightweightCharts/series/creators/legend";
import { createLineSeries } from "../lightweightCharts/series/creators/line";
import { debounce } from "../utils/debounce";
import { stringToId } from "../utils/id";
export enum SeriesType {
Normal,
Based,
Area,
Histogram,
}
type SeriesConfig<Scale extends ResourceScale> =
| {
dataset: AnyDataset<Scale>;
color?: string;
colors?: undefined;
seriesType: SeriesType.Based;
title: string;
options?: BaselineSeriesOptions;
defaultVisible?: boolean;
}
| {
dataset: AnyDataset<Scale>;
color?: string;
colors?: string[];
seriesType: SeriesType.Histogram;
title: string;
options?: DeepPartialHistogramOptions;
defaultVisible?: boolean;
}
| {
dataset: AnyDataset<Scale>;
color: string;
colors?: undefined;
seriesType?: SeriesType.Normal | SeriesType.Area;
title: string;
options?: DeepPartialLineOptions;
defaultVisible?: boolean;
};
export function applySeriesList<Scale extends ResourceScale>({
parentDiv,
charts: reactiveChartList,
top,
bottom,
preset,
priceScaleOptions,
datasets,
priceDataset,
priceOptions,
activeResources,
legendSetter,
}: {
charts: RWS<IChartApi[]>;
parentDiv: HTMLDivElement;
preset: Preset;
legendSetter: Setter<PresetLegend>;
priceDataset?: AnyDataset<Scale>;
priceOptions?: PriceSeriesOptions;
priceScaleOptions?: DeepPartialPriceScaleOptions;
top?: SeriesConfig<Scale>[];
bottom?: SeriesConfig<Scale>[];
datasets: Datasets;
activeResources: Accessor<Set<ResourceDataset<any, any>>>;
}) {
reactiveChartList.set((charts) => {
charts.forEach((chart) => {
chart.remove();
});
return [];
});
parentDiv.replaceChildren();
const scale = preset.scale;
const legendList: PresetLegend = [];
const priceSeriesType = createRWS<"Candlestick" | "Line">("Candlestick");
const valuesSkipped = createRWS(0);
const charts = [top || [], bottom]
.flatMap((list) => (list ? [list] : []))
.flatMap((seriesConfigList, index, array) => {
if (index !== 0 && seriesConfigList.length === 0) {
return [];
}
const isAnyArea = seriesConfigList.find(
(config) => config.seriesType === SeriesType.Area,
);
const div = document.createElement("div");
div.className = "w-full cursor-crosshair min-h-0 border-orange-200/10";
parentDiv.appendChild(div);
const chart = createChart(scale, div, {
...priceScaleOptions,
...(isAnyArea
? {
scaleMargins: {
bottom: 0,
},
}
: {}),
});
chartState.chart = chart;
if (!chart) {
console.log("chart: undefined");
return [];
}
setWhitespace(chart, scale);
const seriesList: ISeriesApi<any>[] = [];
const _legendList: PresetLegend = [];
if (index === 0) {
const price = applyPriceSeries({
chart,
preset,
seriesType: priceSeriesType,
valuesSkipped,
dataset:
priceDataset ||
(datasets[preset.scale as Scale].price as unknown as NonNullable<
typeof priceDataset
>),
activeResources,
options: priceOptions,
});
_legendList.push(price.lineLegend, price.ohlcLegend);
seriesList.push(price.lineLegend.series, price.ohlcLegend.series);
}
seriesList.push(
...seriesConfigList
.reverse()
.map(
({
dataset,
color,
colors,
seriesType: type,
title,
options,
defaultVisible,
}) => {
let series: ISeriesApi<
"Baseline" | "Line" | "Area" | "Histogram"
>;
if (type === SeriesType.Based) {
series = createBaseLineSeries(chart, {
color,
...options,
});
} else if (type === SeriesType.Area) {
series = createAreaSeries(chart, {
color,
autoscaleInfoProvider: (
getInfo: () => AutoscaleInfo | null,
) => {
const info = getInfo();
if (info) {
info.priceRange.minValue = 0;
}
return info;
},
...options,
});
} else if (type === SeriesType.Histogram) {
series = createHistogramSeries(chart, {
color,
...options,
});
} else {
series = createLineSeries(chart, {
color,
...options,
});
}
_legendList.push(
createSeriesLegend({
id: stringToId(title),
presetId: preset.id,
title,
series,
color: () => colors || color || DEFAULT_BASELINE_COLORS,
defaultVisible,
url: dataset.url,
}),
);
createEffect(() => {
series.setData(
dataset?.values() || [],
// computeDrawnSeriesValues(dataset?.values(), valuesSkipped()),
);
});
return series;
},
),
);
_legendList.forEach((legend) => {
legendList.splice(0, 0, legend);
});
return [{ div, chart, seriesList, legendList: _legendList }];
});
createEffect(() => {
const visibleCharts: typeof charts = [];
charts.forEach((chart) => {
if (chart.legendList.some((legend) => legend.drawn())) {
chart.div.style.border = "";
visibleCharts.push(chart);
} else {
chart.div.style.height = "0px";
chart.div.style.border = "none";
}
});
visibleCharts.forEach(({ div, chart }, index) => {
const last = index === visibleCharts.length - 1;
div.style.height = last ? "100%" : "calc(100% - 62px)";
div.style.borderBottomWidth = last ? "none" : "1px";
chart.timeScale().applyOptions({
visible: last,
});
});
});
// const seriesType = createRWS(
// checkIfUpClose(chart, chartState.range) || "Candlestick",
// );
function updateVisibleRangeRatio(
chart: IChartApi,
range: LogicalRange | null,
) {
if (!range) return;
try {
const width = chart.timeScale().width();
const ratio = (range.to - range.from) / width;
if (ratio <= 0.5) {
priceSeriesType.set("Candlestick");
} else {
priceSeriesType.set("Line");
valuesSkipped.set(Math.floor(ratio / 5));
}
} catch {}
}
const debouncedUpdateVisibleRangeRatio = debounce(
updateVisibleRangeRatio,
50,
);
charts.forEach(({ chart }, index) => {
chart.timeScale().subscribeVisibleLogicalRangeChange((timeRange) => {
// Last chart otherwise length of timescale is Infinity
if (index === charts.length - 1) {
debouncedUpdateVisibleRangeRatio(chart, timeRange);
}
charts.forEach(({ chart: _chart }, _index) => {
if (timeRange && index !== _index) {
_chart.timeScale().setVisibleLogicalRange(timeRange);
}
});
});
chart.subscribeCrosshairMove(({ time, sourceEvent }) => {
// Don't override crosshair position from scroll event
if (time && !sourceEvent) return;
charts.forEach(({ chart: _chart, seriesList }, _index) => {
const first = seriesList.at(0);
if (first && index !== _index) {
if (time) {
_chart.setCrosshairPosition(NaN, time, first);
} else {
// No time when mouse goes outside the chart
_chart.clearCrosshairPosition();
}
}
});
});
});
legendSetter(legendList);
reactiveChartList.set(() => charts.map(({ chart }) => chart));
}
export function computeDrawnSeriesValues<T>(
values: DatasetValue<T>[] | undefined,
valuesSkipped: number,
) {
values = values || [];
if (valuesSkipped === 0) {
return values;
} else {
const valuesSkippedPlus1 = valuesSkipped + 1;
// console.log(_valuesSkippedPlus1);
let length = Math.floor(values.length / valuesSkippedPlus1);
// console.log(length);
const filteredValues = new Array(length);
for (let i = 0; i < length; i++) {
filteredValues[i] = values[i * valuesSkippedPlus1];
}
// console.log(filteredValues.length);
return filteredValues;
}
}
+15 -40
View File
@@ -1,5 +1,5 @@
import { colors } from "../../utils/colors";
import { applyMultipleSeries, SeriesType } from "../templates/multiple";
import { applySeriesList, SeriesType } from "../apply";
export function createPresets() {
const scale: ResourceScale = "date";
@@ -14,12 +14,9 @@ export function createPresets() {
title: "Block Height",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Height",
color: colors.bitcoin,
@@ -40,19 +37,15 @@ export function createPresets() {
title: "Daily Sum Of Blocks Mined",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Target",
color: colors.white,
dataset: params.datasets.date.blocks_mined_1d_target,
options: {
lineStyle: 3,
// lineStyle: LineStyle.LargeDashed,
},
},
{
@@ -82,19 +75,15 @@ export function createPresets() {
title: "Weekly Sum Of Blocks Mined",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Target",
color: colors.white,
dataset: params.datasets.date.blocks_mined_1w_target,
options: {
lineStyle: 3,
// lineStyle: LineStyle.LargeDashed,
},
},
{
@@ -113,18 +102,14 @@ export function createPresets() {
title: "Monthly Sum Of Blocks Mined",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Target",
color: colors.white,
dataset: params.datasets.date.blocks_mined_1m_target,
options: {
// lineStyle: LineStyle.LargeDashed,
lineStyle: 3,
},
},
@@ -144,19 +129,15 @@ export function createPresets() {
title: "Yearly Sum Of Blocks Mined",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Target",
color: colors.white,
dataset: params.datasets.date.blocks_mined_1y_target,
options: {
lineStyle: 3,
// lineStyle: LineStyle.LargeDashed,
},
},
{
@@ -175,12 +156,9 @@ export function createPresets() {
title: "Total Blocks Mined",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Mined",
color: colors.bitcoin,
@@ -200,12 +178,9 @@ export function createPresets() {
title: "Cumulative Block Size",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Size (MB)",
color: colors.darkWhite,
+67 -142
View File
@@ -1,5 +1,5 @@
import { colors } from "../../utils/colors";
import { applyMultipleSeries, SeriesType } from "../templates/multiple";
import { applySeriesList, SeriesType } from "../apply";
export function createPresets<Scale extends ResourceScale>({
scale,
@@ -19,9 +19,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "All Cointime Prices",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: [
top: [
{
title: "Vaulted Price",
color: colors.vaultedness,
@@ -61,9 +61,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Active Price",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: [
top: [
{
title: "Active Price",
color: colors.liveliness,
@@ -85,9 +85,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Vaulted Price",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: [
top: [
{
title: "Vaulted Price",
color: colors.vaultedness,
@@ -109,9 +109,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "True Market Mean",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: [
top: [
{
title: "True Market Mean",
color: colors.trueMarketMeanPrice,
@@ -133,9 +133,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Cointime Price",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: [
top: [
{
title: "Cointime",
color: colors.cointimePrice,
@@ -159,16 +159,14 @@ export function createPresets<Scale extends ResourceScale>({
title: "Cointime Capitalizations",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "Market Cap",
color: colors.white,
dataset: params.datasets[scale].market_cap,
},
@@ -198,13 +196,12 @@ export function createPresets<Scale extends ResourceScale>({
title: "Thermo Cap",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "Thermo Cap",
color: colors.thermoCap,
@@ -221,13 +218,12 @@ export function createPresets<Scale extends ResourceScale>({
title: "Investor Cap",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "Investor Cap",
color: colors.investorCap,
@@ -244,12 +240,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Thermo Cap To Investor Cap Ratio (%)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Ratio",
color: colors.bitcoin,
@@ -272,12 +265,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "All Coinblocks",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinblocks Created",
color: colors.coinblocksCreated,
@@ -304,12 +294,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Coinblocks Created",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinblocks Created",
color: colors.coinblocksCreated,
@@ -326,12 +313,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Coinblocks Destroyed",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinblocks Destroyed",
color: colors.coinblocksDestroyed,
@@ -348,12 +332,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Coinblocks Stored",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinblocks Stored",
color: colors.coinblocksStored,
@@ -375,12 +356,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "All Cumulative Coinblocks",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Cumulative Coinblocks Created",
color: colors.coinblocksCreated,
@@ -410,12 +388,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Cumulative Coinblocks Created",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Cumulative Coinblocks Created",
color: colors.coinblocksCreated,
@@ -433,12 +408,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Cumulative Coinblocks Destroyed",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Cumulative Coinblocks Destroyed",
color: colors.coinblocksDestroyed,
@@ -456,12 +428,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Cumulative Coinblocks Stored",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Cumulative Coinblocks Stored",
color: colors.coinblocksStored,
@@ -484,12 +453,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Liveliness (Activity)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Liveliness",
color: colors.liveliness,
@@ -506,12 +472,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Vaultedness",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Vaultedness",
color: colors.vaultedness,
@@ -528,12 +491,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Liveliness V. Vaultedness",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Liveliness",
color: colors.liveliness,
@@ -555,12 +515,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Activity To Vaultedness Ratio",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Activity To Vaultedness Ratio",
color: colors.activityToVaultednessRatio,
@@ -578,12 +535,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Concurrent Liveliness - Supply Adjusted Coindays Destroyed",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Concurrent Liveliness 14d Median",
color: `${colors.liveliness}66`,
@@ -606,12 +560,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Liveliness Incremental Change",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Liveliness Incremental Change",
color: colors.darkLiveliness,
@@ -641,12 +592,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Vaulted Supply",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Vaulted Supply",
color: colors.vaultedness,
@@ -663,12 +611,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Active Supply",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Active Supply",
color: colors.liveliness,
@@ -685,12 +630,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Vaulted V. Active",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Circulating Supply",
color: colors.coinblocksCreated,
@@ -747,12 +689,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Vaulted Supply Net Change",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Vaulted Supply Net Change",
color: colors.vaultedness,
@@ -769,12 +708,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Active Supply Net Change",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Active Supply Net Change",
color: colors.liveliness,
@@ -791,12 +727,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Active VS. Vaulted 90 Day Supply Net Change",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Active Supply Net Change",
color: `${colors.liveliness}80`,
@@ -919,12 +852,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Cointime Supply In Profit",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Circulating Supply",
color: colors.coinblocksCreated,
@@ -951,12 +881,9 @@ export function createPresets<Scale extends ResourceScale>({
title: "Cointime Supply In Loss",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Circulating Supply",
color: colors.coinblocksCreated,
@@ -985,13 +912,12 @@ export function createPresets<Scale extends ResourceScale>({
title: "Cointime-Adjusted Yearly Inflation Rate (%)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "Cointime Adjusted",
color: colors.coinblocksCreated,
@@ -1015,13 +941,12 @@ export function createPresets<Scale extends ResourceScale>({
title: "Cointime-Adjusted Transactions Velocity",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "Cointime Adjusted",
color: colors.coinblocksCreated,
+3 -6
View File
@@ -6,8 +6,8 @@ import {
yearCohorts,
} from "../../datasets/consts/age";
import { colors } from "../../utils/colors";
import { applySeriesList } from "../apply";
import { createCohortPresetFolder } from "../templates/cohort";
import { applyMultipleSeries } from "../templates/multiple";
export function createPresets({ scale }: { scale: ResourceScale }) {
return {
@@ -20,12 +20,9 @@ export function createPresets({ scale }: { scale: ResourceScale }) {
description: "",
icon: IconTablerRipple,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: `24h`,
color: colors.up_to_1d,
+14 -15
View File
@@ -48,22 +48,21 @@ export function createPresets(): Presets {
],
} satisfies PartialPresetFolder,
{
name: "By Height (Coming soon)",
name: "By Height",
tree: [
// createMarketPresets({ scale: "height", datasets }),
// createMinersPresets("height"),
// createTransactionsPresets("height"),
// ...createCohortPresetList({
// datasets,
// scale: "height",
// color: colors.bitcoin,
// name: "",
// datasetKey: "",
// title: "",
// }),
// createHodlersPresets({ scale: "height", datasets }),
// createAddressesPresets({ scale: "height", datasets }),
// createCoinblocksPresets({ scale: "height", datasets }),
createMarketPresets({ scale: "height" }),
createMinersPresets("height"),
createTransactionsPresets("height"),
...createCohortPresetList({
scale: "height",
color: colors.bitcoin,
name: "",
datasetKey: "",
title: "",
}),
createHodlersPresets({ scale: "height" }),
createAddressesPresets({ scale: "height" }),
createCoinblocksPresets({ scale: "height" }),
],
} satisfies PartialPresetFolder,
],
@@ -1,7 +1,7 @@
import { averages } from "/src/scripts/datasets/date";
import { colors } from "/src/scripts/utils/colors";
import { applyMultipleSeries } from "../../templates/multiple";
import { applySeriesList } from "../../apply";
export function createPresets(): PartialPresetFolder {
const scale: ResourceScale = "date";
@@ -15,9 +15,9 @@ export function createPresets(): PartialPresetFolder {
name: "All",
title: "All Averages",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: averages.map((average) => ({
top: averages.map((average) => ({
title: average.key.toUpperCase(),
color: colors[`_${average.key}`],
dataset: params.datasets.date[`price_${average.key}_sma`],
@@ -60,9 +60,9 @@ function createPresetFolder({
icon: IconTablerMathAvg,
title: `${name} Moving Average`,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: [
top: [
{
title: `SMA`,
color,
+5 -8
View File
@@ -1,5 +1,5 @@
import { colors } from "../../utils/colors";
import { applyMultipleSeries } from "../templates/multiple";
import { applySeriesList } from "../apply";
import { createPresets as createAveragesPresets } from "./averages";
import { createPresets as createIndicatorsPresets } from "./indicators";
import { createPresets as createReturnsPresets } from "./returns";
@@ -14,7 +14,7 @@ export function createPresets({ scale }: { scale: ResourceScale }) {
name: "Price",
title: "Market Price",
applyPreset(params) {
return applyMultipleSeries({ ...params });
return applySeriesList(params);
},
description: "",
},
@@ -24,7 +24,7 @@ export function createPresets({ scale }: { scale: ResourceScale }) {
name: "Performance",
title: "Market Performance",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceOptions: {
id: "performance",
@@ -43,12 +43,9 @@ export function createPresets({ scale }: { scale: ResourceScale }) {
name: "Capitalization",
title: "Market Capitalization",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Market Cap.",
dataset: params.datasets[scale].market_cap,
@@ -3,7 +3,7 @@ import {
totalReturns,
} from "/src/scripts/datasets/consts/returns";
import { applyMultipleSeries, SeriesType } from "../../templates/multiple";
import { applySeriesList, SeriesType } from "../../apply";
export function createPresets() {
return {
@@ -57,12 +57,9 @@ function createPreset({
icon: IconTablerReceiptTax,
title: `${title} Return`,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: `Return (%)`,
seriesType: SeriesType.Based,
+68 -155
View File
@@ -1,5 +1,5 @@
import { colors } from "../../utils/colors";
import { applyMultipleSeries, SeriesType } from "../templates/multiple";
import { applySeriesList, SeriesType } from "../apply";
export function createPresets(scale: ResourceScale) {
return {
@@ -20,12 +20,9 @@ export function createPresets(scale: ResourceScale) {
title: "Last Coinbase (In Bitcoin)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Last",
color: colors.bitcoin,
@@ -42,12 +39,9 @@ export function createPresets(scale: ResourceScale) {
title: "Last Coinbase (In Dollars)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Last",
color: colors.dollars,
@@ -71,12 +65,9 @@ export function createPresets(scale: ResourceScale) {
title: "Daily Sum Of Bitcoin Coinbases",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinbases (Bitcoin)",
color: colors.bitcoin,
@@ -93,12 +84,9 @@ export function createPresets(scale: ResourceScale) {
title: "Daily Sum Of Dollar Coinbases",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinbases (Dollars)",
color: colors.dollars,
@@ -122,12 +110,9 @@ export function createPresets(scale: ResourceScale) {
title: "Yearly Sum Of Bitcoin Coinbases",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinbases (Bitcoin)",
color: colors.bitcoin,
@@ -144,12 +129,9 @@ export function createPresets(scale: ResourceScale) {
title: "Yearly Sum Of Dollar Coinbases",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinbases (Dollars)",
color: colors.dollars,
@@ -174,12 +156,9 @@ export function createPresets(scale: ResourceScale) {
title: "Cumulative Bitcoin Coinbases",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinbases (Bitcoin)",
color: colors.bitcoin,
@@ -197,12 +176,9 @@ export function createPresets(scale: ResourceScale) {
title: "Cumulative Dollar Coinbases",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Coinbases (Dollars)",
color: colors.dollars,
@@ -236,12 +212,10 @@ export function createPresets(scale: ResourceScale) {
title: "Last Subsidy (In Bitcoin)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Last",
color: colors.bitcoin,
@@ -258,12 +232,9 @@ export function createPresets(scale: ResourceScale) {
title: "Last Subsidy (In Dollars)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Last",
color: colors.dollars,
@@ -287,12 +258,9 @@ export function createPresets(scale: ResourceScale) {
title: "Daily Sum Of Bitcoin Subsidies",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Subsidies (Bitcoin)",
color: colors.bitcoin,
@@ -309,12 +277,9 @@ export function createPresets(scale: ResourceScale) {
title: "Daily Sum Of Dollar Subsidies",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Subsidies (Dollars)",
color: colors.dollars,
@@ -338,12 +303,9 @@ export function createPresets(scale: ResourceScale) {
title: "Yearly Sum Of Bitcoin Subsidies",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Subsidies (Bitcoin)",
color: colors.bitcoin,
@@ -360,12 +322,9 @@ export function createPresets(scale: ResourceScale) {
title: "Yearly Sum Of Dollar Subsidies",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Subsidies (Dollars)",
color: colors.dollars,
@@ -390,12 +349,9 @@ export function createPresets(scale: ResourceScale) {
title: "Cumulative Bitcoin Subsidies",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Subsidies (Bitcoin)",
color: colors.bitcoin,
@@ -413,12 +369,9 @@ export function createPresets(scale: ResourceScale) {
title: "Cumulative Dollar Subsidies",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Subsidies (Dollars)",
color: colors.dollars,
@@ -452,12 +405,9 @@ export function createPresets(scale: ResourceScale) {
title: "Last Fees (In Bitcoin)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Last",
color: colors.bitcoin,
@@ -474,12 +424,9 @@ export function createPresets(scale: ResourceScale) {
title: "Last Fees (In Dollars)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Last",
color: colors.dollars,
@@ -503,12 +450,9 @@ export function createPresets(scale: ResourceScale) {
title: "Daily Sum Of Bitcoin Fees",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Fees (Bitcoin)",
color: colors.bitcoin,
@@ -525,12 +469,9 @@ export function createPresets(scale: ResourceScale) {
title: "Daily Sum Of Dollar Fees",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Fees (Dollars)",
color: colors.dollars,
@@ -553,12 +494,9 @@ export function createPresets(scale: ResourceScale) {
title: "Yearly Sum Of Bitcoin Fees",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Fees (Bitcoin)",
color: colors.bitcoin,
@@ -575,12 +513,9 @@ export function createPresets(scale: ResourceScale) {
title: "Yearly Sum Of Dollar Fees",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Fees (Dollars)",
color: colors.dollars,
@@ -604,12 +539,9 @@ export function createPresets(scale: ResourceScale) {
title: "Cumulative Bitcoin Fees",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Fees (Bitcoin)",
color: colors.bitcoin,
@@ -626,12 +558,9 @@ export function createPresets(scale: ResourceScale) {
title: "Cumulative Dollar Fees",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Fees (Dollars)",
color: colors.dollars,
@@ -657,12 +586,9 @@ export function createPresets(scale: ResourceScale) {
title: "Subsidy V. Fees",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Subsidy (%)",
color: colors.bitcoin,
@@ -687,13 +613,12 @@ export function createPresets(scale: ResourceScale) {
title: "Puell Multiple",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "Multiple",
color: colors.bitcoin,
@@ -711,13 +636,12 @@ export function createPresets(scale: ResourceScale) {
title: "Hash Rate (EH/s)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "1M SMA",
color: colors.momentumYellow,
@@ -745,13 +669,12 @@ export function createPresets(scale: ResourceScale) {
title: "Hash Ribbon (EH/s)",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "1M SMA",
color: colors.profit,
@@ -774,12 +697,9 @@ export function createPresets(scale: ResourceScale) {
title: "Hash Price",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Price ($/PH/s)",
color: colors.dollars,
@@ -799,13 +719,12 @@ export function createPresets(scale: ResourceScale) {
title: "Difficulty",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "Difficulty",
color: colors.bitcoin,
@@ -825,15 +744,11 @@ export function createPresets(scale: ResourceScale) {
title: "Difficulty Adjustment",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Adjustment (%)",
// color: colors.bitcoin,
seriesType: SeriesType.Based,
dataset: params.datasets[scale].difficulty_adjustment,
},
@@ -851,13 +766,12 @@ export function createPresets(scale: ResourceScale) {
title: "Annualized Issuance",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "Issuance",
color: colors.bitcoin,
@@ -875,13 +789,12 @@ export function createPresets(scale: ResourceScale) {
title: "Yearly Inflation Rate",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "Rate (%)",
color: colors.bitcoin,
+67 -151
View File
@@ -1,6 +1,6 @@
import { percentiles } from "../../datasets/consts/percentiles";
import { colors } from "../../utils/colors";
import { applyMultipleSeries, SeriesType } from "./multiple";
import { applySeriesList, SeriesType } from "../apply";
export function createCohortPresetFolder<Scale extends ResourceScale>({
scale,
@@ -54,12 +54,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Unspent Transaction Outputs Count`,
icon: () => IconTablerTicket,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Count",
color,
@@ -83,9 +80,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
description: "",
icon: () => IconTablerTag,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: [
top: [
{
title: "Realized Price",
color,
@@ -102,12 +99,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Realized Capitalization`,
icon: () => IconTablerPigMoney,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: `${name} Realized Cap.`,
color,
@@ -136,12 +130,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Realized Capitalization 1 Month Net Change`,
icon: () => IconTablerStatusChange,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: `Net Change`,
seriesType: SeriesType.Based,
@@ -161,12 +152,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Realized Profit`,
icon: () => IconTablerCash,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Realized Profit",
dataset:
@@ -185,12 +173,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Realized Loss`,
icon: () => IconTablerCoffin,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Realized Loss",
dataset:
@@ -209,12 +194,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Realized Profit And Loss`,
icon: () => IconTablerArrowsVertical,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Profit",
color: colors.profit,
@@ -242,12 +224,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Net Realized Profit And Loss`,
icon: () => IconTablerScale,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Net PNL",
seriesType: SeriesType.Based,
@@ -267,12 +246,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Net Realized Profit And Loss Relative To Market Capitalization`,
icon: () => IconTablerDivide,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Net",
seriesType: SeriesType.Based,
@@ -292,12 +268,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Cumulative Realized Profit`,
icon: () => IconTablerSum,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Cumulative Realized Profit",
color: colors.profit,
@@ -318,12 +291,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Cumulative Realized Loss`,
icon: () => IconTablerSum,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Cumulative Realized Loss",
color: colors.loss,
@@ -344,12 +314,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Cumulative Net Realized Profit And Loss`,
icon: () => IconTablerSum,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Cumulative Net Realized PNL",
seriesType: SeriesType.Based,
@@ -369,12 +336,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Cumulative Net Realized Profit And Loss 30 Day Change`,
icon: () => IconTablerTimeDuration30,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Cumulative Net Realized PNL 30d Change",
dataset:
@@ -399,12 +363,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Unrealized Profit`,
icon: () => IconTablerMoodDollar,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Profit",
dataset:
@@ -424,12 +385,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Unrealized Loss`,
icon: () => IconTablerMoodSadDizzy,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Loss",
dataset:
@@ -448,12 +406,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Unrealized Profit And Loss`,
icon: () => IconTablerArrowsVertical,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Profit",
color: colors.profit,
@@ -481,12 +436,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Net Unrealized Profit And Loss`,
icon: () => IconTablerScale,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Net Unrealized PNL",
dataset:
@@ -506,12 +458,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Net Unrealized Profit And Loss Relative To Total Market Capitalization`,
icon: () => IconTablerDivide,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Relative Net Unrealized PNL",
dataset:
@@ -540,12 +489,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
icon: () => IconTablerArrowsCross,
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "In Profit",
color: colors.profit,
@@ -587,12 +533,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
icon: () => IconTablerSum,
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Supply",
color,
@@ -609,12 +552,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Supply In Profit`,
icon: () => IconTablerTrendingUp,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Supply",
color: colors.profit,
@@ -635,12 +575,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Supply In Loss`,
icon: () => IconTablerTrendingDown,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Supply",
color: colors.loss,
@@ -667,12 +604,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
icon: () => IconTablerArrowsCross,
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "In Profit",
color: colors.profit,
@@ -718,12 +652,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Total supply Relative To Circulating Supply`,
icon: () => IconTablerSum,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Supply",
color,
@@ -744,12 +675,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Supply In Profit Relative To Circulating Supply`,
icon: () => IconTablerTrendingUp,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Supply",
color: colors.profit,
@@ -770,12 +698,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Supply In Loss Relative To Circulating Supply`,
icon: () => IconTablerTrendingDown,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Supply",
seriesType: SeriesType.Area,
@@ -801,14 +726,11 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Supply In Profit And Loss Relative To Own Supply`,
icon: () => IconTablerArrowsCross,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "In profit",
title: "In Profit",
dataset:
params.datasets[scale][
`${datasetPrefix}supply_in_profit_to_own_supply_ratio`
@@ -816,7 +738,7 @@ export function createCohortPresetList<Scale extends ResourceScale>({
color: colors.profit,
},
{
title: "In loss",
title: "In Loss",
color: colors.loss,
dataset:
params.datasets[scale][
@@ -851,12 +773,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Supply In Profit Relative To Own Supply`,
icon: () => IconTablerTrendingUp,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Supply",
color: colors.profit,
@@ -877,12 +796,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Supply In Loss Relative To Own Supply`,
icon: () => IconTablerTrendingDown,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Supply",
seriesType: SeriesType.Area,
@@ -917,9 +833,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} Average Price Paid - Realized Price`,
icon: () => IconTablerMathAvg,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: [
top: [
{
title: "Average",
color,
@@ -937,9 +853,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} deciles`,
icon: () => IconTablerSquareHalf,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: percentiles
top: percentiles
.filter(({ value }) => Number(value) % 10 === 0)
.map(({ name, key }) => ({
dataset: params.datasets[scale][`${datasetPrefix}${key}`],
@@ -957,9 +873,9 @@ export function createCohortPresetList<Scale extends ResourceScale>({
title: `${title} ${percentile.title}`,
icon: () => IconTablerSquareHalf,
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
list: [
top: [
{
title: percentile.name,
color,
@@ -1,183 +0,0 @@
import { applyPriceSeries } from "../../lightweightCharts/chart/price";
import { chartState } from "../../lightweightCharts/chart/state";
import { setTimeScale } from "../../lightweightCharts/chart/time";
import { createAreaSeries } from "../../lightweightCharts/series/creators/area";
import {
createBaseLineSeries,
DEFAULT_BASELINE_COLORS,
} from "../../lightweightCharts/series/creators/baseLine";
import { createHistogramSeries } from "../../lightweightCharts/series/creators/histogram";
import { createSeriesLegend } from "../../lightweightCharts/series/creators/legend";
import { createLineSeries } from "../../lightweightCharts/series/creators/line";
import { resetRightPriceScale } from "../../lightweightCharts/series/options/priceScale";
import { stringToId } from "../../utils/id";
export enum SeriesType {
Normal,
Based,
Area,
Histogram,
}
export function applyMultipleSeries<
Scale extends ResourceScale,
DS extends Dataset<Scale> & Partial<ResourceDataset<Scale>>,
>({
chart,
list = [],
preset,
priceScaleOptions,
datasets,
priceDataset,
priceOptions,
activeResources,
}: {
chart: IChartApi;
preset: Preset;
priceDataset?: DS;
priceOptions?: PriceSeriesOptions;
priceScaleOptions?: FullPriceScaleOptions;
list?: (
| {
dataset: DS;
color?: string;
colors?: undefined;
seriesType: SeriesType.Based;
title: string;
options?: BaselineSeriesOptions;
defaultVisible?: boolean;
}
| {
dataset: DS;
color?: string;
colors?: string[];
seriesType: SeriesType.Histogram;
title: string;
options?: DeepPartialHistogramOptions;
defaultVisible?: boolean;
}
| {
dataset: DS;
color: string;
colors?: undefined;
seriesType?: SeriesType.Normal | SeriesType.Area;
title: string;
options?: DeepPartialLineOptions;
defaultVisible?: boolean;
}
)[];
datasets: Datasets;
activeResources: Accessor<Set<ResourceDataset<any, any>>>;
}): PresetLegend {
const { halved } = priceScaleOptions || {};
const price = applyPriceSeries({
chart,
datasets,
preset,
dataset: priceDataset,
activeResources,
options: {
...priceOptions,
halved,
},
});
const legendList: PresetLegend = [price.lineLegend, price.ohlcLegend];
const isAnyArea = list.find(
(config) => config.seriesType === SeriesType.Area,
);
const rightPriceScaleOptions = resetRightPriceScale(chart, {
...priceScaleOptions,
...(isAnyArea
? {
scaleMargins: {
bottom: 0,
},
}
: {}),
});
[...list]
.reverse()
.forEach(
({
dataset,
color,
colors,
seriesType: type,
title,
options,
defaultVisible,
}) => {
let series: ISeriesApi<"Baseline" | "Line" | "Area" | "Histogram">;
if (type === SeriesType.Based) {
series = createBaseLineSeries(chart, {
color,
...options,
});
} else if (type === SeriesType.Area) {
series = createAreaSeries(chart, {
color,
autoscaleInfoProvider: (getInfo: () => AutoscaleInfo | null) => {
const info = getInfo();
if (info) {
info.priceRange.minValue = 0;
}
return info;
},
...options,
});
} else if (type === SeriesType.Histogram) {
series = createHistogramSeries(chart, {
color,
...options,
});
} else {
series = createLineSeries(chart, {
color,
...options,
});
}
legendList.splice(
0,
0,
createSeriesLegend({
id: stringToId(title),
presetId: preset.id,
title,
series,
color: () => colors || color || DEFAULT_BASELINE_COLORS,
defaultVisible,
url: dataset.url,
}),
);
createEffect(() => {
series.setData(dataset?.values() || []);
setTimeScale(chartState.range);
});
},
);
createEffect(() => {
const options = {
scaleMargins: {
top:
price.lineLegend.visible() || price.ohlcLegend.visible()
? rightPriceScaleOptions.scaleMargins.top
: rightPriceScaleOptions.scaleMargins.bottom,
bottom: rightPriceScaleOptions.scaleMargins.bottom,
},
};
chart.priceScale("right").applyOptions(options);
});
return legendList;
}
+15 -34
View File
@@ -1,5 +1,5 @@
import { colors } from "../../utils/colors";
import { applyMultipleSeries } from "../templates/multiple";
import { applySeriesList } from "../apply";
export function createPresets(scale: ResourceScale) {
return {
@@ -12,12 +12,9 @@ export function createPresets(scale: ResourceScale) {
title: "Transaction Count",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "1M SMA",
color: colors.momentumYellow,
@@ -48,12 +45,9 @@ export function createPresets(scale: ResourceScale) {
title: "Transaction Volume",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "1M SMA",
color: colors.momentumYellow,
@@ -80,13 +74,12 @@ export function createPresets(scale: ResourceScale) {
title: "Transaction Volume In Dollars",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
mode: 1,
},
list: [
bottom: [
{
title: "1M SMA",
color: colors.lightDollars,
@@ -124,12 +117,9 @@ export function createPresets(scale: ResourceScale) {
title: "Annualized Transaction Volume",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Volume",
color: colors.bitcoin,
@@ -147,12 +137,9 @@ export function createPresets(scale: ResourceScale) {
title: "Annualized Transaction Volume In Dollars",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Volume",
color: colors.dollars,
@@ -173,12 +160,9 @@ export function createPresets(scale: ResourceScale) {
title: "Transactions Velocity",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "Transactions Velocity",
color: colors.bitcoin,
@@ -195,12 +179,9 @@ export function createPresets(scale: ResourceScale) {
title: "Transactions Per Second",
description: "",
applyPreset(params) {
return applyMultipleSeries({
return applySeriesList({
...params,
priceScaleOptions: {
halved: true,
},
list: [
bottom: [
{
title: "1M SMA",
color: colors.lightBitcoin,
+4 -4
View File
@@ -20,13 +20,13 @@ type FilePath = {
}[];
type ApplyPreset = (params: {
chart: IChartApi;
charts: RWS<IChartApi[]>;
parentDiv: HTMLDivElement;
datasets: Datasets;
preset: Preset;
activeResources: Accessor<Set<ResourceDataset<any, any>>>;
}) => ApplyPresetReturn;
type ApplyPresetReturn = PresetLegend;
legendSetter: Setter<PresetLegend>;
}) => void;
interface PartialPresetFolder {
name: string;