@tradejs/core 2.0.1 → 2.0.3
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.
|
@@ -134,10 +134,28 @@ var DERIVATIVES_INTERVAL_MS = {
|
|
|
134
134
|
"15m": 15 * 60 * 1e3,
|
|
135
135
|
"1h": 60 * 60 * 1e3
|
|
136
136
|
};
|
|
137
|
+
var COINALYZE_MIN_INTRADAY_RETENTION_POINTS = 1500;
|
|
137
138
|
var getLastClosedDerivativesBarStartMs = (timestamp, interval) => {
|
|
138
139
|
const intervalMs = DERIVATIVES_INTERVAL_MS[interval];
|
|
139
140
|
return Math.floor(timestamp / intervalMs) * intervalMs - intervalMs;
|
|
140
141
|
};
|
|
142
|
+
var resolveCoinalyzeConfirmedIntradayCoverage = (params) => {
|
|
143
|
+
const intervalMs = DERIVATIVES_INTERVAL_MS[params.interval];
|
|
144
|
+
const nowMs = params.nowMs ?? Date.now();
|
|
145
|
+
const lastClosedStartMs = getLastClosedDerivativesBarStartMs(
|
|
146
|
+
nowMs,
|
|
147
|
+
params.interval
|
|
148
|
+
);
|
|
149
|
+
const guaranteedRetentionFromMs = lastClosedStartMs - (COINALYZE_MIN_INTRADAY_RETENTION_POINTS - 1) * intervalMs;
|
|
150
|
+
const requestedFromMs = Math.ceil(params.fromMs / intervalMs) * intervalMs;
|
|
151
|
+
const requestedToMs = Math.floor(params.toMs / intervalMs) * intervalMs;
|
|
152
|
+
const fromMs = Math.max(requestedFromMs, guaranteedRetentionFromMs);
|
|
153
|
+
const toMs2 = Math.min(requestedToMs, lastClosedStartMs);
|
|
154
|
+
return fromMs <= toMs2 ? {
|
|
155
|
+
fromMs,
|
|
156
|
+
toMs: toMs2
|
|
157
|
+
} : null;
|
|
158
|
+
};
|
|
141
159
|
var normalizeCoinalyzeSymbols = (input) => String(input ?? "").split(",").map((item) => item.trim().toUpperCase()).filter(Boolean);
|
|
142
160
|
var normalizeDerivativesIntervals = (input) => parseDerivativesIntervals(input);
|
|
143
161
|
var toCoinalyzeTimestampMs = (value) => {
|
|
@@ -264,6 +282,57 @@ var deriveCoinalyzeHourlyRowsFrom15m = (rows) => {
|
|
|
264
282
|
}
|
|
265
283
|
return hourlyRows;
|
|
266
284
|
};
|
|
285
|
+
var deriveCoinalyzeRollingHourlyRowsFrom15m = (rows) => {
|
|
286
|
+
const quarterHourMs = DERIVATIVES_INTERVAL_MS["15m"];
|
|
287
|
+
const rowsByTimestamp = /* @__PURE__ */ new Map();
|
|
288
|
+
for (const row of rows ?? []) {
|
|
289
|
+
const timestamp = row.ts.getTime();
|
|
290
|
+
if (row.interval !== "15m" || !Number.isFinite(timestamp) || timestamp % quarterHourMs !== 0) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
rowsByTimestamp.set(timestamp, row);
|
|
294
|
+
}
|
|
295
|
+
const rollingRows = [];
|
|
296
|
+
for (const timestamp of [...rowsByTimestamp.keys()].sort(
|
|
297
|
+
(left, right) => left - right
|
|
298
|
+
)) {
|
|
299
|
+
const expectedRows = [3, 2, 1, 0].map(
|
|
300
|
+
(offset) => rowsByTimestamp.get(timestamp - offset * quarterHourMs)
|
|
301
|
+
);
|
|
302
|
+
if (expectedRows.some((row) => row == null)) continue;
|
|
303
|
+
const completeRows = expectedRows;
|
|
304
|
+
const latest = completeRows[completeRows.length - 1];
|
|
305
|
+
rollingRows.push({
|
|
306
|
+
symbol: latest.symbol,
|
|
307
|
+
interval: "1h",
|
|
308
|
+
ts: new Date(timestamp),
|
|
309
|
+
openInterest: latest.openInterest ?? null,
|
|
310
|
+
fundingRate: latest.fundingRate ?? null,
|
|
311
|
+
liqLong: sumAvailable(completeRows.map((row) => row.liqLong)),
|
|
312
|
+
liqShort: sumAvailable(completeRows.map((row) => row.liqShort)),
|
|
313
|
+
liqTotal: sumAvailable(completeRows.map(getLiquidationTotal)),
|
|
314
|
+
source: `${latest.source ?? "coinalyze"}:rolling_15m`
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
return rollingRows;
|
|
318
|
+
};
|
|
319
|
+
var buildCoinalyzeHourlyRowsWithFallback = (params) => {
|
|
320
|
+
const hourMs = DERIVATIVES_INTERVAL_MS["1h"];
|
|
321
|
+
const rollingRows = deriveCoinalyzeRollingHourlyRowsFrom15m(params.rows15m);
|
|
322
|
+
const rollingHours = new Set(
|
|
323
|
+
rollingRows.map((row) => Math.floor(row.ts.getTime() / hourMs) * hourMs)
|
|
324
|
+
);
|
|
325
|
+
const fallbackRows = (params.fallbackRows1h ?? []).filter((row) => {
|
|
326
|
+
const timestamp = row.ts.getTime();
|
|
327
|
+
return row.interval === "1h" && Number.isFinite(timestamp) && timestamp % hourMs === 0 && !rollingHours.has(timestamp);
|
|
328
|
+
}).map((row) => ({
|
|
329
|
+
...row,
|
|
330
|
+
source: `${row.source ?? "coinalyze"}:legacy_1h_fallback`
|
|
331
|
+
}));
|
|
332
|
+
return [...fallbackRows, ...rollingRows].sort(
|
|
333
|
+
(left, right) => left.ts.getTime() - right.ts.getTime()
|
|
334
|
+
);
|
|
335
|
+
};
|
|
267
336
|
|
|
268
337
|
// src/utils/derivativesContext.ts
|
|
269
338
|
var HOUR_MS = 60 * 60 * 1e3;
|
|
@@ -11868,7 +11937,9 @@ export {
|
|
|
11868
11937
|
buildReturnsFromCandles,
|
|
11869
11938
|
calculatePearsonCorrelation,
|
|
11870
11939
|
calculateCoinBtcCorrelation,
|
|
11940
|
+
COINALYZE_MIN_INTRADAY_RETENTION_POINTS,
|
|
11871
11941
|
getLastClosedDerivativesBarStartMs,
|
|
11942
|
+
resolveCoinalyzeConfirmedIntradayCoverage,
|
|
11872
11943
|
normalizeCoinalyzeSymbols,
|
|
11873
11944
|
normalizeDerivativesIntervals,
|
|
11874
11945
|
toCoinalyzeTimestampMs,
|
|
@@ -11877,6 +11948,8 @@ export {
|
|
|
11877
11948
|
mergeCoinalyzeMetrics,
|
|
11878
11949
|
coinalyzePointsToRows,
|
|
11879
11950
|
deriveCoinalyzeHourlyRowsFrom15m,
|
|
11951
|
+
deriveCoinalyzeRollingHourlyRowsFrom15m,
|
|
11952
|
+
buildCoinalyzeHourlyRowsWithFallback,
|
|
11880
11953
|
buildDerivativesContext,
|
|
11881
11954
|
buildMlCandleIndicators,
|
|
11882
11955
|
registerIndicatorEntries,
|
package/dist/indicators.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KlineChartItem,
|
|
1
|
+
import { KlineChartItem, DerivativesRow, DerivativesInterval, Direction, DerivativesContext, IndicatorPluginRenderer, Indicator, IndicatorPluginEntry, TrendLine, TrendLineOptions } from '@tradejs/types';
|
|
2
2
|
export { C as COMPACT_INDICATORS_SNAPSHOT_KEY, c as COMPACT_INDICATORS_SNAPSHOT_SYMBOL, I as IndicatorPeriods, b as IndicatorsControllerCheckpointState, a as IndicatorsControllerRuntimeState, P as PricePoint, S as SpreadSmootherState, d as alignSpreadRows, e as applyIndicatorsToHistory, f as buildMlCandleIndicators, g as buildMlTimeframeIndicators, h as coinbaseProductFromSymbol, i as createIndicators, j as createSerializableSpreadSmoother, k as createSpreadSmoother, l as getRequiredControllerSeedWindow, m as intervalToMs, r as rollingMeanStd, s as smoothSpreadSeries } from './indicators-Da_i06-8.mjs';
|
|
3
3
|
import { KLineData } from 'klinecharts';
|
|
4
4
|
|
|
@@ -37,7 +37,17 @@ type CoinalyzePoint = {
|
|
|
37
37
|
liqShort?: number | null;
|
|
38
38
|
liqTotal?: number | null;
|
|
39
39
|
};
|
|
40
|
+
declare const COINALYZE_MIN_INTRADAY_RETENTION_POINTS = 1500;
|
|
40
41
|
declare const getLastClosedDerivativesBarStartMs: (timestamp: number, interval: DerivativesInterval) => number;
|
|
42
|
+
declare const resolveCoinalyzeConfirmedIntradayCoverage: (params: {
|
|
43
|
+
interval: DerivativesInterval;
|
|
44
|
+
fromMs: number;
|
|
45
|
+
toMs: number;
|
|
46
|
+
nowMs?: number;
|
|
47
|
+
}) => {
|
|
48
|
+
fromMs: number;
|
|
49
|
+
toMs: number;
|
|
50
|
+
} | null;
|
|
41
51
|
declare const normalizeCoinalyzeSymbols: (input: unknown) => string[];
|
|
42
52
|
declare const normalizeDerivativesIntervals: (input: unknown) => DerivativesInterval[];
|
|
43
53
|
declare const toCoinalyzeTimestampMs: (value: unknown) => number | null;
|
|
@@ -51,6 +61,11 @@ declare const mergeCoinalyzeMetrics: (params: {
|
|
|
51
61
|
}) => CoinalyzePoint[];
|
|
52
62
|
declare const coinalyzePointsToRows: (points: CoinalyzePoint[], interval: DerivativesInterval, source: string) => DerivativesRow[];
|
|
53
63
|
declare const deriveCoinalyzeHourlyRowsFrom15m: (rows: DerivativesRow[] | undefined) => DerivativesRow[];
|
|
64
|
+
declare const deriveCoinalyzeRollingHourlyRowsFrom15m: (rows: DerivativesRow[] | undefined) => DerivativesRow[];
|
|
65
|
+
declare const buildCoinalyzeHourlyRowsWithFallback: (params: {
|
|
66
|
+
rows15m: DerivativesRow[] | undefined;
|
|
67
|
+
fallbackRows1h: DerivativesRow[] | undefined;
|
|
68
|
+
}) => DerivativesRow[];
|
|
54
69
|
|
|
55
70
|
declare const buildDerivativesContext: (params: {
|
|
56
71
|
symbol: string;
|
|
@@ -95,4 +110,4 @@ type TrendlineEngine = {
|
|
|
95
110
|
};
|
|
96
111
|
declare const createTrendlineEngine: (initialCandles: KLineData[], options: TrendLineOptions) => TrendlineEngine;
|
|
97
112
|
|
|
98
|
-
export { type CoinalyzePoint, type IndicatorRendererDescriptor, type TrendlineEngine, alignSortedCandlesByTimestamp, buildDerivativesContext, buildReturnsFromCandles, calculateCoinBtcCorrelation, calculatePearsonCorrelation, coinalyzePointsToRows, createTrendlineEngine, deriveCoinalyzeHourlyRowsFrom15m, detectRawSupportResistance, getLastClosedDerivativesBarStartMs, getPluginIndicatorCatalog, getPluginIndicatorRenderers, getRegisteredIndicatorEntries, getSupportResistanceLevels, mergeCoinalyzeMetrics, normalizeCoinalyzeSymbols, normalizeDerivativesIntervals, registerIndicatorEntries, resetIndicatorRegistryCache, toArrayData, toCoinalyzeTimestampMs, toFiniteNumber };
|
|
113
|
+
export { COINALYZE_MIN_INTRADAY_RETENTION_POINTS, type CoinalyzePoint, type IndicatorRendererDescriptor, type TrendlineEngine, alignSortedCandlesByTimestamp, buildCoinalyzeHourlyRowsWithFallback, buildDerivativesContext, buildReturnsFromCandles, calculateCoinBtcCorrelation, calculatePearsonCorrelation, coinalyzePointsToRows, createTrendlineEngine, deriveCoinalyzeHourlyRowsFrom15m, deriveCoinalyzeRollingHourlyRowsFrom15m, detectRawSupportResistance, getLastClosedDerivativesBarStartMs, getPluginIndicatorCatalog, getPluginIndicatorRenderers, getRegisteredIndicatorEntries, getSupportResistanceLevels, mergeCoinalyzeMetrics, normalizeCoinalyzeSymbols, normalizeDerivativesIntervals, registerIndicatorEntries, resetIndicatorRegistryCache, resolveCoinalyzeConfirmedIntradayCoverage, toArrayData, toCoinalyzeTimestampMs, toFiniteNumber };
|
package/dist/indicators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KlineChartItem,
|
|
1
|
+
import { KlineChartItem, DerivativesRow, DerivativesInterval, Direction, DerivativesContext, IndicatorPluginRenderer, Indicator, IndicatorPluginEntry, TrendLine, TrendLineOptions } from '@tradejs/types';
|
|
2
2
|
export { C as COMPACT_INDICATORS_SNAPSHOT_KEY, c as COMPACT_INDICATORS_SNAPSHOT_SYMBOL, I as IndicatorPeriods, b as IndicatorsControllerCheckpointState, a as IndicatorsControllerRuntimeState, P as PricePoint, S as SpreadSmootherState, d as alignSpreadRows, e as applyIndicatorsToHistory, f as buildMlCandleIndicators, g as buildMlTimeframeIndicators, h as coinbaseProductFromSymbol, i as createIndicators, j as createSerializableSpreadSmoother, k as createSpreadSmoother, l as getRequiredControllerSeedWindow, m as intervalToMs, r as rollingMeanStd, s as smoothSpreadSeries } from './indicators-Da_i06-8.js';
|
|
3
3
|
import { KLineData } from 'klinecharts';
|
|
4
4
|
|
|
@@ -37,7 +37,17 @@ type CoinalyzePoint = {
|
|
|
37
37
|
liqShort?: number | null;
|
|
38
38
|
liqTotal?: number | null;
|
|
39
39
|
};
|
|
40
|
+
declare const COINALYZE_MIN_INTRADAY_RETENTION_POINTS = 1500;
|
|
40
41
|
declare const getLastClosedDerivativesBarStartMs: (timestamp: number, interval: DerivativesInterval) => number;
|
|
42
|
+
declare const resolveCoinalyzeConfirmedIntradayCoverage: (params: {
|
|
43
|
+
interval: DerivativesInterval;
|
|
44
|
+
fromMs: number;
|
|
45
|
+
toMs: number;
|
|
46
|
+
nowMs?: number;
|
|
47
|
+
}) => {
|
|
48
|
+
fromMs: number;
|
|
49
|
+
toMs: number;
|
|
50
|
+
} | null;
|
|
41
51
|
declare const normalizeCoinalyzeSymbols: (input: unknown) => string[];
|
|
42
52
|
declare const normalizeDerivativesIntervals: (input: unknown) => DerivativesInterval[];
|
|
43
53
|
declare const toCoinalyzeTimestampMs: (value: unknown) => number | null;
|
|
@@ -51,6 +61,11 @@ declare const mergeCoinalyzeMetrics: (params: {
|
|
|
51
61
|
}) => CoinalyzePoint[];
|
|
52
62
|
declare const coinalyzePointsToRows: (points: CoinalyzePoint[], interval: DerivativesInterval, source: string) => DerivativesRow[];
|
|
53
63
|
declare const deriveCoinalyzeHourlyRowsFrom15m: (rows: DerivativesRow[] | undefined) => DerivativesRow[];
|
|
64
|
+
declare const deriveCoinalyzeRollingHourlyRowsFrom15m: (rows: DerivativesRow[] | undefined) => DerivativesRow[];
|
|
65
|
+
declare const buildCoinalyzeHourlyRowsWithFallback: (params: {
|
|
66
|
+
rows15m: DerivativesRow[] | undefined;
|
|
67
|
+
fallbackRows1h: DerivativesRow[] | undefined;
|
|
68
|
+
}) => DerivativesRow[];
|
|
54
69
|
|
|
55
70
|
declare const buildDerivativesContext: (params: {
|
|
56
71
|
symbol: string;
|
|
@@ -95,4 +110,4 @@ type TrendlineEngine = {
|
|
|
95
110
|
};
|
|
96
111
|
declare const createTrendlineEngine: (initialCandles: KLineData[], options: TrendLineOptions) => TrendlineEngine;
|
|
97
112
|
|
|
98
|
-
export { type CoinalyzePoint, type IndicatorRendererDescriptor, type TrendlineEngine, alignSortedCandlesByTimestamp, buildDerivativesContext, buildReturnsFromCandles, calculateCoinBtcCorrelation, calculatePearsonCorrelation, coinalyzePointsToRows, createTrendlineEngine, deriveCoinalyzeHourlyRowsFrom15m, detectRawSupportResistance, getLastClosedDerivativesBarStartMs, getPluginIndicatorCatalog, getPluginIndicatorRenderers, getRegisteredIndicatorEntries, getSupportResistanceLevels, mergeCoinalyzeMetrics, normalizeCoinalyzeSymbols, normalizeDerivativesIntervals, registerIndicatorEntries, resetIndicatorRegistryCache, toArrayData, toCoinalyzeTimestampMs, toFiniteNumber };
|
|
113
|
+
export { COINALYZE_MIN_INTRADAY_RETENTION_POINTS, type CoinalyzePoint, type IndicatorRendererDescriptor, type TrendlineEngine, alignSortedCandlesByTimestamp, buildCoinalyzeHourlyRowsWithFallback, buildDerivativesContext, buildReturnsFromCandles, calculateCoinBtcCorrelation, calculatePearsonCorrelation, coinalyzePointsToRows, createTrendlineEngine, deriveCoinalyzeHourlyRowsFrom15m, deriveCoinalyzeRollingHourlyRowsFrom15m, detectRawSupportResistance, getLastClosedDerivativesBarStartMs, getPluginIndicatorCatalog, getPluginIndicatorRenderers, getRegisteredIndicatorEntries, getSupportResistanceLevels, mergeCoinalyzeMetrics, normalizeCoinalyzeSymbols, normalizeDerivativesIntervals, registerIndicatorEntries, resetIndicatorRegistryCache, resolveCoinalyzeConfirmedIntradayCoverage, toArrayData, toCoinalyzeTimestampMs, toFiniteNumber };
|
package/dist/indicators.js
CHANGED
|
@@ -30,11 +30,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/indicators.ts
|
|
31
31
|
var indicators_exports = {};
|
|
32
32
|
__export(indicators_exports, {
|
|
33
|
+
COINALYZE_MIN_INTRADAY_RETENTION_POINTS: () => COINALYZE_MIN_INTRADAY_RETENTION_POINTS,
|
|
33
34
|
COMPACT_INDICATORS_SNAPSHOT_KEY: () => COMPACT_INDICATORS_SNAPSHOT_KEY,
|
|
34
35
|
COMPACT_INDICATORS_SNAPSHOT_SYMBOL: () => COMPACT_INDICATORS_SNAPSHOT_SYMBOL,
|
|
35
36
|
alignSortedCandlesByTimestamp: () => alignSortedCandlesByTimestamp,
|
|
36
37
|
alignSpreadRows: () => alignSpreadRows,
|
|
37
38
|
applyIndicatorsToHistory: () => applyIndicatorsToHistory,
|
|
39
|
+
buildCoinalyzeHourlyRowsWithFallback: () => buildCoinalyzeHourlyRowsWithFallback,
|
|
38
40
|
buildDerivativesContext: () => buildDerivativesContext,
|
|
39
41
|
buildMlCandleIndicators: () => buildMlCandleIndicators,
|
|
40
42
|
buildMlTimeframeIndicators: () => buildMlTimeframeIndicators,
|
|
@@ -48,6 +50,7 @@ __export(indicators_exports, {
|
|
|
48
50
|
createSpreadSmoother: () => createSpreadSmoother,
|
|
49
51
|
createTrendlineEngine: () => createTrendlineEngine,
|
|
50
52
|
deriveCoinalyzeHourlyRowsFrom15m: () => deriveCoinalyzeHourlyRowsFrom15m,
|
|
53
|
+
deriveCoinalyzeRollingHourlyRowsFrom15m: () => deriveCoinalyzeRollingHourlyRowsFrom15m,
|
|
51
54
|
detectRawSupportResistance: () => detectRawSupportResistance,
|
|
52
55
|
getLastClosedDerivativesBarStartMs: () => getLastClosedDerivativesBarStartMs,
|
|
53
56
|
getPluginIndicatorCatalog: () => getPluginIndicatorCatalog,
|
|
@@ -61,6 +64,7 @@ __export(indicators_exports, {
|
|
|
61
64
|
normalizeDerivativesIntervals: () => normalizeDerivativesIntervals,
|
|
62
65
|
registerIndicatorEntries: () => registerIndicatorEntries,
|
|
63
66
|
resetIndicatorRegistryCache: () => resetIndicatorRegistryCache,
|
|
67
|
+
resolveCoinalyzeConfirmedIntradayCoverage: () => resolveCoinalyzeConfirmedIntradayCoverage,
|
|
64
68
|
rollingMeanStd: () => rollingMeanStd,
|
|
65
69
|
smoothSpreadSeries: () => smoothSpreadSeries,
|
|
66
70
|
toArrayData: () => toArrayData,
|
|
@@ -194,10 +198,28 @@ var DERIVATIVES_INTERVAL_MS = {
|
|
|
194
198
|
"15m": 15 * 60 * 1e3,
|
|
195
199
|
"1h": 60 * 60 * 1e3
|
|
196
200
|
};
|
|
201
|
+
var COINALYZE_MIN_INTRADAY_RETENTION_POINTS = 1500;
|
|
197
202
|
var getLastClosedDerivativesBarStartMs = (timestamp, interval) => {
|
|
198
203
|
const intervalMs = DERIVATIVES_INTERVAL_MS[interval];
|
|
199
204
|
return Math.floor(timestamp / intervalMs) * intervalMs - intervalMs;
|
|
200
205
|
};
|
|
206
|
+
var resolveCoinalyzeConfirmedIntradayCoverage = (params) => {
|
|
207
|
+
const intervalMs = DERIVATIVES_INTERVAL_MS[params.interval];
|
|
208
|
+
const nowMs = params.nowMs ?? Date.now();
|
|
209
|
+
const lastClosedStartMs = getLastClosedDerivativesBarStartMs(
|
|
210
|
+
nowMs,
|
|
211
|
+
params.interval
|
|
212
|
+
);
|
|
213
|
+
const guaranteedRetentionFromMs = lastClosedStartMs - (COINALYZE_MIN_INTRADAY_RETENTION_POINTS - 1) * intervalMs;
|
|
214
|
+
const requestedFromMs = Math.ceil(params.fromMs / intervalMs) * intervalMs;
|
|
215
|
+
const requestedToMs = Math.floor(params.toMs / intervalMs) * intervalMs;
|
|
216
|
+
const fromMs = Math.max(requestedFromMs, guaranteedRetentionFromMs);
|
|
217
|
+
const toMs2 = Math.min(requestedToMs, lastClosedStartMs);
|
|
218
|
+
return fromMs <= toMs2 ? {
|
|
219
|
+
fromMs,
|
|
220
|
+
toMs: toMs2
|
|
221
|
+
} : null;
|
|
222
|
+
};
|
|
201
223
|
var normalizeCoinalyzeSymbols = (input) => String(input ?? "").split(",").map((item) => item.trim().toUpperCase()).filter(Boolean);
|
|
202
224
|
var normalizeDerivativesIntervals = (input) => parseDerivativesIntervals(input);
|
|
203
225
|
var toCoinalyzeTimestampMs = (value) => {
|
|
@@ -324,6 +346,57 @@ var deriveCoinalyzeHourlyRowsFrom15m = (rows) => {
|
|
|
324
346
|
}
|
|
325
347
|
return hourlyRows;
|
|
326
348
|
};
|
|
349
|
+
var deriveCoinalyzeRollingHourlyRowsFrom15m = (rows) => {
|
|
350
|
+
const quarterHourMs = DERIVATIVES_INTERVAL_MS["15m"];
|
|
351
|
+
const rowsByTimestamp = /* @__PURE__ */ new Map();
|
|
352
|
+
for (const row of rows ?? []) {
|
|
353
|
+
const timestamp = row.ts.getTime();
|
|
354
|
+
if (row.interval !== "15m" || !Number.isFinite(timestamp) || timestamp % quarterHourMs !== 0) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
rowsByTimestamp.set(timestamp, row);
|
|
358
|
+
}
|
|
359
|
+
const rollingRows = [];
|
|
360
|
+
for (const timestamp of [...rowsByTimestamp.keys()].sort(
|
|
361
|
+
(left, right) => left - right
|
|
362
|
+
)) {
|
|
363
|
+
const expectedRows = [3, 2, 1, 0].map(
|
|
364
|
+
(offset) => rowsByTimestamp.get(timestamp - offset * quarterHourMs)
|
|
365
|
+
);
|
|
366
|
+
if (expectedRows.some((row) => row == null)) continue;
|
|
367
|
+
const completeRows = expectedRows;
|
|
368
|
+
const latest = completeRows[completeRows.length - 1];
|
|
369
|
+
rollingRows.push({
|
|
370
|
+
symbol: latest.symbol,
|
|
371
|
+
interval: "1h",
|
|
372
|
+
ts: new Date(timestamp),
|
|
373
|
+
openInterest: latest.openInterest ?? null,
|
|
374
|
+
fundingRate: latest.fundingRate ?? null,
|
|
375
|
+
liqLong: sumAvailable(completeRows.map((row) => row.liqLong)),
|
|
376
|
+
liqShort: sumAvailable(completeRows.map((row) => row.liqShort)),
|
|
377
|
+
liqTotal: sumAvailable(completeRows.map(getLiquidationTotal)),
|
|
378
|
+
source: `${latest.source ?? "coinalyze"}:rolling_15m`
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
return rollingRows;
|
|
382
|
+
};
|
|
383
|
+
var buildCoinalyzeHourlyRowsWithFallback = (params) => {
|
|
384
|
+
const hourMs = DERIVATIVES_INTERVAL_MS["1h"];
|
|
385
|
+
const rollingRows = deriveCoinalyzeRollingHourlyRowsFrom15m(params.rows15m);
|
|
386
|
+
const rollingHours = new Set(
|
|
387
|
+
rollingRows.map((row) => Math.floor(row.ts.getTime() / hourMs) * hourMs)
|
|
388
|
+
);
|
|
389
|
+
const fallbackRows = (params.fallbackRows1h ?? []).filter((row) => {
|
|
390
|
+
const timestamp = row.ts.getTime();
|
|
391
|
+
return row.interval === "1h" && Number.isFinite(timestamp) && timestamp % hourMs === 0 && !rollingHours.has(timestamp);
|
|
392
|
+
}).map((row) => ({
|
|
393
|
+
...row,
|
|
394
|
+
source: `${row.source ?? "coinalyze"}:legacy_1h_fallback`
|
|
395
|
+
}));
|
|
396
|
+
return [...fallbackRows, ...rollingRows].sort(
|
|
397
|
+
(left, right) => left.ts.getTime() - right.ts.getTime()
|
|
398
|
+
);
|
|
399
|
+
};
|
|
327
400
|
|
|
328
401
|
// src/utils/derivativesContext.ts
|
|
329
402
|
var HOUR_MS = 60 * 60 * 1e3;
|
|
@@ -11981,11 +12054,13 @@ var createTrendlineEngine = (initialCandles, options) => {
|
|
|
11981
12054
|
};
|
|
11982
12055
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11983
12056
|
0 && (module.exports = {
|
|
12057
|
+
COINALYZE_MIN_INTRADAY_RETENTION_POINTS,
|
|
11984
12058
|
COMPACT_INDICATORS_SNAPSHOT_KEY,
|
|
11985
12059
|
COMPACT_INDICATORS_SNAPSHOT_SYMBOL,
|
|
11986
12060
|
alignSortedCandlesByTimestamp,
|
|
11987
12061
|
alignSpreadRows,
|
|
11988
12062
|
applyIndicatorsToHistory,
|
|
12063
|
+
buildCoinalyzeHourlyRowsWithFallback,
|
|
11989
12064
|
buildDerivativesContext,
|
|
11990
12065
|
buildMlCandleIndicators,
|
|
11991
12066
|
buildMlTimeframeIndicators,
|
|
@@ -11999,6 +12074,7 @@ var createTrendlineEngine = (initialCandles, options) => {
|
|
|
11999
12074
|
createSpreadSmoother,
|
|
12000
12075
|
createTrendlineEngine,
|
|
12001
12076
|
deriveCoinalyzeHourlyRowsFrom15m,
|
|
12077
|
+
deriveCoinalyzeRollingHourlyRowsFrom15m,
|
|
12002
12078
|
detectRawSupportResistance,
|
|
12003
12079
|
getLastClosedDerivativesBarStartMs,
|
|
12004
12080
|
getPluginIndicatorCatalog,
|
|
@@ -12012,6 +12088,7 @@ var createTrendlineEngine = (initialCandles, options) => {
|
|
|
12012
12088
|
normalizeDerivativesIntervals,
|
|
12013
12089
|
registerIndicatorEntries,
|
|
12014
12090
|
resetIndicatorRegistryCache,
|
|
12091
|
+
resolveCoinalyzeConfirmedIntradayCoverage,
|
|
12015
12092
|
rollingMeanStd,
|
|
12016
12093
|
smoothSpreadSeries,
|
|
12017
12094
|
toArrayData,
|
package/dist/indicators.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
COINALYZE_MIN_INTRADAY_RETENTION_POINTS,
|
|
2
3
|
COMPACT_INDICATORS_SNAPSHOT_KEY,
|
|
3
4
|
COMPACT_INDICATORS_SNAPSHOT_SYMBOL,
|
|
4
5
|
alignSortedCandlesByTimestamp,
|
|
5
6
|
alignSpreadRows,
|
|
6
7
|
applyIndicatorsToHistory,
|
|
8
|
+
buildCoinalyzeHourlyRowsWithFallback,
|
|
7
9
|
buildDerivativesContext,
|
|
8
10
|
buildMlCandleIndicators,
|
|
9
11
|
buildMlTimeframeIndicators,
|
|
@@ -17,6 +19,7 @@ import {
|
|
|
17
19
|
createSpreadSmoother,
|
|
18
20
|
createTrendlineEngine,
|
|
19
21
|
deriveCoinalyzeHourlyRowsFrom15m,
|
|
22
|
+
deriveCoinalyzeRollingHourlyRowsFrom15m,
|
|
20
23
|
detectRawSupportResistance,
|
|
21
24
|
getLastClosedDerivativesBarStartMs,
|
|
22
25
|
getPluginIndicatorCatalog,
|
|
@@ -30,22 +33,25 @@ import {
|
|
|
30
33
|
normalizeDerivativesIntervals,
|
|
31
34
|
registerIndicatorEntries,
|
|
32
35
|
resetIndicatorRegistryCache,
|
|
36
|
+
resolveCoinalyzeConfirmedIntradayCoverage,
|
|
33
37
|
rollingMeanStd,
|
|
34
38
|
smoothSpreadSeries,
|
|
35
39
|
toArrayData,
|
|
36
40
|
toCoinalyzeTimestampMs,
|
|
37
41
|
toFiniteNumber
|
|
38
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-HM7WDSPT.mjs";
|
|
39
43
|
import "./chunk-AYC2QVKI.mjs";
|
|
40
44
|
import "./chunk-M7QGVZ3J.mjs";
|
|
41
45
|
import "./chunk-BOETNABM.mjs";
|
|
42
46
|
import "./chunk-MKCQSB4H.mjs";
|
|
43
47
|
export {
|
|
48
|
+
COINALYZE_MIN_INTRADAY_RETENTION_POINTS,
|
|
44
49
|
COMPACT_INDICATORS_SNAPSHOT_KEY,
|
|
45
50
|
COMPACT_INDICATORS_SNAPSHOT_SYMBOL,
|
|
46
51
|
alignSortedCandlesByTimestamp,
|
|
47
52
|
alignSpreadRows,
|
|
48
53
|
applyIndicatorsToHistory,
|
|
54
|
+
buildCoinalyzeHourlyRowsWithFallback,
|
|
49
55
|
buildDerivativesContext,
|
|
50
56
|
buildMlCandleIndicators,
|
|
51
57
|
buildMlTimeframeIndicators,
|
|
@@ -59,6 +65,7 @@ export {
|
|
|
59
65
|
createSpreadSmoother,
|
|
60
66
|
createTrendlineEngine,
|
|
61
67
|
deriveCoinalyzeHourlyRowsFrom15m,
|
|
68
|
+
deriveCoinalyzeRollingHourlyRowsFrom15m,
|
|
62
69
|
detectRawSupportResistance,
|
|
63
70
|
getLastClosedDerivativesBarStartMs,
|
|
64
71
|
getPluginIndicatorCatalog,
|
|
@@ -72,6 +79,7 @@ export {
|
|
|
72
79
|
normalizeDerivativesIntervals,
|
|
73
80
|
registerIndicatorEntries,
|
|
74
81
|
resetIndicatorRegistryCache,
|
|
82
|
+
resolveCoinalyzeConfirmedIntradayCoverage,
|
|
75
83
|
rollingMeanStd,
|
|
76
84
|
smoothSpreadSeries,
|
|
77
85
|
toArrayData,
|
package/dist/strategies.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "MIT-licensed browser-safe API for TradeJS config, strategy authoring, figures, and shared helpers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tradejs",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@tradejs/types": "^2.0.
|
|
103
|
+
"@tradejs/types": "^2.0.3",
|
|
104
104
|
"date-fns": "^3.3.1",
|
|
105
105
|
"fast-technical-indicators": "^1.1.4",
|
|
106
106
|
"klinecharts": "10.0.0-alpha9",
|