mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-14 04:28:11 -07:00
general: snapshot
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
import { createResourceDataset } from "./resource";
|
||||
|
||||
export { averages } from "./consts/averages";
|
||||
|
||||
export function createScaleDatasets<Scale extends ResourceScale>({
|
||||
scale,
|
||||
groupedKeysToURLPath,
|
||||
}: {
|
||||
scale: Scale;
|
||||
groupedKeysToURLPath: GroupedKeysToURLPath[Scale];
|
||||
}) {
|
||||
type Key = keyof typeof groupedKeysToURLPath;
|
||||
type ResourceData = ReturnType<typeof createResourceDataset<Scale>>;
|
||||
|
||||
type ResourceDatasets = Record<Exclude<Key, "price">, ResourceData>;
|
||||
|
||||
const datasets = groupedKeysToURLPath as any as ResourceDatasets;
|
||||
|
||||
for (const key in groupedKeysToURLPath) {
|
||||
if ((key as Key) !== "price") {
|
||||
datasets[key as unknown as Exclude<Key, "price">] = createResourceDataset(
|
||||
{
|
||||
scale,
|
||||
path: groupedKeysToURLPath[key as Key] as any,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const price = createResourceDataset<Scale, OHLC>({
|
||||
scale,
|
||||
path: `/${scale}-to-price`,
|
||||
});
|
||||
|
||||
Object.assign(datasets, { price });
|
||||
|
||||
return datasets;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { createResourceDataset } from "./resource";
|
||||
|
||||
export { averages } from "./consts/averages";
|
||||
|
||||
export function createDateDatasets({
|
||||
groupedKeysToURLPath,
|
||||
}: {
|
||||
groupedKeysToURLPath: GroupedKeysToURLPath["date"];
|
||||
}) {
|
||||
type Key = keyof typeof groupedKeysToURLPath;
|
||||
type ResourceData = ReturnType<typeof createResourceDataset<"date">>;
|
||||
|
||||
type ResourceDatasets = Record<Exclude<Key, "price">, ResourceData>;
|
||||
|
||||
const datasets = groupedKeysToURLPath as any as ResourceDatasets;
|
||||
|
||||
for (const key in groupedKeysToURLPath) {
|
||||
if ((key as Key) !== "price") {
|
||||
datasets[key as Exclude<Key, "price">] = createResourceDataset<"date">({
|
||||
scale: "date",
|
||||
path: groupedKeysToURLPath[key as Key],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const price = createResourceDataset<"date", OHLC>({
|
||||
scale: "date",
|
||||
path: "/date-to-price",
|
||||
});
|
||||
|
||||
Object.assign(datasets, { price });
|
||||
|
||||
return datasets as ResourceDatasets & {
|
||||
price: ResourceDataset<"date", OHLC>;
|
||||
};
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
import { createResourceDataset } from "./resource";
|
||||
|
||||
export function createHeightDatasets({
|
||||
groupedKeysToURLPath,
|
||||
}: {
|
||||
groupedKeysToURLPath: GroupedKeysToURLPath["height"];
|
||||
}) {
|
||||
type Key = keyof typeof groupedKeysToURLPath;
|
||||
type ResourceData = ReturnType<typeof createResourceDataset<"height">>;
|
||||
|
||||
type ResourceDatasets = Record<Exclude<Key, "price">, ResourceData>;
|
||||
|
||||
const datasets = groupedKeysToURLPath as any as ResourceDatasets;
|
||||
|
||||
for (const key in groupedKeysToURLPath) {
|
||||
if ((key as Key) !== "price") {
|
||||
datasets[key as Exclude<Key, "price">] = createResourceDataset<"height">({
|
||||
scale: "height",
|
||||
path: groupedKeysToURLPath[key as Key],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const price = createResourceDataset<"height", OHLC>({
|
||||
scale: "height",
|
||||
path: "/height-to-price",
|
||||
});
|
||||
|
||||
Object.assign(datasets, { price });
|
||||
|
||||
return datasets as ResourceDatasets & {
|
||||
price: ResourceDataset<"height", OHLC>;
|
||||
};
|
||||
}
|
||||
@@ -5,8 +5,8 @@ export const scales = ["date" as const, "height" as const];
|
||||
export const HEIGHT_CHUNK_SIZE = 10_000;
|
||||
|
||||
export function createDatasets() {
|
||||
const date = new Map<DateDatasetPath, ResourceDataset<"date">>();
|
||||
const height = new Map<HeightDatasetPath, ResourceDataset<"height">>();
|
||||
const date = new Map<DatePath, ResourceDataset<"date">>();
|
||||
const height = new Map<HeightPath, ResourceDataset<"height">>();
|
||||
|
||||
function getOrImport<Scale extends ResourceScale>(
|
||||
scale: Scale,
|
||||
|
||||
Vendored
+3
-12
@@ -68,17 +68,8 @@ interface OHLC {
|
||||
close: number;
|
||||
}
|
||||
|
||||
type GroupedKeysToURLPath =
|
||||
typeof import("/src/../../datasets/grouped_keys_to_url_path.json");
|
||||
|
||||
type DateDatasetPath = import("/src/../../datasets/paths").DatePath;
|
||||
|
||||
type HeightDatasetPath = import("/src/../../datasets/paths").HeightPath;
|
||||
|
||||
type LastDataPath = import("/src/../../datasets/paths").LastPath;
|
||||
|
||||
type DatasetPath<Scale extends ResourceScale> = Scale extends "date"
|
||||
? DateDatasetPath
|
||||
: HeightDatasetPath;
|
||||
? DatePath
|
||||
: HeightPath;
|
||||
|
||||
type AnyDatasetPath = DateDatasetPath | HeightDatasetPath;
|
||||
type AnyDatasetPath = DatePath | HeightPath;
|
||||
|
||||
@@ -18,7 +18,7 @@ export function createPresets(scale: ResourceScale) {
|
||||
title: `Hodl Supply`,
|
||||
description: "",
|
||||
icon: IconTablerRipple,
|
||||
unit: "Bitcoin",
|
||||
unit: "Percentage",
|
||||
bottom: [
|
||||
{
|
||||
title: `24h`,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { averages } from "/src/scripts/datasets/date";
|
||||
import { averages } from "/src/scripts/datasets/consts/averages";
|
||||
import { colors } from "/src/scripts/utils/colors";
|
||||
|
||||
import { createRatioFolder } from "../../templates/ratio";
|
||||
|
||||
Reference in New Issue
Block a user