mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-11 14:41:16 -07:00
kibo: move types around
This commit is contained in:
71
Cargo.lock
generated
71
Cargo.lock
generated
@@ -1117,9 +1117,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.1.0"
|
version = "1.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc"
|
checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"miniz_oxide 0.8.5",
|
"miniz_oxide 0.8.5",
|
||||||
@@ -1350,9 +1350,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hyper-util"
|
name = "hyper-util"
|
||||||
version = "0.1.10"
|
version = "0.1.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4"
|
checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@@ -1366,9 +1366,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iana-time-zone"
|
name = "iana-time-zone"
|
||||||
version = "0.1.62"
|
version = "0.1.63"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b2fd658b06e56721792c5df4475705b6cda790e9298d19d2f8af083457bcd127"
|
checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_system_properties",
|
"android_system_properties",
|
||||||
"core-foundation-sys",
|
"core-foundation-sys",
|
||||||
@@ -1504,10 +1504,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jobserver"
|
name = "jobserver"
|
||||||
version = "0.1.32"
|
version = "0.1.33"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
|
checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"getrandom 0.3.2",
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2492,9 +2493,9 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "1.0.3"
|
version = "1.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96"
|
checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"errno",
|
"errno",
|
||||||
@@ -3307,11 +3308,37 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows-core"
|
||||||
version = "0.52.0"
|
version = "0.61.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-implement",
|
||||||
|
"windows-interface",
|
||||||
|
"windows-link",
|
||||||
|
"windows-result",
|
||||||
|
"windows-strings",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-implement"
|
||||||
|
version = "0.60.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.100",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-interface"
|
||||||
|
version = "0.59.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.100",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3320,6 +3347,24 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38"
|
checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-result"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-strings"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ Heartfelt thanks go out to every donor on [Nostr](https://primal.net/p/npub1jagm
|
|||||||
|
|
||||||
If you'd like to have your own instance hosted for you please contact [hosting@bitcoinresearchkit.org](mailto:hosting@bitcoinresearchkit.org).
|
If you'd like to have your own instance hosted for you please contact [hosting@bitcoinresearchkit.org](mailto:hosting@bitcoinresearchkit.org).
|
||||||
|
|
||||||
- 2 separate servers (1 GB/s each) with different ISPs and Cloudflare integration for enhanced performance and optimal availability
|
- 2 separate dedicated servers (1 GB/s each) with different ISPs and Cloudflare integration for enhanced performance and optimal availability
|
||||||
- Direct communication for feature requests and support
|
- Direct communication for feature requests and support
|
||||||
- Updates delivered at your convenience
|
- Updates delivered at your convenience
|
||||||
- Optional subdomains: `*.bitcoinresearchkit.org`, `*.kibo.money` and `*.satonomics.xyz`
|
- Optional subdomains: `*.bitcoinresearchkit.org`, `*.kibo.money` and `*.satonomics.xyz`
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ pub struct Store<Key, Value> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CHECK_COLLISISONS: bool = true;
|
const CHECK_COLLISISONS: bool = true;
|
||||||
const FJALL_VERSION: Version = Version::TWO;
|
const MAJOR_FJALL_VERSION: Version = Version::TWO;
|
||||||
|
|
||||||
impl<K, V> Store<K, V>
|
impl<K, V> Store<K, V>
|
||||||
where
|
where
|
||||||
@@ -36,7 +36,7 @@ where
|
|||||||
<V as TryFrom<ByteView>>::Error: error::Error + Send + Sync + 'static,
|
<V as TryFrom<ByteView>>::Error: error::Error + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
pub fn import(path: &Path, version: Version) -> color_eyre::Result<Self> {
|
pub fn import(path: &Path, version: Version) -> color_eyre::Result<Self> {
|
||||||
let version = FJALL_VERSION + version;
|
let version = MAJOR_FJALL_VERSION + version;
|
||||||
|
|
||||||
let meta = StoreMeta::checked_open(path, version)?;
|
let meta = StoreMeta::checked_open(path, version)?;
|
||||||
|
|
||||||
@@ -92,6 +92,10 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove(&mut self, key: K) {
|
pub fn remove(&mut self, key: K) {
|
||||||
|
if self.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if !self.puts.is_empty() {
|
if !self.puts.is_empty() {
|
||||||
unreachable!("Shouldn't reach this");
|
unreachable!("Shouldn't reach this");
|
||||||
// self.puts.remove(&key);
|
// self.puts.remove(&key);
|
||||||
|
|||||||
@@ -46,6 +46,13 @@ impl Stores {
|
|||||||
vecs: &mut Vecs,
|
vecs: &mut Vecs,
|
||||||
starting_indexes: &Indexes,
|
starting_indexes: &Indexes,
|
||||||
) -> color_eyre::Result<()> {
|
) -> color_eyre::Result<()> {
|
||||||
|
if self.addresshash_to_addressindex.is_empty()
|
||||||
|
&& self.blockhash_prefix_to_height.is_empty()
|
||||||
|
&& self.txid_prefix_to_txindex.is_empty()
|
||||||
|
{
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
vecs.height_to_blockhash
|
vecs.height_to_blockhash
|
||||||
.iter_from(starting_indexes.height, |(_, blockhash, ..)| {
|
.iter_from(starting_indexes.height, |(_, blockhash, ..)| {
|
||||||
let blockhash_prefix = BlockHashPrefix::from(blockhash);
|
let blockhash_prefix = BlockHashPrefix::from(blockhash);
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ impl Server {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.on_body_chunk(())
|
.on_body_chunk(())
|
||||||
|
.on_failure(())
|
||||||
.on_eos(());
|
.on_eos(());
|
||||||
|
|
||||||
let router = Router::new()
|
let router = Router::new()
|
||||||
|
|||||||
@@ -200,6 +200,10 @@ where
|
|||||||
.to_usize()
|
.to_usize()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
if len == 0 {
|
||||||
|
return Err(Error::IndexTooHigh);
|
||||||
|
}
|
||||||
|
|
||||||
let from = from.map_or(0, |from| {
|
let from = from.map_or(0, |from| {
|
||||||
if from >= 0 {
|
if from >= 0 {
|
||||||
from as usize
|
from as usize
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,3 +0,0 @@
|
|||||||
URL + Version:
|
|
||||||
|
|
||||||
https://unpkg.com/browse/lightweight-charts@latest/
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
import { Signal } from "../solid-signals/types";
|
|
||||||
import { Accessor } from "../solid-signals/v0.2.4-treeshaked/types/signals";
|
|
||||||
import {
|
|
||||||
DeepPartial,
|
|
||||||
BaselineStyleOptions,
|
|
||||||
CandlestickStyleOptions,
|
|
||||||
LineStyleOptions,
|
|
||||||
SeriesOptionsCommon,
|
|
||||||
Time,
|
|
||||||
ISeriesApi,
|
|
||||||
BaselineData,
|
|
||||||
} from "./v5.0.5-treeshaked/types";
|
|
||||||
import { VecId } from "../../scripts/vecid-to-indexes";
|
|
||||||
|
|
||||||
interface BaseSeriesBlueprint {
|
|
||||||
title: string;
|
|
||||||
defaultActive?: boolean;
|
|
||||||
}
|
|
||||||
interface BaselineSeriesBlueprint extends BaseSeriesBlueprint {
|
|
||||||
type: "Baseline";
|
|
||||||
color?: Color;
|
|
||||||
options?: DeepPartial<BaselineStyleOptions & SeriesOptionsCommon>;
|
|
||||||
data?: Accessor<BaselineData<Time>[]>;
|
|
||||||
}
|
|
||||||
interface CandlestickSeriesBlueprint extends BaseSeriesBlueprint {
|
|
||||||
type: "Candlestick";
|
|
||||||
color?: Color;
|
|
||||||
options?: DeepPartial<CandlestickStyleOptions & SeriesOptionsCommon>;
|
|
||||||
data?: Accessor<CandlestickData[]>;
|
|
||||||
}
|
|
||||||
interface LineSeriesBlueprint extends BaseSeriesBlueprint {
|
|
||||||
type?: "Line";
|
|
||||||
color: Color;
|
|
||||||
options?: DeepPartial<LineStyleOptions & SeriesOptionsCommon>;
|
|
||||||
data?: Accessor<LineData<Time>[]>;
|
|
||||||
}
|
|
||||||
type AnySpecificSeriesBlueprint =
|
|
||||||
| BaselineSeriesBlueprint
|
|
||||||
| CandlestickSeriesBlueprint
|
|
||||||
| LineSeriesBlueprint;
|
|
||||||
|
|
||||||
type SeriesType = NonNullable<AnySpecificSeriesBlueprint["type"]>;
|
|
||||||
type PriceSeriesType = "Candlestick" | "Line";
|
|
||||||
|
|
||||||
type RemoveSeriesBlueprintFluff<Blueprint extends AnySpecificSeriesBlueprint> =
|
|
||||||
Omit<Blueprint, "type" | "title">;
|
|
||||||
|
|
||||||
type SplitSeriesBlueprint<> = {
|
|
||||||
key: VecId;
|
|
||||||
} & AnySpecificSeriesBlueprint;
|
|
||||||
|
|
||||||
type SingleSeriesBlueprint = AnySpecificSeriesBlueprint;
|
|
||||||
|
|
||||||
interface CreateBaseSeriesParameters extends BaseSeriesBlueprint {
|
|
||||||
id: string;
|
|
||||||
disabled?: Accessor<boolean>;
|
|
||||||
color?: Color;
|
|
||||||
}
|
|
||||||
interface BaseSeries {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
color: Color | Color[];
|
|
||||||
active: Signal<boolean>;
|
|
||||||
visible: Accessor<boolean>;
|
|
||||||
}
|
|
||||||
interface SingleSeries extends BaseSeries {
|
|
||||||
iseries: ISeriesApi<SeriesType>;
|
|
||||||
dataset: Accessor<(SingleValueData | CandlestickData)[] | null>;
|
|
||||||
}
|
|
||||||
interface SplitSeries extends BaseSeries {
|
|
||||||
chunks: Array<Accessor<ISeriesApi<SeriesType> | undefined>>;
|
|
||||||
// dataset: ResourceDataset<number>;
|
|
||||||
}
|
|
||||||
type AnySeries = SingleSeries | SplitSeries;
|
|
||||||
|
|
||||||
interface CreateSingleSeriesParameters {
|
|
||||||
blueprint: SingleSeriesBlueprint;
|
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CreateSplitSeriesParameters {
|
|
||||||
// dataset: ResourceDataset;
|
|
||||||
blueprint: SplitSeriesBlueprint;
|
|
||||||
id: string;
|
|
||||||
index: number;
|
|
||||||
disabled?: Accessor<boolean>;
|
|
||||||
}
|
|
||||||
|
|
||||||
type ChartPane = IChartApi & {
|
|
||||||
whitespace: ISeriesApi<"Line">;
|
|
||||||
hidden: () => boolean;
|
|
||||||
setHidden: (b: boolean) => void;
|
|
||||||
setInitialVisibleTimeRange: VoidFunction;
|
|
||||||
createSingleSeries: (a: CreateSingleSeriesParameters) => SingleSeries;
|
|
||||||
createSplitSeries: (a: CreateSplitSeriesParameters) => SplitSeries[];
|
|
||||||
anySeries: AnySeries[];
|
|
||||||
singleSeries: SingleSeries[];
|
|
||||||
splitSeries: SplitSeries[];
|
|
||||||
remove: VoidFunction;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface CreatePaneParameters {
|
|
||||||
options?: DeepPartial<ChartOptions>;
|
|
||||||
config?: SingleSeriesBlueprint[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Marker {
|
|
||||||
weight: number;
|
|
||||||
time: Time;
|
|
||||||
value: number;
|
|
||||||
seriesChunk: ISeriesApi<SeriesType>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HoveredLegend {
|
|
||||||
label: HTMLLabelElement;
|
|
||||||
series: AnySeries;
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,26 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
/** @import {IChartApi, ISeriesApi, SeriesDefinition} from './v5.0.5-treeshaked/types' */
|
/** @import {IChartApi, ISeriesApi, SeriesDefinition, SingleValueData as _SingleValueData, CandlestickData as _CandlestickData} from './v5.0.5-treeshaked/types' */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {[number, number, number, number]} OHLCTuple
|
||||||
|
*
|
||||||
|
* @typedef {Object} Valued
|
||||||
|
* @property {number} value
|
||||||
|
*
|
||||||
|
* @typedef {Object} Indexed
|
||||||
|
* @property {number} index
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @typedef {T & Valued & Indexed} ChartData<T>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {ChartData<_SingleValueData>} SingleValueData
|
||||||
|
* @typedef {ChartData<_CandlestickData>} CandlestickData
|
||||||
|
*/
|
||||||
|
|
||||||
export default import("./v5.0.5-treeshaked/script.js").then((lc) => {
|
export default import("./v5.0.5-treeshaked/script.js").then((lc) => {
|
||||||
const oklchToRGBA = createOklchToRGBA();
|
const oklchToRGBA = createOklchToRGBA();
|
||||||
@@ -752,6 +772,7 @@ function createPriceScaleSelectorIfNeeded({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const field = utils.dom.createHorizontalChoiceField({
|
const field = utils.dom.createHorizontalChoiceField({
|
||||||
title: unit,
|
title: unit,
|
||||||
selected: serializedValue(),
|
selected: serializedValue(),
|
||||||
@@ -759,6 +780,7 @@ function createPriceScaleSelectorIfNeeded({
|
|||||||
id: unit,
|
id: unit,
|
||||||
signals,
|
signals,
|
||||||
});
|
});
|
||||||
|
|
||||||
field.addEventListener("change", (event) => {
|
field.addEventListener("change", (event) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const value = event.target.value;
|
const value = event.target.value;
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
Compiled version of: https://github.com/solidjs/signals/commits/main/
|
|
||||||
|
|
||||||
Head:
|
|
||||||
- SHA: 4d75d3f84ce22b560988f3b27a5065c0fd2e69a8
|
|
||||||
- Date: Apr 17, 2024
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @import { Option, Weighted, Color, DatasetCandlestickData, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, SimulationOption, Valued, SingleValueData, CandlestickData, ChartData, OHLCTuple, Unit } from "./types/self"
|
* @import { Option, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, SimulationOption, Unit } from "./types/self"
|
||||||
* @import { Marker, CreatePaneParameters, HoveredLegend, ChartPane, SplitSeries, SingleSeries, CreateSplitSeriesParameters, LineSeriesBlueprint, CandlestickSeriesBlueprint, BaselineSeriesBlueprint, CreateBaseSeriesParameters, BaseSeries, RemoveSeriesBlueprintFluff, SplitSeriesBlueprint, AnySeries, PriceSeriesType } from "../packages/lightweight-charts/types";
|
* @import {Valued, SingleValueData, CandlestickData, ChartData, OHLCTuple} from "../packages/lightweight-charts/wrapper"
|
||||||
* @import * as _ from "../packages/ufuzzy/v1.0.14/types"
|
* @import * as _ from "../packages/ufuzzy/v1.0.14/types"
|
||||||
* @import { createChart as CreateClassicChart, LineStyleOptions, DeepPartial, ChartOptions, IChartApi, IHorzScaleBehavior, WhitespaceData, ISeriesApi, Time, LineData, LogicalRange, SeriesType, BaselineStyleOptions, SeriesOptionsCommon } from "../packages/lightweight-charts/v5.0.5-treeshaked/types"
|
* @import { createChart as CreateClassicChart, LineStyleOptions, DeepPartial, ChartOptions, IChartApi, IHorzScaleBehavior, WhitespaceData, ISeriesApi, Time, LineData, LogicalRange, SeriesType, BaselineStyleOptions, SeriesOptionsCommon } from "../packages/lightweight-charts/v5.0.5-treeshaked/types"
|
||||||
* @import { SignalOptions } from "../packages/solid-signals/v0.2.4-treeshaked/types/core/core"
|
* @import { SignalOptions } from "../packages/solid-signals/v0.2.4-treeshaked/types/core/core"
|
||||||
@@ -885,12 +885,12 @@ function createUtils() {
|
|||||||
return v ? Number(v) : null;
|
return v ? Number(v) : null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
date: {
|
optDate: {
|
||||||
/**
|
/**
|
||||||
* @param {Date} v
|
* @param {Date | null} date
|
||||||
*/
|
*/
|
||||||
serialize(v) {
|
serialize(date) {
|
||||||
return date.toString(v);
|
return date !== null ? date.toString() : "";
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @param {string} v
|
* @param {string} v
|
||||||
@@ -1609,6 +1609,8 @@ function createColors(dark, elements) {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @typedef {ReturnType<typeof createColors>} Colors
|
* @typedef {ReturnType<typeof createColors>} Colors
|
||||||
|
* @typedef {Colors["orange"]} Color
|
||||||
|
* @typedef {keyof Colors} ColorName
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1676,7 +1678,7 @@ function initWebSockets(signals, utils) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {(candle: DatasetCandlestickData) => void} callback
|
* @param {(candle: CandlestickData) => void} callback
|
||||||
* @param {number} interval
|
* @param {number} interval
|
||||||
*/
|
*/
|
||||||
function krakenCandleWebSocketCreator(callback, interval) {
|
function krakenCandleWebSocketCreator(callback, interval) {
|
||||||
@@ -1706,7 +1708,7 @@ function initWebSockets(signals, utils) {
|
|||||||
|
|
||||||
const dateStr = utils.date.toString(date);
|
const dateStr = utils.date.toString(date);
|
||||||
|
|
||||||
/** @type {DatasetCandlestickData} */
|
/** @type {CandlestickData} */
|
||||||
const candle = {
|
const candle = {
|
||||||
index: -1,
|
index: -1,
|
||||||
time: dateStr,
|
time: dateStr,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @import { CohortOption, CohortOptions, Color, DefaultCohortOption, DefaultCohortOptions, OptionsGroup, PartialChartOption, PartialOptionsGroup, PartialOptionsTree, RatioOption, RatioOptions, Unit } from "./types/self"
|
* @import { CohortOption, CohortOptions, Color, DefaultCohortOption, DefaultCohortOptions, OptionsGroup, PartialChartOption, PartialOptionsGroup, PartialOptionsTree, RatioOption, RatioOptions, Unit } from "./types/self"
|
||||||
* @import {AnySpecificSeriesBlueprint, SplitSeriesBlueprint} from '../packages/lightweight-charts/types';
|
* @import { AnySeriesBlueprint} from '../packages/lightweight-charts/wrapper';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function initGroups() {
|
function initGroups() {
|
||||||
@@ -2815,7 +2815,7 @@ function createPartialOptions(colors) {
|
|||||||
// generateSeriesBlueprints(arg, blueprint) {
|
// generateSeriesBlueprints(arg, blueprint) {
|
||||||
// return this.toList(arg).map(
|
// return this.toList(arg).map(
|
||||||
// ({ scale, datasetId, color, name }) =>
|
// ({ scale, datasetId, color, name }) =>
|
||||||
// /** @satisfies {SplitSeriesBlueprint} */ ({
|
// /** @satisfies {AnySeriesBlueprint} */ ({
|
||||||
// title: cohortOptionOrOptions.toLegendName(
|
// title: cohortOptionOrOptions.toLegendName(
|
||||||
// arg,
|
// arg,
|
||||||
// name,
|
// name,
|
||||||
@@ -5159,7 +5159,7 @@ export function initOptions({
|
|||||||
const optionsIds = env.localhost ? [] : undefined;
|
const optionsIds = env.localhost ? [] : undefined;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @param {SplitSeriesBlueprint[]} array
|
// * @param {AnySeriesBlueprint[]} array
|
||||||
// */
|
// */
|
||||||
// function getMainIdFromBlueprints(array) {
|
// function getMainIdFromBlueprints(array) {
|
||||||
// const searchArray = array.filter(
|
// const searchArray = array.filter(
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
||||||
/**
|
/**
|
||||||
* @import { ColorName } from './types/self';
|
|
||||||
*
|
|
||||||
* @typedef {Object} Frequency
|
* @typedef {Object} Frequency
|
||||||
* @property {string} name
|
* @property {string} name
|
||||||
* @property {string} value
|
* @property {string} value
|
||||||
@@ -151,7 +149,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
initial: {
|
initial: {
|
||||||
amount: signals.createSignal(/** @type {number | null} */ (1000), {
|
amount: signals.createSignal(/** @type {number | null} */ (1000), {
|
||||||
save: {
|
save: {
|
||||||
...utils.serde.number,
|
...utils.serde.optNumber,
|
||||||
keyPrefix,
|
keyPrefix,
|
||||||
key: "initial-amount",
|
key: "initial-amount",
|
||||||
},
|
},
|
||||||
@@ -160,7 +158,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
topUp: {
|
topUp: {
|
||||||
amount: signals.createSignal(/** @type {number | null} */ (150), {
|
amount: signals.createSignal(/** @type {number | null} */ (150), {
|
||||||
save: {
|
save: {
|
||||||
...utils.serde.number,
|
...utils.serde.optNumber,
|
||||||
keyPrefix,
|
keyPrefix,
|
||||||
key: "top-up-amount",
|
key: "top-up-amount",
|
||||||
},
|
},
|
||||||
@@ -181,14 +179,14 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
investment: {
|
investment: {
|
||||||
initial: signals.createSignal(/** @type {number | null} */ (1000), {
|
initial: signals.createSignal(/** @type {number | null} */ (1000), {
|
||||||
save: {
|
save: {
|
||||||
...utils.serde.number,
|
...utils.serde.optNumber,
|
||||||
keyPrefix,
|
keyPrefix,
|
||||||
key: "initial-swap",
|
key: "initial-swap",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
recurrent: signals.createSignal(/** @type {number | null} */ (5), {
|
recurrent: signals.createSignal(/** @type {number | null} */ (5), {
|
||||||
save: {
|
save: {
|
||||||
...utils.serde.number,
|
...utils.serde.optNumber,
|
||||||
keyPrefix,
|
keyPrefix,
|
||||||
key: "recurrent-swap",
|
key: "recurrent-swap",
|
||||||
},
|
},
|
||||||
@@ -210,7 +208,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
/** @type {Date | null} */ (new Date("2021-04-15")),
|
/** @type {Date | null} */ (new Date("2021-04-15")),
|
||||||
{
|
{
|
||||||
save: {
|
save: {
|
||||||
...utils.serde.date,
|
...utils.serde.optDate,
|
||||||
keyPrefix,
|
keyPrefix,
|
||||||
key: "interval-start",
|
key: "interval-start",
|
||||||
},
|
},
|
||||||
@@ -218,7 +216,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
),
|
),
|
||||||
end: signals.createSignal(/** @type {Date | null} */ (new Date()), {
|
end: signals.createSignal(/** @type {Date | null} */ (new Date()), {
|
||||||
save: {
|
save: {
|
||||||
...utils.serde.date,
|
...utils.serde.optDate,
|
||||||
keyPrefix,
|
keyPrefix,
|
||||||
key: "interval-end",
|
key: "interval-end",
|
||||||
},
|
},
|
||||||
@@ -227,7 +225,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
fees: {
|
fees: {
|
||||||
percentage: signals.createSignal(/** @type {number | null} */ (0.25), {
|
percentage: signals.createSignal(/** @type {number | null} */ (0.25), {
|
||||||
save: {
|
save: {
|
||||||
...utils.serde.number,
|
...utils.serde.optNumber,
|
||||||
keyPrefix,
|
keyPrefix,
|
||||||
key: "percentage",
|
key: "percentage",
|
||||||
},
|
},
|
||||||
@@ -545,8 +543,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
signals,
|
signals,
|
||||||
colors,
|
colors,
|
||||||
id: `simulation-0`,
|
id: `simulation-0`,
|
||||||
kind: "static",
|
fitContentOnResize: true,
|
||||||
scale: "date",
|
|
||||||
utils,
|
utils,
|
||||||
config: [
|
config: [
|
||||||
{
|
{
|
||||||
@@ -586,8 +583,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
signals,
|
signals,
|
||||||
colors,
|
colors,
|
||||||
id: `simulation-1`,
|
id: `simulation-1`,
|
||||||
scale: "date",
|
fitContentOnResize: true,
|
||||||
kind: "static",
|
|
||||||
utils,
|
utils,
|
||||||
config: [
|
config: [
|
||||||
{
|
{
|
||||||
@@ -609,8 +605,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
signals,
|
signals,
|
||||||
colors,
|
colors,
|
||||||
id: `simulation-average-price`,
|
id: `simulation-average-price`,
|
||||||
scale: "date",
|
fitContentOnResize: true,
|
||||||
kind: "static",
|
|
||||||
utils,
|
utils,
|
||||||
config: [
|
config: [
|
||||||
{
|
{
|
||||||
@@ -638,8 +633,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
signals,
|
signals,
|
||||||
colors,
|
colors,
|
||||||
id: `simulation-return-ratio`,
|
id: `simulation-return-ratio`,
|
||||||
scale: "date",
|
fitContentOnResize: true,
|
||||||
kind: "static",
|
|
||||||
utils,
|
utils,
|
||||||
config: [
|
config: [
|
||||||
{
|
{
|
||||||
@@ -670,8 +664,7 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
signals,
|
signals,
|
||||||
colors,
|
colors,
|
||||||
id: `simulation-profitability-ratios`,
|
id: `simulation-profitability-ratios`,
|
||||||
kind: "static",
|
fitContentOnResize: true,
|
||||||
scale: "date",
|
|
||||||
utils,
|
utils,
|
||||||
owner,
|
owner,
|
||||||
config: [
|
config: [
|
||||||
@@ -939,36 +932,43 @@ export function init({ colors, elements, lightweightCharts, signals, utils }) {
|
|||||||
|
|
||||||
p3.innerHTML = `You would've been ${serProfitableDaysRatio} of the time profitable and ${serUnprofitableDaysRatio} of the time unprofitable.`;
|
p3.innerHTML = `You would've been ${serProfitableDaysRatio} of the time profitable and ${serUnprofitableDaysRatio} of the time unprofitable.`;
|
||||||
|
|
||||||
signals.createEffect(lastValues, (lastValues) => {
|
signals.createEffect(
|
||||||
const lowestAnnual4YReturn = 0.2368;
|
() => 0.2368,
|
||||||
// const lowestAnnual4YReturn = lastValues?.["price-4y-compound-return"] || 0
|
(lowestAnnual4YReturn) => {
|
||||||
const serLowestAnnual4YReturn = c(
|
const serLowestAnnual4YReturn = c(
|
||||||
"cyan",
|
"cyan",
|
||||||
`${fp(lowestAnnual4YReturn)}`,
|
`${fp(lowestAnnual4YReturn)}`,
|
||||||
);
|
|
||||||
|
|
||||||
const lowestAnnual4YReturnPercentage = 1 + lowestAnnual4YReturn;
|
|
||||||
/**
|
|
||||||
* @param {number} power
|
|
||||||
*/
|
|
||||||
function bitcoinValueReturn(power) {
|
|
||||||
return (
|
|
||||||
bitcoinValue * Math.pow(lowestAnnual4YReturnPercentage, power)
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
const bitcoinValueAfter4y = bitcoinValueReturn(4);
|
|
||||||
const serBitcoinValueAfter4y = c("purple", fd(bitcoinValueAfter4y));
|
|
||||||
const bitcoinValueAfter10y = bitcoinValueReturn(10);
|
|
||||||
const serBitcoinValueAfter10y = c(
|
|
||||||
"fuchsia",
|
|
||||||
fd(bitcoinValueAfter10y),
|
|
||||||
);
|
|
||||||
const bitcoinValueAfter21y = bitcoinValueReturn(21);
|
|
||||||
const serBitcoinValueAfter21y = c("pink", fd(bitcoinValueAfter21y));
|
|
||||||
|
|
||||||
/** @param {number} v */
|
const lowestAnnual4YReturnPercentage = 1 + lowestAnnual4YReturn;
|
||||||
p4.innerHTML = `The lowest annual return after 4 years has historically been ${serLowestAnnual4YReturn}.<br/>Using it as the baseline, your Bitcoin would be worth ${serBitcoinValueAfter4y} after 4 years, ${serBitcoinValueAfter10y} after 10 years and ${serBitcoinValueAfter21y} after 21 years.`;
|
/**
|
||||||
});
|
* @param {number} power
|
||||||
|
*/
|
||||||
|
function bitcoinValueReturn(power) {
|
||||||
|
return (
|
||||||
|
bitcoinValue * Math.pow(lowestAnnual4YReturnPercentage, power)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const bitcoinValueAfter4y = bitcoinValueReturn(4);
|
||||||
|
const serBitcoinValueAfter4y = c(
|
||||||
|
"purple",
|
||||||
|
fd(bitcoinValueAfter4y),
|
||||||
|
);
|
||||||
|
const bitcoinValueAfter10y = bitcoinValueReturn(10);
|
||||||
|
const serBitcoinValueAfter10y = c(
|
||||||
|
"fuchsia",
|
||||||
|
fd(bitcoinValueAfter10y),
|
||||||
|
);
|
||||||
|
const bitcoinValueAfter21y = bitcoinValueReturn(21);
|
||||||
|
const serBitcoinValueAfter21y = c(
|
||||||
|
"pink",
|
||||||
|
fd(bitcoinValueAfter21y),
|
||||||
|
);
|
||||||
|
|
||||||
|
/** @param {number} v */
|
||||||
|
p4.innerHTML = `The lowest annual return after 4 years has historically been ${serLowestAnnual4YReturn}.<br/>Using it as the baseline, your Bitcoin would be worth ${serBitcoinValueAfter4y} after 4 years, ${serBitcoinValueAfter10y} after 10 years and ${serBitcoinValueAfter21y} after 21 years.`;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
totalInvestedAmountData.set((a) => a);
|
totalInvestedAmountData.set((a) => a);
|
||||||
bitcoinValueData.set((a) => a);
|
bitcoinValueData.set((a) => a);
|
||||||
|
|||||||
79
websites/kibo.money/scripts/types/self.d.ts
vendored
79
websites/kibo.money/scripts/types/self.d.ts
vendored
@@ -1,28 +1,17 @@
|
|||||||
import {
|
import { Accessor } from "../../packages/solid-signals/v0.2.4-treeshaked/types/signals";
|
||||||
Accessor,
|
|
||||||
Setter,
|
|
||||||
} from "../../packages/solid-signals/v0.2.4-treeshaked/types/signals";
|
|
||||||
import {
|
import {
|
||||||
DeepPartial,
|
DeepPartial,
|
||||||
BaselineStyleOptions,
|
BaselineStyleOptions,
|
||||||
CandlestickStyleOptions,
|
CandlestickStyleOptions,
|
||||||
LineStyleOptions,
|
LineStyleOptions,
|
||||||
SeriesOptionsCommon,
|
SeriesOptionsCommon,
|
||||||
IRange,
|
|
||||||
Time,
|
Time,
|
||||||
SingleValueData as _SingleValueData,
|
SingleValueData as _SingleValueData,
|
||||||
CandlestickData as _CandlestickData,
|
CandlestickData as _CandlestickData,
|
||||||
SeriesType,
|
|
||||||
ISeriesApi,
|
|
||||||
BaselineData,
|
BaselineData,
|
||||||
} from "../../packages/lightweight-charts/v5.0.5-treeshaked/types";
|
} from "../../packages/lightweight-charts/v5.0.5-treeshaked/types";
|
||||||
import { AnyPossibleCohortId, Groups } from "../options";
|
import { AnyPossibleCohortId } from "../options";
|
||||||
|
|
||||||
type Color = () => string;
|
|
||||||
type ColorName = keyof Colors;
|
|
||||||
|
|
||||||
// TODO: Compute from VecId when displaying the Unit
|
|
||||||
// And write a checker when localhost, similar to the dup one
|
|
||||||
type Unit =
|
type Unit =
|
||||||
| ""
|
| ""
|
||||||
| "Bitcoin"
|
| "Bitcoin"
|
||||||
@@ -47,11 +36,39 @@ interface PartialOption {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface BaseSeriesBlueprint {
|
||||||
|
title: string;
|
||||||
|
key: VecId;
|
||||||
|
defaultActive?: boolean;
|
||||||
|
}
|
||||||
|
interface BaselineSeriesBlueprint extends BaseSeriesBlueprint {
|
||||||
|
type: "Baseline";
|
||||||
|
color?: Color;
|
||||||
|
options?: DeepPartial<BaselineStyleOptions & SeriesOptionsCommon>;
|
||||||
|
data?: Accessor<BaselineData<Time>[]>;
|
||||||
|
}
|
||||||
|
interface CandlestickSeriesBlueprint extends BaseSeriesBlueprint {
|
||||||
|
type: "Candlestick";
|
||||||
|
color?: Color;
|
||||||
|
options?: DeepPartial<CandlestickStyleOptions & SeriesOptionsCommon>;
|
||||||
|
data?: Accessor<CandlestickData[]>;
|
||||||
|
}
|
||||||
|
interface LineSeriesBlueprint extends BaseSeriesBlueprint {
|
||||||
|
type?: "Line";
|
||||||
|
color: Color;
|
||||||
|
options?: DeepPartial<LineStyleOptions & SeriesOptionsCommon>;
|
||||||
|
data?: Accessor<LineData<Time>[]>;
|
||||||
|
}
|
||||||
|
type AnySeriesBlueprint =
|
||||||
|
| BaselineSeriesBlueprint
|
||||||
|
| CandlestickSeriesBlueprint
|
||||||
|
| LineSeriesBlueprint;
|
||||||
|
|
||||||
interface PartialChartOption extends PartialOption {
|
interface PartialChartOption extends PartialOption {
|
||||||
title?: string;
|
title?: string;
|
||||||
unit?: Unit;
|
unit?: Unit;
|
||||||
top?: SplitSeriesBlueprint[];
|
top?: AnySeriesBlueprint[];
|
||||||
bottom?: SplitSeriesBlueprint[];
|
bottom?: AnySeriesBlueprint[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PartialSimulationOption extends PartialOption {
|
interface PartialSimulationOption extends PartialOption {
|
||||||
@@ -105,34 +122,6 @@ interface OptionsGroup extends PartialOptionsGroup {
|
|||||||
tree: OptionsTree;
|
tree: OptionsTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
type OHLCTuple = [number, number, number, number];
|
|
||||||
|
|
||||||
interface Valued {
|
|
||||||
value: number;
|
|
||||||
}
|
|
||||||
interface Indexed {
|
|
||||||
index: number;
|
|
||||||
}
|
|
||||||
type ChartData<T> = T & Valued & Indexed;
|
|
||||||
type SingleValueData = ChartData<_SingleValueData>;
|
|
||||||
type CandlestickData = ChartData<_CandlestickData>;
|
|
||||||
|
|
||||||
type FetchedSource = string;
|
|
||||||
|
|
||||||
interface FetchedChunk {
|
|
||||||
id: number;
|
|
||||||
previous: string | null;
|
|
||||||
next: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Weighted {
|
|
||||||
weight: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
type DatasetCandlestickData = ChartData<CandlestickData>;
|
|
||||||
|
|
||||||
// type NotFunction<T> = T extends Function ? never : T;
|
|
||||||
|
|
||||||
type DefaultCohortOption = CohortOption<AnyPossibleCohortId>;
|
type DefaultCohortOption = CohortOption<AnyPossibleCohortId>;
|
||||||
|
|
||||||
interface CohortOption<Id extends AnyPossibleCohortId> {
|
interface CohortOption<Id extends AnyPossibleCohortId> {
|
||||||
@@ -162,7 +151,3 @@ interface RatioOptions {
|
|||||||
title: string;
|
title: string;
|
||||||
list: RatioOption[];
|
list: RatioOption[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove
|
|
||||||
// Fetch last of each individually when in viewport
|
|
||||||
// type LastValues = Record<LastPath, number> | null;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user