brk-client 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +385 -248
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -838,15 +838,120 @@ class BrkError extends Error {
|
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
840
|
|
|
841
|
+
// Date conversion constants and helpers
|
|
842
|
+
const _GENESIS = new Date(2009, 0, 3); // dateindex 0, weekindex 0
|
|
843
|
+
const _DAY_ONE = new Date(2009, 0, 9); // dateindex 1 (6 day gap after genesis)
|
|
844
|
+
const _MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
845
|
+
const _MS_PER_WEEK = 7 * _MS_PER_DAY;
|
|
846
|
+
const _DATE_INDEXES = new Set(['dateindex', 'weekindex', 'monthindex', 'yearindex', 'quarterindex', 'semesterindex', 'decadeindex']);
|
|
847
|
+
|
|
848
|
+
/** @param {number} months @returns {globalThis.Date} */
|
|
849
|
+
const _addMonths = (months) => new Date(2009, months, 1);
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Convert an index value to a Date for date-based indexes.
|
|
853
|
+
* @param {Index} index - The index type
|
|
854
|
+
* @param {number} i - The index value
|
|
855
|
+
* @returns {globalThis.Date}
|
|
856
|
+
*/
|
|
857
|
+
function indexToDate(index, i) {
|
|
858
|
+
switch (index) {
|
|
859
|
+
case 'dateindex': return i === 0 ? _GENESIS : new Date(_DAY_ONE.getTime() + (i - 1) * _MS_PER_DAY);
|
|
860
|
+
case 'weekindex': return new Date(_GENESIS.getTime() + i * _MS_PER_WEEK);
|
|
861
|
+
case 'monthindex': return _addMonths(i);
|
|
862
|
+
case 'yearindex': return new Date(2009 + i, 0, 1);
|
|
863
|
+
case 'quarterindex': return _addMonths(i * 3);
|
|
864
|
+
case 'semesterindex': return _addMonths(i * 6);
|
|
865
|
+
case 'decadeindex': return new Date(2009 + i * 10, 0, 1);
|
|
866
|
+
default: throw new Error(`${index} is not a date-based index`);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Check if an index type is date-based.
|
|
872
|
+
* @param {Index} index
|
|
873
|
+
* @returns {boolean}
|
|
874
|
+
*/
|
|
875
|
+
function isDateIndex(index) {
|
|
876
|
+
return _DATE_INDEXES.has(index);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Wrap raw metric data with helper methods.
|
|
881
|
+
* @template T
|
|
882
|
+
* @param {MetricData<T>} raw - Raw JSON response
|
|
883
|
+
* @returns {MetricData<T>}
|
|
884
|
+
*/
|
|
885
|
+
function _wrapMetricData(raw) {
|
|
886
|
+
const { index, start, end, data } = raw;
|
|
887
|
+
return /** @type {MetricData<T>} */ ({
|
|
888
|
+
...raw,
|
|
889
|
+
dates() {
|
|
890
|
+
/** @type {globalThis.Date[]} */
|
|
891
|
+
const result = [];
|
|
892
|
+
for (let i = start; i < end; i++) result.push(indexToDate(index, i));
|
|
893
|
+
return result;
|
|
894
|
+
},
|
|
895
|
+
indexes() {
|
|
896
|
+
/** @type {number[]} */
|
|
897
|
+
const result = [];
|
|
898
|
+
for (let i = start; i < end; i++) result.push(i);
|
|
899
|
+
return result;
|
|
900
|
+
},
|
|
901
|
+
toDateMap() {
|
|
902
|
+
/** @type {Map<globalThis.Date, T>} */
|
|
903
|
+
const map = new Map();
|
|
904
|
+
for (let i = 0; i < data.length; i++) map.set(indexToDate(index, start + i), data[i]);
|
|
905
|
+
return map;
|
|
906
|
+
},
|
|
907
|
+
toIndexMap() {
|
|
908
|
+
/** @type {Map<number, T>} */
|
|
909
|
+
const map = new Map();
|
|
910
|
+
for (let i = 0; i < data.length; i++) map.set(start + i, data[i]);
|
|
911
|
+
return map;
|
|
912
|
+
},
|
|
913
|
+
dateEntries() {
|
|
914
|
+
/** @type {Array<[globalThis.Date, T]>} */
|
|
915
|
+
const result = [];
|
|
916
|
+
for (let i = 0; i < data.length; i++) result.push([indexToDate(index, start + i), data[i]]);
|
|
917
|
+
return result;
|
|
918
|
+
},
|
|
919
|
+
indexEntries() {
|
|
920
|
+
/** @type {Array<[number, T]>} */
|
|
921
|
+
const result = [];
|
|
922
|
+
for (let i = 0; i < data.length; i++) result.push([start + i, data[i]]);
|
|
923
|
+
return result;
|
|
924
|
+
},
|
|
925
|
+
*iter() {
|
|
926
|
+
for (let i = 0; i < data.length; i++) yield [start + i, data[i]];
|
|
927
|
+
},
|
|
928
|
+
*iterDates() {
|
|
929
|
+
for (let i = 0; i < data.length; i++) yield [indexToDate(index, start + i), data[i]];
|
|
930
|
+
},
|
|
931
|
+
[Symbol.iterator]() {
|
|
932
|
+
return this.iter();
|
|
933
|
+
},
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
|
|
841
937
|
/**
|
|
842
938
|
* @template T
|
|
843
939
|
* @typedef {Object} MetricData
|
|
844
940
|
* @property {number} version - Version of the metric data
|
|
941
|
+
* @property {Index} index - The index type used for this query
|
|
845
942
|
* @property {number} total - Total number of data points
|
|
846
943
|
* @property {number} start - Start index (inclusive)
|
|
847
944
|
* @property {number} end - End index (exclusive)
|
|
848
945
|
* @property {string} stamp - ISO 8601 timestamp of when the response was generated
|
|
849
946
|
* @property {T[]} data - The metric data
|
|
947
|
+
* @property {() => globalThis.Date[]} dates - Convert index range to dates (date-based indexes only)
|
|
948
|
+
* @property {() => number[]} indexes - Get index range as array
|
|
949
|
+
* @property {() => Map<globalThis.Date, T>} toDateMap - Return data as Map keyed by date (date-based only)
|
|
950
|
+
* @property {() => Map<number, T>} toIndexMap - Return data as Map keyed by index
|
|
951
|
+
* @property {() => Array<[globalThis.Date, T]>} dateEntries - Return data as [date, value] pairs (date-based only)
|
|
952
|
+
* @property {() => Array<[number, T]>} indexEntries - Return data as [index, value] pairs
|
|
953
|
+
* @property {() => IterableIterator<[number, T]>} iter - Iterate over [index, value] pairs
|
|
954
|
+
* @property {() => IterableIterator<[globalThis.Date, T]>} iterDates - Iterate over [date, value] pairs (date-based only)
|
|
850
955
|
*/
|
|
851
956
|
/** @typedef {MetricData<any>} AnyMetricData */
|
|
852
957
|
|
|
@@ -940,18 +1045,18 @@ function _endpoint(client, name, index) {
|
|
|
940
1045
|
* @returns {RangeBuilder<T>}
|
|
941
1046
|
*/
|
|
942
1047
|
const rangeBuilder = (start, end) => ({
|
|
943
|
-
fetch(onUpdate) { return client.
|
|
1048
|
+
fetch(onUpdate) { return client._fetchMetricData(buildPath(start, end), onUpdate); },
|
|
944
1049
|
fetchCsv() { return client.getText(buildPath(start, end, 'csv')); },
|
|
945
1050
|
then(resolve, reject) { return this.fetch().then(resolve, reject); },
|
|
946
1051
|
});
|
|
947
1052
|
|
|
948
1053
|
/**
|
|
949
|
-
* @param {number}
|
|
1054
|
+
* @param {number} idx
|
|
950
1055
|
* @returns {SingleItemBuilder<T>}
|
|
951
1056
|
*/
|
|
952
|
-
const singleItemBuilder = (
|
|
953
|
-
fetch(onUpdate) { return client.
|
|
954
|
-
fetchCsv() { return client.getText(buildPath(
|
|
1057
|
+
const singleItemBuilder = (idx) => ({
|
|
1058
|
+
fetch(onUpdate) { return client._fetchMetricData(buildPath(idx, idx + 1), onUpdate); },
|
|
1059
|
+
fetchCsv() { return client.getText(buildPath(idx, idx + 1, 'csv')); },
|
|
955
1060
|
then(resolve, reject) { return this.fetch().then(resolve, reject); },
|
|
956
1061
|
});
|
|
957
1062
|
|
|
@@ -961,19 +1066,19 @@ function _endpoint(client, name, index) {
|
|
|
961
1066
|
*/
|
|
962
1067
|
const skippedBuilder = (start) => ({
|
|
963
1068
|
take(n) { return rangeBuilder(start, start + n); },
|
|
964
|
-
fetch(onUpdate) { return client.
|
|
1069
|
+
fetch(onUpdate) { return client._fetchMetricData(buildPath(start, undefined), onUpdate); },
|
|
965
1070
|
fetchCsv() { return client.getText(buildPath(start, undefined, 'csv')); },
|
|
966
1071
|
then(resolve, reject) { return this.fetch().then(resolve, reject); },
|
|
967
1072
|
});
|
|
968
1073
|
|
|
969
1074
|
/** @type {MetricEndpointBuilder<T>} */
|
|
970
1075
|
const endpoint = {
|
|
971
|
-
get(
|
|
1076
|
+
get(idx) { return singleItemBuilder(idx); },
|
|
972
1077
|
slice(start, end) { return rangeBuilder(start, end); },
|
|
973
1078
|
first(n) { return rangeBuilder(undefined, n); },
|
|
974
1079
|
last(n) { return n === 0 ? rangeBuilder(undefined, 0) : rangeBuilder(-n, undefined); },
|
|
975
1080
|
skip(n) { return skippedBuilder(n); },
|
|
976
|
-
fetch(onUpdate) { return client.
|
|
1081
|
+
fetch(onUpdate) { return client._fetchMetricData(buildPath(), onUpdate); },
|
|
977
1082
|
fetchCsv() { return client.getText(buildPath(undefined, undefined, 'csv')); },
|
|
978
1083
|
then(resolve, reject) { return this.fetch().then(resolve, reject); },
|
|
979
1084
|
get path() { return p; },
|
|
@@ -1053,6 +1158,19 @@ class BrkClientBase {
|
|
|
1053
1158
|
const res = await this.get(path);
|
|
1054
1159
|
return res.text();
|
|
1055
1160
|
}
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* Fetch metric data and wrap with helper methods (internal)
|
|
1164
|
+
* @template T
|
|
1165
|
+
* @param {string} path
|
|
1166
|
+
* @param {(value: MetricData<T>) => void} [onUpdate]
|
|
1167
|
+
* @returns {Promise<MetricData<T>>}
|
|
1168
|
+
*/
|
|
1169
|
+
async _fetchMetricData(path, onUpdate) {
|
|
1170
|
+
const wrappedOnUpdate = onUpdate ? (/** @type {MetricData<T>} */ raw) => onUpdate(_wrapMetricData(raw)) : undefined;
|
|
1171
|
+
const raw = await this.getJson(path, wrappedOnUpdate);
|
|
1172
|
+
return _wrapMetricData(raw);
|
|
1173
|
+
}
|
|
1056
1174
|
}
|
|
1057
1175
|
|
|
1058
1176
|
/**
|
|
@@ -1953,18 +2071,18 @@ function createPeriodDaysInLossPattern(client, acc) {
|
|
|
1953
2071
|
*/
|
|
1954
2072
|
function createClassDaysInLossPattern(client, acc) {
|
|
1955
2073
|
return {
|
|
1956
|
-
_2015: createMetricPattern4(client, _m(acc, '
|
|
1957
|
-
_2016: createMetricPattern4(client, _m(acc, '
|
|
1958
|
-
_2017: createMetricPattern4(client, _m(acc, '
|
|
1959
|
-
_2018: createMetricPattern4(client, _m(acc, '
|
|
1960
|
-
_2019: createMetricPattern4(client, _m(acc, '
|
|
1961
|
-
_2020: createMetricPattern4(client, _m(acc, '
|
|
1962
|
-
_2021: createMetricPattern4(client, _m(acc, '
|
|
1963
|
-
_2022: createMetricPattern4(client, _m(acc, '
|
|
1964
|
-
_2023: createMetricPattern4(client, _m(acc, '
|
|
1965
|
-
_2024: createMetricPattern4(client, _m(acc, '
|
|
1966
|
-
_2025: createMetricPattern4(client, _m(acc, '
|
|
1967
|
-
_2026: createMetricPattern4(client, _m(acc, '
|
|
2074
|
+
_2015: createMetricPattern4(client, _m(acc, '2015_returns')),
|
|
2075
|
+
_2016: createMetricPattern4(client, _m(acc, '2016_returns')),
|
|
2076
|
+
_2017: createMetricPattern4(client, _m(acc, '2017_returns')),
|
|
2077
|
+
_2018: createMetricPattern4(client, _m(acc, '2018_returns')),
|
|
2078
|
+
_2019: createMetricPattern4(client, _m(acc, '2019_returns')),
|
|
2079
|
+
_2020: createMetricPattern4(client, _m(acc, '2020_returns')),
|
|
2080
|
+
_2021: createMetricPattern4(client, _m(acc, '2021_returns')),
|
|
2081
|
+
_2022: createMetricPattern4(client, _m(acc, '2022_returns')),
|
|
2082
|
+
_2023: createMetricPattern4(client, _m(acc, '2023_returns')),
|
|
2083
|
+
_2024: createMetricPattern4(client, _m(acc, '2024_returns')),
|
|
2084
|
+
_2025: createMetricPattern4(client, _m(acc, '2025_returns')),
|
|
2085
|
+
_2026: createMetricPattern4(client, _m(acc, '2026_returns')),
|
|
1968
2086
|
};
|
|
1969
2087
|
}
|
|
1970
2088
|
|
|
@@ -2044,41 +2162,6 @@ function createDollarsPattern(client, acc) {
|
|
|
2044
2162
|
};
|
|
2045
2163
|
}
|
|
2046
2164
|
|
|
2047
|
-
/**
|
|
2048
|
-
* @typedef {Object} RelativePattern2
|
|
2049
|
-
* @property {MetricPattern1<StoredF32>} negUnrealizedLossRelToOwnMarketCap
|
|
2050
|
-
* @property {MetricPattern1<StoredF32>} negUnrealizedLossRelToOwnTotalUnrealizedPnl
|
|
2051
|
-
* @property {MetricPattern1<StoredF32>} netUnrealizedPnlRelToOwnMarketCap
|
|
2052
|
-
* @property {MetricPattern1<StoredF32>} netUnrealizedPnlRelToOwnTotalUnrealizedPnl
|
|
2053
|
-
* @property {MetricPattern1<StoredF64>} supplyInLossRelToOwnSupply
|
|
2054
|
-
* @property {MetricPattern1<StoredF64>} supplyInProfitRelToOwnSupply
|
|
2055
|
-
* @property {MetricPattern1<StoredF32>} unrealizedLossRelToOwnMarketCap
|
|
2056
|
-
* @property {MetricPattern1<StoredF32>} unrealizedLossRelToOwnTotalUnrealizedPnl
|
|
2057
|
-
* @property {MetricPattern1<StoredF32>} unrealizedProfitRelToOwnMarketCap
|
|
2058
|
-
* @property {MetricPattern1<StoredF32>} unrealizedProfitRelToOwnTotalUnrealizedPnl
|
|
2059
|
-
*/
|
|
2060
|
-
|
|
2061
|
-
/**
|
|
2062
|
-
* Create a RelativePattern2 pattern node
|
|
2063
|
-
* @param {BrkClientBase} client
|
|
2064
|
-
* @param {string} acc - Accumulated metric name
|
|
2065
|
-
* @returns {RelativePattern2}
|
|
2066
|
-
*/
|
|
2067
|
-
function createRelativePattern2(client, acc) {
|
|
2068
|
-
return {
|
|
2069
|
-
negUnrealizedLossRelToOwnMarketCap: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss_rel_to_own_market_cap')),
|
|
2070
|
-
negUnrealizedLossRelToOwnTotalUnrealizedPnl: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss_rel_to_own_total_unrealized_pnl')),
|
|
2071
|
-
netUnrealizedPnlRelToOwnMarketCap: createMetricPattern1(client, _m(acc, 'net_unrealized_pnl_rel_to_own_market_cap')),
|
|
2072
|
-
netUnrealizedPnlRelToOwnTotalUnrealizedPnl: createMetricPattern1(client, _m(acc, 'net_unrealized_pnl_rel_to_own_total_unrealized_pnl')),
|
|
2073
|
-
supplyInLossRelToOwnSupply: createMetricPattern1(client, _m(acc, 'supply_in_loss_rel_to_own_supply')),
|
|
2074
|
-
supplyInProfitRelToOwnSupply: createMetricPattern1(client, _m(acc, 'supply_in_profit_rel_to_own_supply')),
|
|
2075
|
-
unrealizedLossRelToOwnMarketCap: createMetricPattern1(client, _m(acc, 'unrealized_loss_rel_to_own_market_cap')),
|
|
2076
|
-
unrealizedLossRelToOwnTotalUnrealizedPnl: createMetricPattern1(client, _m(acc, 'unrealized_loss_rel_to_own_total_unrealized_pnl')),
|
|
2077
|
-
unrealizedProfitRelToOwnMarketCap: createMetricPattern1(client, _m(acc, 'unrealized_profit_rel_to_own_market_cap')),
|
|
2078
|
-
unrealizedProfitRelToOwnTotalUnrealizedPnl: createMetricPattern1(client, _m(acc, 'unrealized_profit_rel_to_own_total_unrealized_pnl')),
|
|
2079
|
-
};
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
2165
|
/**
|
|
2083
2166
|
* @typedef {Object} RelativePattern
|
|
2084
2167
|
* @property {MetricPattern1<StoredF32>} negUnrealizedLossRelToMarketCap
|
|
@@ -2114,6 +2197,41 @@ function createRelativePattern(client, acc) {
|
|
|
2114
2197
|
};
|
|
2115
2198
|
}
|
|
2116
2199
|
|
|
2200
|
+
/**
|
|
2201
|
+
* @typedef {Object} RelativePattern2
|
|
2202
|
+
* @property {MetricPattern1<StoredF32>} negUnrealizedLossRelToOwnMarketCap
|
|
2203
|
+
* @property {MetricPattern1<StoredF32>} negUnrealizedLossRelToOwnTotalUnrealizedPnl
|
|
2204
|
+
* @property {MetricPattern1<StoredF32>} netUnrealizedPnlRelToOwnMarketCap
|
|
2205
|
+
* @property {MetricPattern1<StoredF32>} netUnrealizedPnlRelToOwnTotalUnrealizedPnl
|
|
2206
|
+
* @property {MetricPattern1<StoredF64>} supplyInLossRelToOwnSupply
|
|
2207
|
+
* @property {MetricPattern1<StoredF64>} supplyInProfitRelToOwnSupply
|
|
2208
|
+
* @property {MetricPattern1<StoredF32>} unrealizedLossRelToOwnMarketCap
|
|
2209
|
+
* @property {MetricPattern1<StoredF32>} unrealizedLossRelToOwnTotalUnrealizedPnl
|
|
2210
|
+
* @property {MetricPattern1<StoredF32>} unrealizedProfitRelToOwnMarketCap
|
|
2211
|
+
* @property {MetricPattern1<StoredF32>} unrealizedProfitRelToOwnTotalUnrealizedPnl
|
|
2212
|
+
*/
|
|
2213
|
+
|
|
2214
|
+
/**
|
|
2215
|
+
* Create a RelativePattern2 pattern node
|
|
2216
|
+
* @param {BrkClientBase} client
|
|
2217
|
+
* @param {string} acc - Accumulated metric name
|
|
2218
|
+
* @returns {RelativePattern2}
|
|
2219
|
+
*/
|
|
2220
|
+
function createRelativePattern2(client, acc) {
|
|
2221
|
+
return {
|
|
2222
|
+
negUnrealizedLossRelToOwnMarketCap: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss_rel_to_own_market_cap')),
|
|
2223
|
+
negUnrealizedLossRelToOwnTotalUnrealizedPnl: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss_rel_to_own_total_unrealized_pnl')),
|
|
2224
|
+
netUnrealizedPnlRelToOwnMarketCap: createMetricPattern1(client, _m(acc, 'net_unrealized_pnl_rel_to_own_market_cap')),
|
|
2225
|
+
netUnrealizedPnlRelToOwnTotalUnrealizedPnl: createMetricPattern1(client, _m(acc, 'net_unrealized_pnl_rel_to_own_total_unrealized_pnl')),
|
|
2226
|
+
supplyInLossRelToOwnSupply: createMetricPattern1(client, _m(acc, 'supply_in_loss_rel_to_own_supply')),
|
|
2227
|
+
supplyInProfitRelToOwnSupply: createMetricPattern1(client, _m(acc, 'supply_in_profit_rel_to_own_supply')),
|
|
2228
|
+
unrealizedLossRelToOwnMarketCap: createMetricPattern1(client, _m(acc, 'unrealized_loss_rel_to_own_market_cap')),
|
|
2229
|
+
unrealizedLossRelToOwnTotalUnrealizedPnl: createMetricPattern1(client, _m(acc, 'unrealized_loss_rel_to_own_total_unrealized_pnl')),
|
|
2230
|
+
unrealizedProfitRelToOwnMarketCap: createMetricPattern1(client, _m(acc, 'unrealized_profit_rel_to_own_market_cap')),
|
|
2231
|
+
unrealizedProfitRelToOwnTotalUnrealizedPnl: createMetricPattern1(client, _m(acc, 'unrealized_profit_rel_to_own_total_unrealized_pnl')),
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2117
2235
|
/**
|
|
2118
2236
|
* @template T
|
|
2119
2237
|
* @typedef {Object} CountPattern2
|
|
@@ -2285,35 +2403,6 @@ function create_0satsPattern(client, acc) {
|
|
|
2285
2403
|
};
|
|
2286
2404
|
}
|
|
2287
2405
|
|
|
2288
|
-
/**
|
|
2289
|
-
* @typedef {Object} _0satsPattern2
|
|
2290
|
-
* @property {ActivityPattern2} activity
|
|
2291
|
-
* @property {CostBasisPattern} costBasis
|
|
2292
|
-
* @property {OutputsPattern} outputs
|
|
2293
|
-
* @property {RealizedPattern} realized
|
|
2294
|
-
* @property {RelativePattern4} relative
|
|
2295
|
-
* @property {SupplyPattern2} supply
|
|
2296
|
-
* @property {UnrealizedPattern} unrealized
|
|
2297
|
-
*/
|
|
2298
|
-
|
|
2299
|
-
/**
|
|
2300
|
-
* Create a _0satsPattern2 pattern node
|
|
2301
|
-
* @param {BrkClientBase} client
|
|
2302
|
-
* @param {string} acc - Accumulated metric name
|
|
2303
|
-
* @returns {_0satsPattern2}
|
|
2304
|
-
*/
|
|
2305
|
-
function create_0satsPattern2(client, acc) {
|
|
2306
|
-
return {
|
|
2307
|
-
activity: createActivityPattern2(client, acc),
|
|
2308
|
-
costBasis: createCostBasisPattern(client, acc),
|
|
2309
|
-
outputs: createOutputsPattern(client, _m(acc, 'utxo_count')),
|
|
2310
|
-
realized: createRealizedPattern(client, acc),
|
|
2311
|
-
relative: createRelativePattern4(client, _m(acc, 'supply_in')),
|
|
2312
|
-
supply: createSupplyPattern2(client, _m(acc, 'supply')),
|
|
2313
|
-
unrealized: createUnrealizedPattern(client, acc),
|
|
2314
|
-
};
|
|
2315
|
-
}
|
|
2316
|
-
|
|
2317
2406
|
/**
|
|
2318
2407
|
* @typedef {Object} PeriodCagrPattern
|
|
2319
2408
|
* @property {MetricPattern4<StoredF32>} _10y
|
|
@@ -2344,58 +2433,58 @@ function createPeriodCagrPattern(client, acc) {
|
|
|
2344
2433
|
}
|
|
2345
2434
|
|
|
2346
2435
|
/**
|
|
2347
|
-
* @typedef {Object}
|
|
2436
|
+
* @typedef {Object} _100btcPattern
|
|
2348
2437
|
* @property {ActivityPattern2} activity
|
|
2349
|
-
* @property {
|
|
2438
|
+
* @property {CostBasisPattern} costBasis
|
|
2350
2439
|
* @property {OutputsPattern} outputs
|
|
2351
|
-
* @property {
|
|
2352
|
-
* @property {
|
|
2440
|
+
* @property {RealizedPattern} realized
|
|
2441
|
+
* @property {RelativePattern} relative
|
|
2353
2442
|
* @property {SupplyPattern2} supply
|
|
2354
2443
|
* @property {UnrealizedPattern} unrealized
|
|
2355
2444
|
*/
|
|
2356
2445
|
|
|
2357
2446
|
/**
|
|
2358
|
-
* Create a
|
|
2447
|
+
* Create a _100btcPattern pattern node
|
|
2359
2448
|
* @param {BrkClientBase} client
|
|
2360
2449
|
* @param {string} acc - Accumulated metric name
|
|
2361
|
-
* @returns {
|
|
2450
|
+
* @returns {_100btcPattern}
|
|
2362
2451
|
*/
|
|
2363
|
-
function
|
|
2452
|
+
function create_100btcPattern(client, acc) {
|
|
2364
2453
|
return {
|
|
2365
2454
|
activity: createActivityPattern2(client, acc),
|
|
2366
|
-
costBasis:
|
|
2455
|
+
costBasis: createCostBasisPattern(client, acc),
|
|
2367
2456
|
outputs: createOutputsPattern(client, _m(acc, 'utxo_count')),
|
|
2368
|
-
realized:
|
|
2369
|
-
relative:
|
|
2457
|
+
realized: createRealizedPattern(client, acc),
|
|
2458
|
+
relative: createRelativePattern(client, acc),
|
|
2370
2459
|
supply: createSupplyPattern2(client, _m(acc, 'supply')),
|
|
2371
2460
|
unrealized: createUnrealizedPattern(client, acc),
|
|
2372
2461
|
};
|
|
2373
2462
|
}
|
|
2374
2463
|
|
|
2375
2464
|
/**
|
|
2376
|
-
* @typedef {Object}
|
|
2465
|
+
* @typedef {Object} _0satsPattern2
|
|
2377
2466
|
* @property {ActivityPattern2} activity
|
|
2378
2467
|
* @property {CostBasisPattern} costBasis
|
|
2379
2468
|
* @property {OutputsPattern} outputs
|
|
2380
2469
|
* @property {RealizedPattern} realized
|
|
2381
|
-
* @property {
|
|
2470
|
+
* @property {RelativePattern4} relative
|
|
2382
2471
|
* @property {SupplyPattern2} supply
|
|
2383
2472
|
* @property {UnrealizedPattern} unrealized
|
|
2384
2473
|
*/
|
|
2385
2474
|
|
|
2386
2475
|
/**
|
|
2387
|
-
* Create a
|
|
2476
|
+
* Create a _0satsPattern2 pattern node
|
|
2388
2477
|
* @param {BrkClientBase} client
|
|
2389
2478
|
* @param {string} acc - Accumulated metric name
|
|
2390
|
-
* @returns {
|
|
2479
|
+
* @returns {_0satsPattern2}
|
|
2391
2480
|
*/
|
|
2392
|
-
function
|
|
2481
|
+
function create_0satsPattern2(client, acc) {
|
|
2393
2482
|
return {
|
|
2394
2483
|
activity: createActivityPattern2(client, acc),
|
|
2395
2484
|
costBasis: createCostBasisPattern(client, acc),
|
|
2396
2485
|
outputs: createOutputsPattern(client, _m(acc, 'utxo_count')),
|
|
2397
2486
|
realized: createRealizedPattern(client, acc),
|
|
2398
|
-
relative:
|
|
2487
|
+
relative: createRelativePattern4(client, _m(acc, 'supply_in')),
|
|
2399
2488
|
supply: createSupplyPattern2(client, _m(acc, 'supply')),
|
|
2400
2489
|
unrealized: createUnrealizedPattern(client, acc),
|
|
2401
2490
|
};
|
|
@@ -2430,6 +2519,35 @@ function create_10yPattern(client, acc) {
|
|
|
2430
2519
|
};
|
|
2431
2520
|
}
|
|
2432
2521
|
|
|
2522
|
+
/**
|
|
2523
|
+
* @typedef {Object} _10yTo12yPattern
|
|
2524
|
+
* @property {ActivityPattern2} activity
|
|
2525
|
+
* @property {CostBasisPattern2} costBasis
|
|
2526
|
+
* @property {OutputsPattern} outputs
|
|
2527
|
+
* @property {RealizedPattern2} realized
|
|
2528
|
+
* @property {RelativePattern2} relative
|
|
2529
|
+
* @property {SupplyPattern2} supply
|
|
2530
|
+
* @property {UnrealizedPattern} unrealized
|
|
2531
|
+
*/
|
|
2532
|
+
|
|
2533
|
+
/**
|
|
2534
|
+
* Create a _10yTo12yPattern pattern node
|
|
2535
|
+
* @param {BrkClientBase} client
|
|
2536
|
+
* @param {string} acc - Accumulated metric name
|
|
2537
|
+
* @returns {_10yTo12yPattern}
|
|
2538
|
+
*/
|
|
2539
|
+
function create_10yTo12yPattern(client, acc) {
|
|
2540
|
+
return {
|
|
2541
|
+
activity: createActivityPattern2(client, acc),
|
|
2542
|
+
costBasis: createCostBasisPattern2(client, acc),
|
|
2543
|
+
outputs: createOutputsPattern(client, _m(acc, 'utxo_count')),
|
|
2544
|
+
realized: createRealizedPattern2(client, acc),
|
|
2545
|
+
relative: createRelativePattern2(client, acc),
|
|
2546
|
+
supply: createSupplyPattern2(client, _m(acc, 'supply')),
|
|
2547
|
+
unrealized: createUnrealizedPattern(client, acc),
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2433
2551
|
/**
|
|
2434
2552
|
* @typedef {Object} UnrealizedPattern
|
|
2435
2553
|
* @property {MetricPattern1<Dollars>} negUnrealizedLoss
|
|
@@ -2537,86 +2655,86 @@ function createSplitPattern2(client, acc) {
|
|
|
2537
2655
|
}
|
|
2538
2656
|
|
|
2539
2657
|
/**
|
|
2540
|
-
* @typedef {Object}
|
|
2541
|
-
* @property {
|
|
2542
|
-
* @property {
|
|
2543
|
-
* @property {
|
|
2658
|
+
* @typedef {Object} SegwitAdoptionPattern
|
|
2659
|
+
* @property {MetricPattern11<StoredF32>} base
|
|
2660
|
+
* @property {MetricPattern2<StoredF32>} cumulative
|
|
2661
|
+
* @property {MetricPattern2<StoredF32>} sum
|
|
2544
2662
|
*/
|
|
2545
2663
|
|
|
2546
2664
|
/**
|
|
2547
|
-
* Create a
|
|
2665
|
+
* Create a SegwitAdoptionPattern pattern node
|
|
2548
2666
|
* @param {BrkClientBase} client
|
|
2549
2667
|
* @param {string} acc - Accumulated metric name
|
|
2550
|
-
* @returns {
|
|
2668
|
+
* @returns {SegwitAdoptionPattern}
|
|
2551
2669
|
*/
|
|
2552
|
-
function
|
|
2670
|
+
function createSegwitAdoptionPattern(client, acc) {
|
|
2553
2671
|
return {
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2672
|
+
base: createMetricPattern11(client, acc),
|
|
2673
|
+
cumulative: createMetricPattern2(client, _m(acc, 'cumulative')),
|
|
2674
|
+
sum: createMetricPattern2(client, _m(acc, 'sum')),
|
|
2557
2675
|
};
|
|
2558
2676
|
}
|
|
2559
2677
|
|
|
2560
2678
|
/**
|
|
2561
|
-
* @typedef {Object}
|
|
2562
|
-
* @property {
|
|
2563
|
-
* @property {
|
|
2564
|
-
* @property {
|
|
2679
|
+
* @typedef {Object} ActiveSupplyPattern
|
|
2680
|
+
* @property {MetricPattern1<Bitcoin>} bitcoin
|
|
2681
|
+
* @property {MetricPattern1<Dollars>} dollars
|
|
2682
|
+
* @property {MetricPattern1<Sats>} sats
|
|
2565
2683
|
*/
|
|
2566
2684
|
|
|
2567
2685
|
/**
|
|
2568
|
-
* Create a
|
|
2686
|
+
* Create a ActiveSupplyPattern pattern node
|
|
2569
2687
|
* @param {BrkClientBase} client
|
|
2570
2688
|
* @param {string} acc - Accumulated metric name
|
|
2571
|
-
* @returns {
|
|
2689
|
+
* @returns {ActiveSupplyPattern}
|
|
2572
2690
|
*/
|
|
2573
|
-
function
|
|
2691
|
+
function createActiveSupplyPattern(client, acc) {
|
|
2574
2692
|
return {
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2693
|
+
bitcoin: createMetricPattern1(client, _m(acc, 'btc')),
|
|
2694
|
+
dollars: createMetricPattern1(client, _m(acc, 'usd')),
|
|
2695
|
+
sats: createMetricPattern1(client, acc),
|
|
2578
2696
|
};
|
|
2579
2697
|
}
|
|
2580
2698
|
|
|
2581
2699
|
/**
|
|
2582
|
-
* @typedef {Object}
|
|
2583
|
-
* @property {
|
|
2584
|
-
* @property {
|
|
2585
|
-
* @property {
|
|
2700
|
+
* @typedef {Object} _2015Pattern
|
|
2701
|
+
* @property {MetricPattern4<Bitcoin>} bitcoin
|
|
2702
|
+
* @property {MetricPattern4<Dollars>} dollars
|
|
2703
|
+
* @property {MetricPattern4<Sats>} sats
|
|
2586
2704
|
*/
|
|
2587
2705
|
|
|
2588
2706
|
/**
|
|
2589
|
-
* Create a
|
|
2707
|
+
* Create a _2015Pattern pattern node
|
|
2590
2708
|
* @param {BrkClientBase} client
|
|
2591
2709
|
* @param {string} acc - Accumulated metric name
|
|
2592
|
-
* @returns {
|
|
2710
|
+
* @returns {_2015Pattern}
|
|
2593
2711
|
*/
|
|
2594
|
-
function
|
|
2712
|
+
function create_2015Pattern(client, acc) {
|
|
2595
2713
|
return {
|
|
2596
|
-
bitcoin:
|
|
2597
|
-
dollars:
|
|
2598
|
-
sats:
|
|
2714
|
+
bitcoin: createMetricPattern4(client, _m(acc, 'btc')),
|
|
2715
|
+
dollars: createMetricPattern4(client, _m(acc, 'usd')),
|
|
2716
|
+
sats: createMetricPattern4(client, acc),
|
|
2599
2717
|
};
|
|
2600
2718
|
}
|
|
2601
2719
|
|
|
2602
2720
|
/**
|
|
2603
|
-
* @typedef {Object}
|
|
2604
|
-
* @property {
|
|
2605
|
-
* @property {
|
|
2606
|
-
* @property {
|
|
2721
|
+
* @typedef {Object} CoinbasePattern
|
|
2722
|
+
* @property {BitcoinPattern} bitcoin
|
|
2723
|
+
* @property {DollarsPattern<Dollars>} dollars
|
|
2724
|
+
* @property {DollarsPattern<Sats>} sats
|
|
2607
2725
|
*/
|
|
2608
2726
|
|
|
2609
2727
|
/**
|
|
2610
|
-
* Create a
|
|
2728
|
+
* Create a CoinbasePattern pattern node
|
|
2611
2729
|
* @param {BrkClientBase} client
|
|
2612
2730
|
* @param {string} acc - Accumulated metric name
|
|
2613
|
-
* @returns {
|
|
2731
|
+
* @returns {CoinbasePattern}
|
|
2614
2732
|
*/
|
|
2615
|
-
function
|
|
2733
|
+
function createCoinbasePattern(client, acc) {
|
|
2616
2734
|
return {
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2735
|
+
bitcoin: createBitcoinPattern(client, _m(acc, 'btc')),
|
|
2736
|
+
dollars: createDollarsPattern(client, _m(acc, 'usd')),
|
|
2737
|
+
sats: createDollarsPattern(client, acc),
|
|
2620
2738
|
};
|
|
2621
2739
|
}
|
|
2622
2740
|
|
|
@@ -2642,44 +2760,44 @@ function createUnclaimedRewardsPattern(client, acc) {
|
|
|
2642
2760
|
}
|
|
2643
2761
|
|
|
2644
2762
|
/**
|
|
2645
|
-
* @typedef {Object}
|
|
2646
|
-
* @property {
|
|
2647
|
-
* @property {
|
|
2648
|
-
* @property {
|
|
2763
|
+
* @typedef {Object} CoinbasePattern2
|
|
2764
|
+
* @property {BlockCountPattern<Bitcoin>} bitcoin
|
|
2765
|
+
* @property {BlockCountPattern<Dollars>} dollars
|
|
2766
|
+
* @property {BlockCountPattern<Sats>} sats
|
|
2649
2767
|
*/
|
|
2650
2768
|
|
|
2651
2769
|
/**
|
|
2652
|
-
* Create a
|
|
2770
|
+
* Create a CoinbasePattern2 pattern node
|
|
2653
2771
|
* @param {BrkClientBase} client
|
|
2654
2772
|
* @param {string} acc - Accumulated metric name
|
|
2655
|
-
* @returns {
|
|
2773
|
+
* @returns {CoinbasePattern2}
|
|
2656
2774
|
*/
|
|
2657
|
-
function
|
|
2775
|
+
function createCoinbasePattern2(client, acc) {
|
|
2658
2776
|
return {
|
|
2659
|
-
bitcoin:
|
|
2660
|
-
dollars:
|
|
2661
|
-
sats:
|
|
2777
|
+
bitcoin: createBlockCountPattern(client, _m(acc, 'btc')),
|
|
2778
|
+
dollars: createBlockCountPattern(client, _m(acc, 'usd')),
|
|
2779
|
+
sats: createBlockCountPattern(client, acc),
|
|
2662
2780
|
};
|
|
2663
2781
|
}
|
|
2664
2782
|
|
|
2665
2783
|
/**
|
|
2666
|
-
* @typedef {Object}
|
|
2667
|
-
* @property {
|
|
2668
|
-
* @property {
|
|
2669
|
-
* @property {
|
|
2784
|
+
* @typedef {Object} CostBasisPattern2
|
|
2785
|
+
* @property {ActivePricePattern} max
|
|
2786
|
+
* @property {ActivePricePattern} min
|
|
2787
|
+
* @property {PercentilesPattern} percentiles
|
|
2670
2788
|
*/
|
|
2671
2789
|
|
|
2672
2790
|
/**
|
|
2673
|
-
* Create a
|
|
2791
|
+
* Create a CostBasisPattern2 pattern node
|
|
2674
2792
|
* @param {BrkClientBase} client
|
|
2675
2793
|
* @param {string} acc - Accumulated metric name
|
|
2676
|
-
* @returns {
|
|
2794
|
+
* @returns {CostBasisPattern2}
|
|
2677
2795
|
*/
|
|
2678
|
-
function
|
|
2796
|
+
function createCostBasisPattern2(client, acc) {
|
|
2679
2797
|
return {
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2798
|
+
max: createActivePricePattern(client, _m(acc, 'max_cost_basis')),
|
|
2799
|
+
min: createActivePricePattern(client, _m(acc, 'min_cost_basis')),
|
|
2800
|
+
percentiles: createPercentilesPattern(client, _m(acc, 'cost_basis')),
|
|
2683
2801
|
};
|
|
2684
2802
|
}
|
|
2685
2803
|
|
|
@@ -2703,40 +2821,59 @@ function createActivePricePattern(client, acc) {
|
|
|
2703
2821
|
}
|
|
2704
2822
|
|
|
2705
2823
|
/**
|
|
2706
|
-
* @typedef {Object}
|
|
2707
|
-
* @property {
|
|
2708
|
-
* @property {
|
|
2824
|
+
* @typedef {Object} _0sdUsdPattern
|
|
2825
|
+
* @property {MetricPattern4<Dollars>} dollars
|
|
2826
|
+
* @property {MetricPattern4<SatsFract>} sats
|
|
2709
2827
|
*/
|
|
2710
2828
|
|
|
2711
2829
|
/**
|
|
2712
|
-
* Create a
|
|
2830
|
+
* Create a _0sdUsdPattern pattern node
|
|
2713
2831
|
* @param {BrkClientBase} client
|
|
2714
2832
|
* @param {string} acc - Accumulated metric name
|
|
2715
|
-
* @returns {
|
|
2833
|
+
* @returns {_0sdUsdPattern}
|
|
2716
2834
|
*/
|
|
2717
|
-
function
|
|
2835
|
+
function create_0sdUsdPattern(client, acc) {
|
|
2718
2836
|
return {
|
|
2719
|
-
|
|
2720
|
-
|
|
2837
|
+
dollars: createMetricPattern4(client, acc),
|
|
2838
|
+
sats: createMetricPattern4(client, _m(acc, 'sats')),
|
|
2721
2839
|
};
|
|
2722
2840
|
}
|
|
2723
2841
|
|
|
2724
2842
|
/**
|
|
2725
|
-
* @typedef {Object}
|
|
2726
|
-
* @property {
|
|
2727
|
-
* @property {
|
|
2843
|
+
* @typedef {Object} SupplyPattern2
|
|
2844
|
+
* @property {ActiveSupplyPattern} halved
|
|
2845
|
+
* @property {ActiveSupplyPattern} total
|
|
2728
2846
|
*/
|
|
2729
2847
|
|
|
2730
2848
|
/**
|
|
2731
|
-
* Create a
|
|
2849
|
+
* Create a SupplyPattern2 pattern node
|
|
2732
2850
|
* @param {BrkClientBase} client
|
|
2733
2851
|
* @param {string} acc - Accumulated metric name
|
|
2734
|
-
* @returns {
|
|
2852
|
+
* @returns {SupplyPattern2}
|
|
2735
2853
|
*/
|
|
2736
|
-
function
|
|
2854
|
+
function createSupplyPattern2(client, acc) {
|
|
2737
2855
|
return {
|
|
2738
|
-
|
|
2739
|
-
|
|
2856
|
+
halved: createActiveSupplyPattern(client, _m(acc, 'halved')),
|
|
2857
|
+
total: createActiveSupplyPattern(client, acc),
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
/**
|
|
2862
|
+
* @typedef {Object} CostBasisPattern
|
|
2863
|
+
* @property {ActivePricePattern} max
|
|
2864
|
+
* @property {ActivePricePattern} min
|
|
2865
|
+
*/
|
|
2866
|
+
|
|
2867
|
+
/**
|
|
2868
|
+
* Create a CostBasisPattern pattern node
|
|
2869
|
+
* @param {BrkClientBase} client
|
|
2870
|
+
* @param {string} acc - Accumulated metric name
|
|
2871
|
+
* @returns {CostBasisPattern}
|
|
2872
|
+
*/
|
|
2873
|
+
function createCostBasisPattern(client, acc) {
|
|
2874
|
+
return {
|
|
2875
|
+
max: createActivePricePattern(client, _m(acc, 'max_cost_basis')),
|
|
2876
|
+
min: createActivePricePattern(client, _m(acc, 'min_cost_basis')),
|
|
2740
2877
|
};
|
|
2741
2878
|
}
|
|
2742
2879
|
|
|
@@ -2779,41 +2916,43 @@ function createRelativePattern4(client, acc) {
|
|
|
2779
2916
|
}
|
|
2780
2917
|
|
|
2781
2918
|
/**
|
|
2782
|
-
* @
|
|
2783
|
-
* @
|
|
2784
|
-
* @property {
|
|
2919
|
+
* @template T
|
|
2920
|
+
* @typedef {Object} BlockCountPattern
|
|
2921
|
+
* @property {MetricPattern1<T>} cumulative
|
|
2922
|
+
* @property {MetricPattern1<T>} sum
|
|
2785
2923
|
*/
|
|
2786
2924
|
|
|
2787
2925
|
/**
|
|
2788
|
-
* Create a
|
|
2926
|
+
* Create a BlockCountPattern pattern node
|
|
2927
|
+
* @template T
|
|
2789
2928
|
* @param {BrkClientBase} client
|
|
2790
2929
|
* @param {string} acc - Accumulated metric name
|
|
2791
|
-
* @returns {
|
|
2930
|
+
* @returns {BlockCountPattern<T>}
|
|
2792
2931
|
*/
|
|
2793
|
-
function
|
|
2932
|
+
function createBlockCountPattern(client, acc) {
|
|
2794
2933
|
return {
|
|
2795
|
-
|
|
2796
|
-
|
|
2934
|
+
cumulative: createMetricPattern1(client, _m(acc, 'cumulative')),
|
|
2935
|
+
sum: createMetricPattern1(client, acc),
|
|
2797
2936
|
};
|
|
2798
2937
|
}
|
|
2799
2938
|
|
|
2800
2939
|
/**
|
|
2801
2940
|
* @template T
|
|
2802
|
-
* @typedef {Object}
|
|
2803
|
-
* @property {
|
|
2941
|
+
* @typedef {Object} BitcoinPattern2
|
|
2942
|
+
* @property {MetricPattern2<T>} cumulative
|
|
2804
2943
|
* @property {MetricPattern1<T>} sum
|
|
2805
2944
|
*/
|
|
2806
2945
|
|
|
2807
2946
|
/**
|
|
2808
|
-
* Create a
|
|
2947
|
+
* Create a BitcoinPattern2 pattern node
|
|
2809
2948
|
* @template T
|
|
2810
2949
|
* @param {BrkClientBase} client
|
|
2811
2950
|
* @param {string} acc - Accumulated metric name
|
|
2812
|
-
* @returns {
|
|
2951
|
+
* @returns {BitcoinPattern2<T>}
|
|
2813
2952
|
*/
|
|
2814
|
-
function
|
|
2953
|
+
function createBitcoinPattern2(client, acc) {
|
|
2815
2954
|
return {
|
|
2816
|
-
cumulative:
|
|
2955
|
+
cumulative: createMetricPattern2(client, _m(acc, 'cumulative')),
|
|
2817
2956
|
sum: createMetricPattern1(client, acc),
|
|
2818
2957
|
};
|
|
2819
2958
|
}
|
|
@@ -2834,29 +2973,25 @@ function createBlockCountPattern(client, acc) {
|
|
|
2834
2973
|
*/
|
|
2835
2974
|
function createSatsPattern(client, acc) {
|
|
2836
2975
|
return {
|
|
2837
|
-
ohlc: createMetricPattern1(client, _m(acc, '
|
|
2838
|
-
split: createSplitPattern2(client, acc),
|
|
2976
|
+
ohlc: createMetricPattern1(client, _m(acc, 'ohlc_sats')),
|
|
2977
|
+
split: createSplitPattern2(client, _m(acc, 'sats')),
|
|
2839
2978
|
};
|
|
2840
2979
|
}
|
|
2841
2980
|
|
|
2842
2981
|
/**
|
|
2843
|
-
* @
|
|
2844
|
-
* @
|
|
2845
|
-
* @property {MetricPattern2<T>} cumulative
|
|
2846
|
-
* @property {MetricPattern1<T>} sum
|
|
2982
|
+
* @typedef {Object} RealizedPriceExtraPattern
|
|
2983
|
+
* @property {MetricPattern4<StoredF32>} ratio
|
|
2847
2984
|
*/
|
|
2848
2985
|
|
|
2849
2986
|
/**
|
|
2850
|
-
* Create a
|
|
2851
|
-
* @template T
|
|
2987
|
+
* Create a RealizedPriceExtraPattern pattern node
|
|
2852
2988
|
* @param {BrkClientBase} client
|
|
2853
2989
|
* @param {string} acc - Accumulated metric name
|
|
2854
|
-
* @returns {
|
|
2990
|
+
* @returns {RealizedPriceExtraPattern}
|
|
2855
2991
|
*/
|
|
2856
|
-
function
|
|
2992
|
+
function createRealizedPriceExtraPattern(client, acc) {
|
|
2857
2993
|
return {
|
|
2858
|
-
|
|
2859
|
-
sum: createMetricPattern1(client, acc),
|
|
2994
|
+
ratio: createMetricPattern4(client, acc),
|
|
2860
2995
|
};
|
|
2861
2996
|
}
|
|
2862
2997
|
|
|
@@ -2877,23 +3012,6 @@ function createOutputsPattern(client, acc) {
|
|
|
2877
3012
|
};
|
|
2878
3013
|
}
|
|
2879
3014
|
|
|
2880
|
-
/**
|
|
2881
|
-
* @typedef {Object} RealizedPriceExtraPattern
|
|
2882
|
-
* @property {MetricPattern4<StoredF32>} ratio
|
|
2883
|
-
*/
|
|
2884
|
-
|
|
2885
|
-
/**
|
|
2886
|
-
* Create a RealizedPriceExtraPattern pattern node
|
|
2887
|
-
* @param {BrkClientBase} client
|
|
2888
|
-
* @param {string} acc - Accumulated metric name
|
|
2889
|
-
* @returns {RealizedPriceExtraPattern}
|
|
2890
|
-
*/
|
|
2891
|
-
function createRealizedPriceExtraPattern(client, acc) {
|
|
2892
|
-
return {
|
|
2893
|
-
ratio: createMetricPattern4(client, acc),
|
|
2894
|
-
};
|
|
2895
|
-
}
|
|
2896
|
-
|
|
2897
3015
|
// Catalog tree typedefs
|
|
2898
3016
|
|
|
2899
3017
|
/**
|
|
@@ -3744,9 +3862,9 @@ function createRealizedPriceExtraPattern(client, acc) {
|
|
|
3744
3862
|
* @property {MetricsTree_Market_Dca_ClassAveragePrice} classAveragePrice
|
|
3745
3863
|
* @property {MetricsTree_Market_Dca_ClassDaysInLoss} classDaysInLoss
|
|
3746
3864
|
* @property {MetricsTree_Market_Dca_ClassDaysInProfit} classDaysInProfit
|
|
3747
|
-
* @property {
|
|
3865
|
+
* @property {MetricsTree_Market_Dca_ClassMaxDrawdown} classMaxDrawdown
|
|
3748
3866
|
* @property {MetricsTree_Market_Dca_ClassMaxReturn} classMaxReturn
|
|
3749
|
-
* @property {
|
|
3867
|
+
* @property {ClassDaysInLossPattern<StoredF32>} classReturns
|
|
3750
3868
|
* @property {MetricsTree_Market_Dca_ClassStack} classStack
|
|
3751
3869
|
* @property {MetricsTree_Market_Dca_PeriodAveragePrice} periodAveragePrice
|
|
3752
3870
|
* @property {PeriodCagrPattern} periodCagr
|
|
@@ -3813,7 +3931,7 @@ function createRealizedPriceExtraPattern(client, acc) {
|
|
|
3813
3931
|
*/
|
|
3814
3932
|
|
|
3815
3933
|
/**
|
|
3816
|
-
* @typedef {Object}
|
|
3934
|
+
* @typedef {Object} MetricsTree_Market_Dca_ClassMaxDrawdown
|
|
3817
3935
|
* @property {MetricPattern4<StoredF32>} _2015
|
|
3818
3936
|
* @property {MetricPattern4<StoredF32>} _2016
|
|
3819
3937
|
* @property {MetricPattern4<StoredF32>} _2017
|
|
@@ -3829,7 +3947,7 @@ function createRealizedPriceExtraPattern(client, acc) {
|
|
|
3829
3947
|
*/
|
|
3830
3948
|
|
|
3831
3949
|
/**
|
|
3832
|
-
* @typedef {Object}
|
|
3950
|
+
* @typedef {Object} MetricsTree_Market_Dca_ClassMaxReturn
|
|
3833
3951
|
* @property {MetricPattern4<StoredF32>} _2015
|
|
3834
3952
|
* @property {MetricPattern4<StoredF32>} _2016
|
|
3835
3953
|
* @property {MetricPattern4<StoredF32>} _2017
|
|
@@ -4212,8 +4330,8 @@ function createRealizedPriceExtraPattern(client, acc) {
|
|
|
4212
4330
|
/**
|
|
4213
4331
|
* @typedef {Object} MetricsTree_Price
|
|
4214
4332
|
* @property {MetricsTree_Price_Cents} cents
|
|
4215
|
-
* @property {
|
|
4216
|
-
* @property {
|
|
4333
|
+
* @property {SatsPattern<OHLCSats>} sats
|
|
4334
|
+
* @property {MetricsTree_Price_Usd} usd
|
|
4217
4335
|
*/
|
|
4218
4336
|
|
|
4219
4337
|
/**
|
|
@@ -4231,9 +4349,9 @@ function createRealizedPriceExtraPattern(client, acc) {
|
|
|
4231
4349
|
*/
|
|
4232
4350
|
|
|
4233
4351
|
/**
|
|
4234
|
-
* @typedef {Object}
|
|
4235
|
-
* @property {MetricPattern1<
|
|
4236
|
-
* @property {SplitPattern2<
|
|
4352
|
+
* @typedef {Object} MetricsTree_Price_Usd
|
|
4353
|
+
* @property {MetricPattern1<OHLCDollars>} ohlc
|
|
4354
|
+
* @property {SplitPattern2<Dollars>} split
|
|
4237
4355
|
*/
|
|
4238
4356
|
|
|
4239
4357
|
/**
|
|
@@ -4371,7 +4489,7 @@ function createRealizedPriceExtraPattern(client, acc) {
|
|
|
4371
4489
|
* @extends BrkClientBase
|
|
4372
4490
|
*/
|
|
4373
4491
|
class BrkClient extends BrkClientBase {
|
|
4374
|
-
VERSION = "v0.1.
|
|
4492
|
+
VERSION = "v0.1.1";
|
|
4375
4493
|
|
|
4376
4494
|
INDEXES = /** @type {const} */ ([
|
|
4377
4495
|
"dateindex",
|
|
@@ -5265,6 +5383,25 @@ class BrkClient extends BrkClientBase {
|
|
|
5265
5383
|
}
|
|
5266
5384
|
});
|
|
5267
5385
|
|
|
5386
|
+
/**
|
|
5387
|
+
* Convert an index value to a Date for date-based indexes.
|
|
5388
|
+
* @param {Index} index - The index type
|
|
5389
|
+
* @param {number} i - The index value
|
|
5390
|
+
* @returns {globalThis.Date}
|
|
5391
|
+
*/
|
|
5392
|
+
indexToDate(index, i) {
|
|
5393
|
+
return indexToDate(index, i);
|
|
5394
|
+
}
|
|
5395
|
+
|
|
5396
|
+
/**
|
|
5397
|
+
* Check if an index type is date-based.
|
|
5398
|
+
* @param {Index} index
|
|
5399
|
+
* @returns {boolean}
|
|
5400
|
+
*/
|
|
5401
|
+
isDateIndex(index) {
|
|
5402
|
+
return isDateIndex(index);
|
|
5403
|
+
}
|
|
5404
|
+
|
|
5268
5405
|
/**
|
|
5269
5406
|
* @param {BrkClientOptions|string} options
|
|
5270
5407
|
*/
|
|
@@ -5920,7 +6057,20 @@ class BrkClient extends BrkClientBase {
|
|
|
5920
6057
|
_2025: createMetricPattern4(this, 'dca_class_2025_days_in_profit'),
|
|
5921
6058
|
_2026: createMetricPattern4(this, 'dca_class_2026_days_in_profit'),
|
|
5922
6059
|
},
|
|
5923
|
-
classMaxDrawdown:
|
|
6060
|
+
classMaxDrawdown: {
|
|
6061
|
+
_2015: createMetricPattern4(this, 'dca_class_2015_max_drawdown'),
|
|
6062
|
+
_2016: createMetricPattern4(this, 'dca_class_2016_max_drawdown'),
|
|
6063
|
+
_2017: createMetricPattern4(this, 'dca_class_2017_max_drawdown'),
|
|
6064
|
+
_2018: createMetricPattern4(this, 'dca_class_2018_max_drawdown'),
|
|
6065
|
+
_2019: createMetricPattern4(this, 'dca_class_2019_max_drawdown'),
|
|
6066
|
+
_2020: createMetricPattern4(this, 'dca_class_2020_max_drawdown'),
|
|
6067
|
+
_2021: createMetricPattern4(this, 'dca_class_2021_max_drawdown'),
|
|
6068
|
+
_2022: createMetricPattern4(this, 'dca_class_2022_max_drawdown'),
|
|
6069
|
+
_2023: createMetricPattern4(this, 'dca_class_2023_max_drawdown'),
|
|
6070
|
+
_2024: createMetricPattern4(this, 'dca_class_2024_max_drawdown'),
|
|
6071
|
+
_2025: createMetricPattern4(this, 'dca_class_2025_max_drawdown'),
|
|
6072
|
+
_2026: createMetricPattern4(this, 'dca_class_2026_max_drawdown'),
|
|
6073
|
+
},
|
|
5924
6074
|
classMaxReturn: {
|
|
5925
6075
|
_2015: createMetricPattern4(this, 'dca_class_2015_max_return'),
|
|
5926
6076
|
_2016: createMetricPattern4(this, 'dca_class_2016_max_return'),
|
|
@@ -5935,20 +6085,7 @@ class BrkClient extends BrkClientBase {
|
|
|
5935
6085
|
_2025: createMetricPattern4(this, 'dca_class_2025_max_return'),
|
|
5936
6086
|
_2026: createMetricPattern4(this, 'dca_class_2026_max_return'),
|
|
5937
6087
|
},
|
|
5938
|
-
classReturns:
|
|
5939
|
-
_2015: createMetricPattern4(this, 'dca_class_2015_returns'),
|
|
5940
|
-
_2016: createMetricPattern4(this, 'dca_class_2016_returns'),
|
|
5941
|
-
_2017: createMetricPattern4(this, 'dca_class_2017_returns'),
|
|
5942
|
-
_2018: createMetricPattern4(this, 'dca_class_2018_returns'),
|
|
5943
|
-
_2019: createMetricPattern4(this, 'dca_class_2019_returns'),
|
|
5944
|
-
_2020: createMetricPattern4(this, 'dca_class_2020_returns'),
|
|
5945
|
-
_2021: createMetricPattern4(this, 'dca_class_2021_returns'),
|
|
5946
|
-
_2022: createMetricPattern4(this, 'dca_class_2022_returns'),
|
|
5947
|
-
_2023: createMetricPattern4(this, 'dca_class_2023_returns'),
|
|
5948
|
-
_2024: createMetricPattern4(this, 'dca_class_2024_returns'),
|
|
5949
|
-
_2025: createMetricPattern4(this, 'dca_class_2025_returns'),
|
|
5950
|
-
_2026: createMetricPattern4(this, 'dca_class_2026_returns'),
|
|
5951
|
-
},
|
|
6088
|
+
classReturns: createClassDaysInLossPattern(this, 'dca_class'),
|
|
5952
6089
|
classStack: {
|
|
5953
6090
|
_2015: create_2015Pattern(this, 'dca_class_2015_stack'),
|
|
5954
6091
|
_2016: create_2015Pattern(this, 'dca_class_2016_stack'),
|
|
@@ -6305,11 +6442,11 @@ class BrkClient extends BrkClientBase {
|
|
|
6305
6442
|
open: createMetricPattern5(this, 'price_open_cents'),
|
|
6306
6443
|
},
|
|
6307
6444
|
},
|
|
6308
|
-
sats:
|
|
6309
|
-
|
|
6310
|
-
|
|
6445
|
+
sats: createSatsPattern(this, 'price'),
|
|
6446
|
+
usd: {
|
|
6447
|
+
ohlc: createMetricPattern1(this, 'price_ohlc'),
|
|
6448
|
+
split: createSplitPattern2(this, 'price'),
|
|
6311
6449
|
},
|
|
6312
|
-
usd: createSatsPattern(this, 'price'),
|
|
6313
6450
|
},
|
|
6314
6451
|
scripts: {
|
|
6315
6452
|
count: {
|
package/package.json
CHANGED