mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-01 01:50:00 -07:00
release: v0.1.1
This commit is contained in:
@@ -1,30 +1,35 @@
|
||||
import groupedKeysToPath from "/src/../../datasets/grouped_keys_to_url_path.json";
|
||||
|
||||
import { createResourceDataset } from "./resource";
|
||||
|
||||
export { averages } from "./consts/averages";
|
||||
|
||||
export function createDateDatasets({
|
||||
setActiveResources,
|
||||
groupedKeysToURLPath,
|
||||
}: {
|
||||
setActiveResources: Setter<Set<ResourceDataset<any, any>>>;
|
||||
groupedKeysToURLPath: GroupedKeysToURLPath["date"];
|
||||
}) {
|
||||
type Key = keyof typeof groupedKeysToPath.date;
|
||||
type Key = keyof typeof groupedKeysToURLPath;
|
||||
type ResourceData = ReturnType<typeof createResourceDataset<"date">>;
|
||||
|
||||
const resourceDatasets = {} as Record<Exclude<Key, "ohlc">, ResourceData>;
|
||||
type ResourceDatasets = Record<Exclude<Key, "ohlc">, ResourceData>;
|
||||
|
||||
Object.entries(groupedKeysToPath.date).forEach(([_key, path]) => {
|
||||
for (const _key in groupedKeysToURLPath) {
|
||||
const key = _key as Key;
|
||||
|
||||
if (key !== "ohlc") {
|
||||
resourceDatasets[key] = createResourceDataset<"date">({
|
||||
scale: "date",
|
||||
path,
|
||||
setActiveResources,
|
||||
});
|
||||
const path = groupedKeysToURLPath[key];
|
||||
|
||||
(groupedKeysToURLPath as any as ResourceDatasets)[key] =
|
||||
createResourceDataset<"date">({
|
||||
scale: "date",
|
||||
path,
|
||||
setActiveResources,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const resourceDatasets = groupedKeysToURLPath as any as ResourceDatasets;
|
||||
|
||||
const price = createResourceDataset<"date", OHLC>({
|
||||
scale: "date",
|
||||
|
||||
@@ -1,27 +1,33 @@
|
||||
import groupedKeysToPath from "/src/../../datasets/grouped_keys_to_url_path.json";
|
||||
|
||||
import { createResourceDataset } from "./resource";
|
||||
|
||||
export function createHeightDatasets({
|
||||
setActiveResources,
|
||||
groupedKeysToURLPath,
|
||||
}: {
|
||||
setActiveResources: Setter<Set<ResourceDataset<any, any>>>;
|
||||
groupedKeysToURLPath: GroupedKeysToURLPath["height"];
|
||||
}) {
|
||||
type Key = keyof typeof groupedKeysToPath.height;
|
||||
type Key = keyof typeof groupedKeysToURLPath;
|
||||
type ResourceData = ReturnType<typeof createResourceDataset<"height">>;
|
||||
|
||||
const resourceDatasets = {} as Record<Exclude<Key, "ohlc">, ResourceData>;
|
||||
type ResourceDatasets = Record<Exclude<Key, "ohlc">, ResourceData>;
|
||||
|
||||
Object.keys(groupedKeysToPath.height).forEach(([_key, path]) => {
|
||||
for (const _key in groupedKeysToURLPath) {
|
||||
const key = _key as Key;
|
||||
|
||||
if (key !== "ohlc") {
|
||||
resourceDatasets[key] = createResourceDataset<"height">({
|
||||
scale: "height",
|
||||
path,
|
||||
setActiveResources,
|
||||
});
|
||||
const path = groupedKeysToURLPath[key];
|
||||
|
||||
(groupedKeysToURLPath as any as ResourceDatasets)[key] =
|
||||
createResourceDataset<"height">({
|
||||
scale: "height",
|
||||
path,
|
||||
setActiveResources,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const resourceDatasets = groupedKeysToURLPath as any as ResourceDatasets;
|
||||
|
||||
const price = createResourceDataset<"height", OHLC>({
|
||||
scale: "height",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import groupedKeysToURLPath from "/src/../../datasets/grouped_keys_to_url_path.json";
|
||||
|
||||
import { createDateDatasets } from "./date";
|
||||
import { createHeightDatasets } from "./height";
|
||||
|
||||
@@ -10,8 +12,18 @@ export function createDatasets({
|
||||
}: {
|
||||
setActiveResources: Setter<Set<ResourceDataset<any, any>>>;
|
||||
}) {
|
||||
const date = createDateDatasets({
|
||||
setActiveResources,
|
||||
groupedKeysToURLPath: groupedKeysToURLPath.date,
|
||||
});
|
||||
|
||||
const height = createHeightDatasets({
|
||||
setActiveResources,
|
||||
groupedKeysToURLPath: groupedKeysToURLPath.height,
|
||||
});
|
||||
|
||||
return {
|
||||
date: createDateDatasets({ setActiveResources }),
|
||||
height: createHeightDatasets({ setActiveResources }),
|
||||
date,
|
||||
height,
|
||||
} satisfies Record<ResourceScale, any>;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,10 @@ export function createResourceDataset<
|
||||
setActiveResources: Setter<Set<ResourceDataset<any, any>>>;
|
||||
}) {
|
||||
const baseURL = `${
|
||||
location.hostname === "localhost"
|
||||
? "http://localhost:3110"
|
||||
: "https://api.satonomics.xyz"
|
||||
// location.hostname === "localhost"
|
||||
// ? "http://localhost:3110"
|
||||
// : "https://api.satonomics.xyz"
|
||||
"https://api.satonomics.xyz"
|
||||
}${path}`;
|
||||
|
||||
type Dataset = Scale extends "date"
|
||||
@@ -36,8 +37,8 @@ export function createResourceDataset<
|
||||
>;
|
||||
|
||||
const fetchedJSONs = new Array(
|
||||
(new Date().getFullYear() - new Date("2009-01-01").getFullYear()) *
|
||||
(scale === "date" ? 2 : 8),
|
||||
(new Date().getFullYear() - new Date("2009-01-01").getFullYear() + 2) *
|
||||
(scale === "date" ? 1 : 6),
|
||||
)
|
||||
.fill(null)
|
||||
.map((): FetchedResult<Scale, Type> => {
|
||||
|
||||
3
app/src/scripts/datasets/types.d.ts
vendored
3
app/src/scripts/datasets/types.d.ts
vendored
@@ -96,3 +96,6 @@ interface OHLC {
|
||||
low: number;
|
||||
close: number;
|
||||
}
|
||||
|
||||
type GroupedKeysToURLPath =
|
||||
typeof import("/src/../../datasets/grouped_keys_to_url_path.json");
|
||||
|
||||
Reference in New Issue
Block a user