@tradejs/core 1.0.0 → 1.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.
- package/README.md +0 -3
- package/dist/{chunk-LIGD3WWX.mjs → chunk-4F73AYK6.mjs} +33 -9
- package/dist/data.d.mts +3 -1
- package/dist/data.d.ts +3 -1
- package/dist/data.js +9 -2
- package/dist/data.mjs +7 -1
- package/dist/{indicators-x3xKl3_W.d.mts → indicators-B-GGjP5F.d.mts} +2 -27
- package/dist/{indicators-x3xKl3_W.d.ts → indicators-B-GGjP5F.d.ts} +2 -27
- package/dist/indicators.d.mts +7 -8
- package/dist/indicators.d.ts +7 -8
- package/dist/indicators.js +33 -9
- package/dist/indicators.mjs +1 -1
- package/dist/strategies.d.mts +3 -3
- package/dist/strategies.d.ts +3 -3
- package/dist/strategies.js +28 -7
- package/dist/strategies.mjs +7 -4
- package/package.json +11 -12
- package/dist/json.d.mts +0 -3
- package/dist/json.d.ts +0 -3
- package/dist/json.js +0 -34
- package/dist/json.mjs +0 -7
- package/dist/pine.d.mts +0 -29
- package/dist/pine.d.ts +0 -29
- package/dist/pine.js +0 -59
- package/dist/pine.mjs +0 -29
package/README.md
CHANGED
|
@@ -29,9 +29,7 @@ Import only explicit public subpaths:
|
|
|
29
29
|
- `@tradejs/core/figures`
|
|
30
30
|
- `@tradejs/core/constants`
|
|
31
31
|
- `@tradejs/core/data`
|
|
32
|
-
- `@tradejs/core/json`
|
|
33
32
|
- `@tradejs/core/async`
|
|
34
|
-
- `@tradejs/core/pine`
|
|
35
33
|
- `@tradejs/core/tickers`
|
|
36
34
|
|
|
37
35
|
There is no root `@tradejs/core` import surface.
|
|
@@ -54,7 +52,6 @@ export default defineConfig(basePreset, {
|
|
|
54
52
|
- import plugin/config helpers from `@tradejs/core/config`
|
|
55
53
|
- import browser-safe authoring helpers from explicit `@tradejs/core/*` subpaths
|
|
56
54
|
- import shared contracts from `@tradejs/types`
|
|
57
|
-
- do not use internal aliases like `@utils` / `@constants`
|
|
58
55
|
- do not use non-public deep imports like `@tradejs/core/src/*`
|
|
59
56
|
|
|
60
57
|
For runtime execution, Pine loading, plugin registries, and backtest orchestration, use `@tradejs/node`.
|
|
@@ -218,8 +218,25 @@ import { SMA, ATR, BollingerBands, OBV, MACD } from "technicalindicators";
|
|
|
218
218
|
var warn = (message, ...args) => {
|
|
219
219
|
console.warn(`[core:indicators] ${message}`, ...args);
|
|
220
220
|
};
|
|
221
|
-
var
|
|
222
|
-
var
|
|
221
|
+
var DEFAULT_INDICATOR_REGISTRY_SCOPE = "__default__";
|
|
222
|
+
var registryStateByScope = /* @__PURE__ */ new Map();
|
|
223
|
+
var normalizeScope = (scope) => {
|
|
224
|
+
const normalized = String(scope ?? "").trim();
|
|
225
|
+
return normalized || DEFAULT_INDICATOR_REGISTRY_SCOPE;
|
|
226
|
+
};
|
|
227
|
+
var getIndicatorRegistryState = (scope) => {
|
|
228
|
+
const normalizedScope = normalizeScope(scope);
|
|
229
|
+
let state = registryStateByScope.get(normalizedScope);
|
|
230
|
+
if (!state) {
|
|
231
|
+
state = {
|
|
232
|
+
pluginIndicatorEntries: /* @__PURE__ */ new Map()
|
|
233
|
+
};
|
|
234
|
+
registryStateByScope.set(normalizedScope, state);
|
|
235
|
+
}
|
|
236
|
+
return state;
|
|
237
|
+
};
|
|
238
|
+
var registerIndicatorEntries = (entries, source, scope) => {
|
|
239
|
+
const { pluginIndicatorEntries } = getIndicatorRegistryState(scope);
|
|
223
240
|
for (const entry of entries) {
|
|
224
241
|
const indicatorId = entry.indicator?.id;
|
|
225
242
|
if (!indicatorId) {
|
|
@@ -237,23 +254,28 @@ var registerIndicatorEntries = (entries, source) => {
|
|
|
237
254
|
pluginIndicatorEntries.set(indicatorId, entry);
|
|
238
255
|
}
|
|
239
256
|
};
|
|
240
|
-
var getRegisteredIndicatorEntries = () => [
|
|
241
|
-
...pluginIndicatorEntries.values()
|
|
257
|
+
var getRegisteredIndicatorEntries = (scope) => [
|
|
258
|
+
...getIndicatorRegistryState(scope).pluginIndicatorEntries.values()
|
|
242
259
|
];
|
|
243
|
-
var getPluginIndicatorCatalog = () => getRegisteredIndicatorEntries().map((entry) => ({
|
|
260
|
+
var getPluginIndicatorCatalog = (scope) => getRegisteredIndicatorEntries(scope).map((entry) => ({
|
|
244
261
|
id: entry.indicator.id,
|
|
245
262
|
label: entry.indicator.label,
|
|
246
263
|
enabled: entry.indicator.enabled,
|
|
247
264
|
periods: entry.indicator.periods
|
|
248
265
|
}));
|
|
249
|
-
var getPluginIndicatorRenderers = () => getRegisteredIndicatorEntries().filter(
|
|
266
|
+
var getPluginIndicatorRenderers = (scope) => getRegisteredIndicatorEntries(scope).filter(
|
|
250
267
|
(entry) => Boolean(entry.renderer)
|
|
251
268
|
).map((entry) => ({
|
|
252
269
|
indicatorId: entry.indicator.id,
|
|
253
270
|
renderer: entry.renderer
|
|
254
271
|
}));
|
|
255
|
-
var resetIndicatorRegistryCache = () => {
|
|
256
|
-
|
|
272
|
+
var resetIndicatorRegistryCache = (scope) => {
|
|
273
|
+
const normalizedScope = String(scope ?? "").trim();
|
|
274
|
+
if (!normalizedScope) {
|
|
275
|
+
registryStateByScope.clear();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
registryStateByScope.delete(normalizeScope(scope));
|
|
257
279
|
};
|
|
258
280
|
|
|
259
281
|
// src/utils/spread.ts
|
|
@@ -462,7 +484,9 @@ var applyIndicatorsToHistory = (indicators, pushIndicator) => {
|
|
|
462
484
|
pushIndicator("spread", indicators.spread ?? void 0);
|
|
463
485
|
};
|
|
464
486
|
var createIndicators = (data, btcData = [], options = {}) => {
|
|
465
|
-
const indicatorPluginEntries = getRegisteredIndicatorEntries(
|
|
487
|
+
const indicatorPluginEntries = getRegisteredIndicatorEntries(
|
|
488
|
+
options.pluginRegistryScope
|
|
489
|
+
);
|
|
466
490
|
const includeMlPayload = options.includeMlPayload !== false;
|
|
467
491
|
const indicatorPeriods = {
|
|
468
492
|
...DEFAULT_INDICATOR_PERIODS,
|
package/dist/data.d.mts
CHANGED
|
@@ -6,4 +6,6 @@ declare const mergeData: (a1: KlineChartData, a2: KlineChartData) => _tradejs_ty
|
|
|
6
6
|
declare const isWrongData: (interval: Interval, data: KlineChartData) => boolean;
|
|
7
7
|
declare const cloneArrayValues: <T>(record: Record<string, T>) => Record<string, T>;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
declare const toJson: (data: any, stringify?: boolean) => string;
|
|
10
|
+
|
|
11
|
+
export { cloneArrayValues, intervalToMs, isWrongData, mergeData, toJson };
|
package/dist/data.d.ts
CHANGED
|
@@ -6,4 +6,6 @@ declare const mergeData: (a1: KlineChartData, a2: KlineChartData) => _tradejs_ty
|
|
|
6
6
|
declare const isWrongData: (interval: Interval, data: KlineChartData) => boolean;
|
|
7
7
|
declare const cloneArrayValues: <T>(record: Record<string, T>) => Record<string, T>;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
declare const toJson: (data: any, stringify?: boolean) => string;
|
|
10
|
+
|
|
11
|
+
export { cloneArrayValues, intervalToMs, isWrongData, mergeData, toJson };
|
package/dist/data.js
CHANGED
|
@@ -33,7 +33,8 @@ __export(data_exports, {
|
|
|
33
33
|
cloneArrayValues: () => cloneArrayValues,
|
|
34
34
|
intervalToMs: () => intervalToMs,
|
|
35
35
|
isWrongData: () => isWrongData,
|
|
36
|
-
mergeData: () => mergeData
|
|
36
|
+
mergeData: () => mergeData,
|
|
37
|
+
toJson: () => toJson
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(data_exports);
|
|
39
40
|
|
|
@@ -91,10 +92,16 @@ var cloneArrayValues = (record) => Object.fromEntries(
|
|
|
91
92
|
Array.isArray(value) ? value.slice() : value
|
|
92
93
|
])
|
|
93
94
|
);
|
|
95
|
+
|
|
96
|
+
// src/utils/toJson.ts
|
|
97
|
+
var toJson = (data, stringify = false) => {
|
|
98
|
+
return stringify ? JSON.stringify(data, null, 2) : JSON.stringify(data);
|
|
99
|
+
};
|
|
94
100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
101
|
0 && (module.exports = {
|
|
96
102
|
cloneArrayValues,
|
|
97
103
|
intervalToMs,
|
|
98
104
|
isWrongData,
|
|
99
|
-
mergeData
|
|
105
|
+
mergeData,
|
|
106
|
+
toJson
|
|
100
107
|
});
|
package/dist/data.mjs
CHANGED
|
@@ -4,9 +4,15 @@ import {
|
|
|
4
4
|
isWrongData,
|
|
5
5
|
mergeData
|
|
6
6
|
} from "./chunk-M7QGVZ3J.mjs";
|
|
7
|
+
|
|
8
|
+
// src/utils/toJson.ts
|
|
9
|
+
var toJson = (data, stringify = false) => {
|
|
10
|
+
return stringify ? JSON.stringify(data, null, 2) : JSON.stringify(data);
|
|
11
|
+
};
|
|
7
12
|
export {
|
|
8
13
|
cloneArrayValues,
|
|
9
14
|
intervalToMs,
|
|
10
15
|
isWrongData,
|
|
11
|
-
mergeData
|
|
16
|
+
mergeData,
|
|
17
|
+
toJson
|
|
12
18
|
};
|
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
import { Pool } from 'pg';
|
|
2
1
|
import { Candle, MlCandleIndicatorsSnapshot, IndicatorSnapshot, IndicatorsHistorySnapshot } from '@tradejs/types';
|
|
3
2
|
|
|
4
|
-
declare global {
|
|
5
|
-
var __pgPool__: Pool | undefined;
|
|
6
|
-
}
|
|
7
|
-
type DerivativesInterval = '15m' | '1h';
|
|
8
|
-
type DerivativesRow = {
|
|
9
|
-
symbol: string;
|
|
10
|
-
interval: DerivativesInterval;
|
|
11
|
-
ts: Date;
|
|
12
|
-
openInterest?: number | null;
|
|
13
|
-
fundingRate?: number | null;
|
|
14
|
-
liqLong?: number | null;
|
|
15
|
-
liqShort?: number | null;
|
|
16
|
-
liqTotal?: number | null;
|
|
17
|
-
source?: string | null;
|
|
18
|
-
};
|
|
19
|
-
type SpreadRow = {
|
|
20
|
-
symbol: string;
|
|
21
|
-
interval: DerivativesInterval;
|
|
22
|
-
ts: Date;
|
|
23
|
-
binancePrice?: number | null;
|
|
24
|
-
coinbasePrice?: number | null;
|
|
25
|
-
spread?: number | null;
|
|
26
|
-
source?: string | null;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
3
|
declare const buildMlCandleIndicators: (candles: Candle[], btcCandles: Candle[]) => MlCandleIndicatorsSnapshot;
|
|
30
4
|
type IndicatorValue = number | null | undefined;
|
|
31
5
|
type TrendlineIndicatorHistoryPush = (key: string, value: number | null | undefined) => void;
|
|
@@ -61,6 +35,7 @@ type CreateIndicatorsOptions = {
|
|
|
61
35
|
includeMlPayload?: boolean;
|
|
62
36
|
btcBinanceData?: Candle[];
|
|
63
37
|
btcCoinbaseData?: Candle[];
|
|
38
|
+
pluginRegistryScope?: string;
|
|
64
39
|
};
|
|
65
40
|
interface IndicatorPeriods {
|
|
66
41
|
maFast: number;
|
|
@@ -87,4 +62,4 @@ declare const createIndicators: (data: Candle[], btcData?: Candle[], options?: C
|
|
|
87
62
|
};
|
|
88
63
|
declare const buildMlTimeframeIndicators: (candles: Candle[], periods?: Partial<IndicatorPeriods>) => Record<string, number[]>;
|
|
89
64
|
|
|
90
|
-
export { type
|
|
65
|
+
export { type IndicatorPeriods as I, applyIndicatorsToHistory as a, buildMlCandleIndicators as b, buildMlTimeframeIndicators as c, createIndicators as d };
|
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
import { Pool } from 'pg';
|
|
2
1
|
import { Candle, MlCandleIndicatorsSnapshot, IndicatorSnapshot, IndicatorsHistorySnapshot } from '@tradejs/types';
|
|
3
2
|
|
|
4
|
-
declare global {
|
|
5
|
-
var __pgPool__: Pool | undefined;
|
|
6
|
-
}
|
|
7
|
-
type DerivativesInterval = '15m' | '1h';
|
|
8
|
-
type DerivativesRow = {
|
|
9
|
-
symbol: string;
|
|
10
|
-
interval: DerivativesInterval;
|
|
11
|
-
ts: Date;
|
|
12
|
-
openInterest?: number | null;
|
|
13
|
-
fundingRate?: number | null;
|
|
14
|
-
liqLong?: number | null;
|
|
15
|
-
liqShort?: number | null;
|
|
16
|
-
liqTotal?: number | null;
|
|
17
|
-
source?: string | null;
|
|
18
|
-
};
|
|
19
|
-
type SpreadRow = {
|
|
20
|
-
symbol: string;
|
|
21
|
-
interval: DerivativesInterval;
|
|
22
|
-
ts: Date;
|
|
23
|
-
binancePrice?: number | null;
|
|
24
|
-
coinbasePrice?: number | null;
|
|
25
|
-
spread?: number | null;
|
|
26
|
-
source?: string | null;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
3
|
declare const buildMlCandleIndicators: (candles: Candle[], btcCandles: Candle[]) => MlCandleIndicatorsSnapshot;
|
|
30
4
|
type IndicatorValue = number | null | undefined;
|
|
31
5
|
type TrendlineIndicatorHistoryPush = (key: string, value: number | null | undefined) => void;
|
|
@@ -61,6 +35,7 @@ type CreateIndicatorsOptions = {
|
|
|
61
35
|
includeMlPayload?: boolean;
|
|
62
36
|
btcBinanceData?: Candle[];
|
|
63
37
|
btcCoinbaseData?: Candle[];
|
|
38
|
+
pluginRegistryScope?: string;
|
|
64
39
|
};
|
|
65
40
|
interface IndicatorPeriods {
|
|
66
41
|
maFast: number;
|
|
@@ -87,4 +62,4 @@ declare const createIndicators: (data: Candle[], btcData?: Candle[], options?: C
|
|
|
87
62
|
};
|
|
88
63
|
declare const buildMlTimeframeIndicators: (candles: Candle[], periods?: Partial<IndicatorPeriods>) => Record<string, number[]>;
|
|
89
64
|
|
|
90
|
-
export { type
|
|
65
|
+
export { type IndicatorPeriods as I, applyIndicatorsToHistory as a, buildMlCandleIndicators as b, buildMlTimeframeIndicators as c, createIndicators as d };
|
package/dist/indicators.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { KlineChartItem, IndicatorPluginRenderer, Indicator, IndicatorPluginEntry, TrendLine, TrendLineOptions } from '@tradejs/types';
|
|
2
|
-
import {
|
|
3
|
-
export { I as IndicatorPeriods,
|
|
2
|
+
import { DerivativesInterval, DerivativesRow, SpreadRow } from '@tradejs/infra/timescale';
|
|
3
|
+
export { I as IndicatorPeriods, a as applyIndicatorsToHistory, b as buildMlCandleIndicators, c as buildMlTimeframeIndicators, d as createIndicators } from './indicators-B-GGjP5F.mjs';
|
|
4
4
|
import { KLineData } from 'klinecharts';
|
|
5
|
-
import 'pg';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Выравнивает два отсортированных массива свечей по timestamp.
|
|
@@ -52,15 +51,15 @@ declare const mergeCoinalyzeMetrics: (params: {
|
|
|
52
51
|
}) => CoinalyzePoint[];
|
|
53
52
|
declare const coinalyzePointsToRows: (points: CoinalyzePoint[], interval: DerivativesInterval, source: string) => DerivativesRow[];
|
|
54
53
|
|
|
55
|
-
declare const registerIndicatorEntries: (entries: readonly IndicatorPluginEntry[], source: string) => void;
|
|
56
|
-
declare const getRegisteredIndicatorEntries: () => IndicatorPluginEntry[];
|
|
57
|
-
declare const getPluginIndicatorCatalog: () => Indicator[];
|
|
54
|
+
declare const registerIndicatorEntries: (entries: readonly IndicatorPluginEntry[], source: string, scope?: string) => void;
|
|
55
|
+
declare const getRegisteredIndicatorEntries: (scope?: string) => IndicatorPluginEntry[];
|
|
56
|
+
declare const getPluginIndicatorCatalog: (scope?: string) => Indicator[];
|
|
58
57
|
type IndicatorRendererDescriptor = {
|
|
59
58
|
indicatorId: string;
|
|
60
59
|
renderer: IndicatorPluginRenderer;
|
|
61
60
|
};
|
|
62
|
-
declare const getPluginIndicatorRenderers: () => IndicatorRendererDescriptor[];
|
|
63
|
-
declare const resetIndicatorRegistryCache: () => void;
|
|
61
|
+
declare const getPluginIndicatorRenderers: (scope?: string) => IndicatorRendererDescriptor[];
|
|
62
|
+
declare const resetIndicatorRegistryCache: (scope?: string) => void;
|
|
64
63
|
|
|
65
64
|
type SpreadValue = number | null | undefined;
|
|
66
65
|
type SpreadPointInput = {
|
package/dist/indicators.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { KlineChartItem, IndicatorPluginRenderer, Indicator, IndicatorPluginEntry, TrendLine, TrendLineOptions } from '@tradejs/types';
|
|
2
|
-
import {
|
|
3
|
-
export { I as IndicatorPeriods,
|
|
2
|
+
import { DerivativesInterval, DerivativesRow, SpreadRow } from '@tradejs/infra/timescale';
|
|
3
|
+
export { I as IndicatorPeriods, a as applyIndicatorsToHistory, b as buildMlCandleIndicators, c as buildMlTimeframeIndicators, d as createIndicators } from './indicators-B-GGjP5F.js';
|
|
4
4
|
import { KLineData } from 'klinecharts';
|
|
5
|
-
import 'pg';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Выравнивает два отсортированных массива свечей по timestamp.
|
|
@@ -52,15 +51,15 @@ declare const mergeCoinalyzeMetrics: (params: {
|
|
|
52
51
|
}) => CoinalyzePoint[];
|
|
53
52
|
declare const coinalyzePointsToRows: (points: CoinalyzePoint[], interval: DerivativesInterval, source: string) => DerivativesRow[];
|
|
54
53
|
|
|
55
|
-
declare const registerIndicatorEntries: (entries: readonly IndicatorPluginEntry[], source: string) => void;
|
|
56
|
-
declare const getRegisteredIndicatorEntries: () => IndicatorPluginEntry[];
|
|
57
|
-
declare const getPluginIndicatorCatalog: () => Indicator[];
|
|
54
|
+
declare const registerIndicatorEntries: (entries: readonly IndicatorPluginEntry[], source: string, scope?: string) => void;
|
|
55
|
+
declare const getRegisteredIndicatorEntries: (scope?: string) => IndicatorPluginEntry[];
|
|
56
|
+
declare const getPluginIndicatorCatalog: (scope?: string) => Indicator[];
|
|
58
57
|
type IndicatorRendererDescriptor = {
|
|
59
58
|
indicatorId: string;
|
|
60
59
|
renderer: IndicatorPluginRenderer;
|
|
61
60
|
};
|
|
62
|
-
declare const getPluginIndicatorRenderers: () => IndicatorRendererDescriptor[];
|
|
63
|
-
declare const resetIndicatorRegistryCache: () => void;
|
|
61
|
+
declare const getPluginIndicatorRenderers: (scope?: string) => IndicatorRendererDescriptor[];
|
|
62
|
+
declare const resetIndicatorRegistryCache: (scope?: string) => void;
|
|
64
63
|
|
|
65
64
|
type SpreadValue = number | null | undefined;
|
|
66
65
|
type SpreadPointInput = {
|
package/dist/indicators.js
CHANGED
|
@@ -299,8 +299,25 @@ var cloneArrayValues = (record) => Object.fromEntries(
|
|
|
299
299
|
var warn = (message, ...args) => {
|
|
300
300
|
console.warn(`[core:indicators] ${message}`, ...args);
|
|
301
301
|
};
|
|
302
|
-
var
|
|
303
|
-
var
|
|
302
|
+
var DEFAULT_INDICATOR_REGISTRY_SCOPE = "__default__";
|
|
303
|
+
var registryStateByScope = /* @__PURE__ */ new Map();
|
|
304
|
+
var normalizeScope = (scope) => {
|
|
305
|
+
const normalized = String(scope ?? "").trim();
|
|
306
|
+
return normalized || DEFAULT_INDICATOR_REGISTRY_SCOPE;
|
|
307
|
+
};
|
|
308
|
+
var getIndicatorRegistryState = (scope) => {
|
|
309
|
+
const normalizedScope = normalizeScope(scope);
|
|
310
|
+
let state = registryStateByScope.get(normalizedScope);
|
|
311
|
+
if (!state) {
|
|
312
|
+
state = {
|
|
313
|
+
pluginIndicatorEntries: /* @__PURE__ */ new Map()
|
|
314
|
+
};
|
|
315
|
+
registryStateByScope.set(normalizedScope, state);
|
|
316
|
+
}
|
|
317
|
+
return state;
|
|
318
|
+
};
|
|
319
|
+
var registerIndicatorEntries = (entries, source, scope) => {
|
|
320
|
+
const { pluginIndicatorEntries } = getIndicatorRegistryState(scope);
|
|
304
321
|
for (const entry of entries) {
|
|
305
322
|
const indicatorId = entry.indicator?.id;
|
|
306
323
|
if (!indicatorId) {
|
|
@@ -318,23 +335,28 @@ var registerIndicatorEntries = (entries, source) => {
|
|
|
318
335
|
pluginIndicatorEntries.set(indicatorId, entry);
|
|
319
336
|
}
|
|
320
337
|
};
|
|
321
|
-
var getRegisteredIndicatorEntries = () => [
|
|
322
|
-
...pluginIndicatorEntries.values()
|
|
338
|
+
var getRegisteredIndicatorEntries = (scope) => [
|
|
339
|
+
...getIndicatorRegistryState(scope).pluginIndicatorEntries.values()
|
|
323
340
|
];
|
|
324
|
-
var getPluginIndicatorCatalog = () => getRegisteredIndicatorEntries().map((entry) => ({
|
|
341
|
+
var getPluginIndicatorCatalog = (scope) => getRegisteredIndicatorEntries(scope).map((entry) => ({
|
|
325
342
|
id: entry.indicator.id,
|
|
326
343
|
label: entry.indicator.label,
|
|
327
344
|
enabled: entry.indicator.enabled,
|
|
328
345
|
periods: entry.indicator.periods
|
|
329
346
|
}));
|
|
330
|
-
var getPluginIndicatorRenderers = () => getRegisteredIndicatorEntries().filter(
|
|
347
|
+
var getPluginIndicatorRenderers = (scope) => getRegisteredIndicatorEntries(scope).filter(
|
|
331
348
|
(entry) => Boolean(entry.renderer)
|
|
332
349
|
).map((entry) => ({
|
|
333
350
|
indicatorId: entry.indicator.id,
|
|
334
351
|
renderer: entry.renderer
|
|
335
352
|
}));
|
|
336
|
-
var resetIndicatorRegistryCache = () => {
|
|
337
|
-
|
|
353
|
+
var resetIndicatorRegistryCache = (scope) => {
|
|
354
|
+
const normalizedScope = String(scope ?? "").trim();
|
|
355
|
+
if (!normalizedScope) {
|
|
356
|
+
registryStateByScope.clear();
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
registryStateByScope.delete(normalizeScope(scope));
|
|
338
360
|
};
|
|
339
361
|
|
|
340
362
|
// src/utils/spread.ts
|
|
@@ -543,7 +565,9 @@ var applyIndicatorsToHistory = (indicators, pushIndicator) => {
|
|
|
543
565
|
pushIndicator("spread", indicators.spread ?? void 0);
|
|
544
566
|
};
|
|
545
567
|
var createIndicators = (data, btcData = [], options = {}) => {
|
|
546
|
-
const indicatorPluginEntries = getRegisteredIndicatorEntries(
|
|
568
|
+
const indicatorPluginEntries = getRegisteredIndicatorEntries(
|
|
569
|
+
options.pluginRegistryScope
|
|
570
|
+
);
|
|
547
571
|
const includeMlPayload = options.includeMlPayload !== false;
|
|
548
572
|
const indicatorPeriods = {
|
|
549
573
|
...DEFAULT_INDICATOR_PERIODS,
|
package/dist/indicators.mjs
CHANGED
package/dist/strategies.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { KlineChartData, StrategyIndicatorsState, Direction, Connector, Interval, BacktestPriceMode, StrategyMarketSnapshot, BuildStrategySignalDraft, StrategyEntrySignalContext, StrategyEntryOrderPlan, StrategyEntryRuntimeOptions, StrategyDecision, BuildStrategySignalParams, Signal, StrategyAPI, StrategyRuntimeAiOptions, StrategyRuntimeMlOptions } from '@tradejs/types';
|
|
2
|
-
import { I as IndicatorPeriods } from './indicators-
|
|
3
|
-
import 'pg';
|
|
2
|
+
import { I as IndicatorPeriods } from './indicators-B-GGjP5F.mjs';
|
|
4
3
|
|
|
5
4
|
type IndicatorPeriodsConfig = Partial<Record<'MA_FAST' | 'MA_MEDIUM' | 'MA_SLOW' | 'OBV_SMA' | 'ATR' | 'ATR_PCT_SHORT' | 'ATR_PCT_LONG' | 'BB' | 'BB_STD' | 'MACD_FAST' | 'MACD_SLOW' | 'MACD_SIGNAL' | 'LEVEL_LOOKBACK' | 'LEVEL_DELAY', number>>;
|
|
6
5
|
declare const buildDefaultIndicatorPeriods: (config: IndicatorPeriodsConfig) => Partial<IndicatorPeriods>;
|
|
@@ -11,8 +10,9 @@ interface StrategyIndicatorsStateParams {
|
|
|
11
10
|
btcBinanceData?: KlineChartData;
|
|
12
11
|
btcCoinbaseData?: KlineChartData;
|
|
13
12
|
periods?: Partial<IndicatorPeriods>;
|
|
13
|
+
pluginRegistryScope?: string;
|
|
14
14
|
}
|
|
15
|
-
declare const createStrategyIndicatorsState: ({ env, data, btcData, btcBinanceData, btcCoinbaseData, periods, }: StrategyIndicatorsStateParams) => StrategyIndicatorsState;
|
|
15
|
+
declare const createStrategyIndicatorsState: ({ env, data, btcData, btcBinanceData, btcCoinbaseData, periods, pluginRegistryScope, }: StrategyIndicatorsStateParams) => StrategyIndicatorsState;
|
|
16
16
|
|
|
17
17
|
interface StrategyMarketSnapshotParams {
|
|
18
18
|
env: string;
|
package/dist/strategies.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { KlineChartData, StrategyIndicatorsState, Direction, Connector, Interval, BacktestPriceMode, StrategyMarketSnapshot, BuildStrategySignalDraft, StrategyEntrySignalContext, StrategyEntryOrderPlan, StrategyEntryRuntimeOptions, StrategyDecision, BuildStrategySignalParams, Signal, StrategyAPI, StrategyRuntimeAiOptions, StrategyRuntimeMlOptions } from '@tradejs/types';
|
|
2
|
-
import { I as IndicatorPeriods } from './indicators-
|
|
3
|
-
import 'pg';
|
|
2
|
+
import { I as IndicatorPeriods } from './indicators-B-GGjP5F.js';
|
|
4
3
|
|
|
5
4
|
type IndicatorPeriodsConfig = Partial<Record<'MA_FAST' | 'MA_MEDIUM' | 'MA_SLOW' | 'OBV_SMA' | 'ATR' | 'ATR_PCT_SHORT' | 'ATR_PCT_LONG' | 'BB' | 'BB_STD' | 'MACD_FAST' | 'MACD_SLOW' | 'MACD_SIGNAL' | 'LEVEL_LOOKBACK' | 'LEVEL_DELAY', number>>;
|
|
6
5
|
declare const buildDefaultIndicatorPeriods: (config: IndicatorPeriodsConfig) => Partial<IndicatorPeriods>;
|
|
@@ -11,8 +10,9 @@ interface StrategyIndicatorsStateParams {
|
|
|
11
10
|
btcBinanceData?: KlineChartData;
|
|
12
11
|
btcCoinbaseData?: KlineChartData;
|
|
13
12
|
periods?: Partial<IndicatorPeriods>;
|
|
13
|
+
pluginRegistryScope?: string;
|
|
14
14
|
}
|
|
15
|
-
declare const createStrategyIndicatorsState: ({ env, data, btcData, btcBinanceData, btcCoinbaseData, periods, }: StrategyIndicatorsStateParams) => StrategyIndicatorsState;
|
|
15
|
+
declare const createStrategyIndicatorsState: ({ env, data, btcData, btcBinanceData, btcCoinbaseData, periods, pluginRegistryScope, }: StrategyIndicatorsStateParams) => StrategyIndicatorsState;
|
|
16
16
|
|
|
17
17
|
interface StrategyMarketSnapshotParams {
|
|
18
18
|
env: string;
|
package/dist/strategies.js
CHANGED
|
@@ -163,9 +163,25 @@ var cloneArrayValues = (record) => Object.fromEntries(
|
|
|
163
163
|
);
|
|
164
164
|
|
|
165
165
|
// src/utils/indicatorPlugins.ts
|
|
166
|
-
var
|
|
167
|
-
var
|
|
168
|
-
|
|
166
|
+
var DEFAULT_INDICATOR_REGISTRY_SCOPE = "__default__";
|
|
167
|
+
var registryStateByScope = /* @__PURE__ */ new Map();
|
|
168
|
+
var normalizeScope = (scope) => {
|
|
169
|
+
const normalized = String(scope ?? "").trim();
|
|
170
|
+
return normalized || DEFAULT_INDICATOR_REGISTRY_SCOPE;
|
|
171
|
+
};
|
|
172
|
+
var getIndicatorRegistryState = (scope) => {
|
|
173
|
+
const normalizedScope = normalizeScope(scope);
|
|
174
|
+
let state = registryStateByScope.get(normalizedScope);
|
|
175
|
+
if (!state) {
|
|
176
|
+
state = {
|
|
177
|
+
pluginIndicatorEntries: /* @__PURE__ */ new Map()
|
|
178
|
+
};
|
|
179
|
+
registryStateByScope.set(normalizedScope, state);
|
|
180
|
+
}
|
|
181
|
+
return state;
|
|
182
|
+
};
|
|
183
|
+
var getRegisteredIndicatorEntries = (scope) => [
|
|
184
|
+
...getIndicatorRegistryState(scope).pluginIndicatorEntries.values()
|
|
169
185
|
];
|
|
170
186
|
|
|
171
187
|
// src/utils/spread.ts
|
|
@@ -313,7 +329,9 @@ var applyIndicatorsToHistory = (indicators, pushIndicator) => {
|
|
|
313
329
|
pushIndicator("spread", indicators.spread ?? void 0);
|
|
314
330
|
};
|
|
315
331
|
var createIndicators = (data, btcData = [], options = {}) => {
|
|
316
|
-
const indicatorPluginEntries = getRegisteredIndicatorEntries(
|
|
332
|
+
const indicatorPluginEntries = getRegisteredIndicatorEntries(
|
|
333
|
+
options.pluginRegistryScope
|
|
334
|
+
);
|
|
317
335
|
const includeMlPayload = options.includeMlPayload !== false;
|
|
318
336
|
const indicatorPeriods = {
|
|
319
337
|
...DEFAULT_INDICATOR_PERIODS,
|
|
@@ -718,12 +736,14 @@ var createStrategyIndicatorsState = ({
|
|
|
718
736
|
btcData,
|
|
719
737
|
btcBinanceData,
|
|
720
738
|
btcCoinbaseData,
|
|
721
|
-
periods
|
|
739
|
+
periods,
|
|
740
|
+
pluginRegistryScope
|
|
722
741
|
}) => {
|
|
723
742
|
let controller = env === "BACKTEST" ? createIndicators(data, btcData, {
|
|
724
743
|
periods,
|
|
725
744
|
btcBinanceData,
|
|
726
|
-
btcCoinbaseData
|
|
745
|
+
btcCoinbaseData,
|
|
746
|
+
pluginRegistryScope
|
|
727
747
|
}) : null;
|
|
728
748
|
let currentBarPair;
|
|
729
749
|
const withSnapshot = (value) => Object.assign(value, {
|
|
@@ -738,7 +758,8 @@ var createStrategyIndicatorsState = ({
|
|
|
738
758
|
controller = createIndicators(data.slice(0, -1), btcData.slice(0, -1), {
|
|
739
759
|
periods,
|
|
740
760
|
btcBinanceData,
|
|
741
|
-
btcCoinbaseData
|
|
761
|
+
btcCoinbaseData,
|
|
762
|
+
pluginRegistryScope
|
|
742
763
|
});
|
|
743
764
|
const lastCandle = data[data.length - 1];
|
|
744
765
|
const lastBtcCandle = btcData[btcData.length - 1];
|
package/dist/strategies.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-NQ7D3T4E.mjs";
|
|
4
4
|
import {
|
|
5
5
|
createIndicators
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4F73AYK6.mjs";
|
|
7
7
|
import "./chunk-AYC2QVKI.mjs";
|
|
8
8
|
import {
|
|
9
9
|
getTimestamp
|
|
@@ -36,12 +36,14 @@ var createStrategyIndicatorsState = ({
|
|
|
36
36
|
btcData,
|
|
37
37
|
btcBinanceData,
|
|
38
38
|
btcCoinbaseData,
|
|
39
|
-
periods
|
|
39
|
+
periods,
|
|
40
|
+
pluginRegistryScope
|
|
40
41
|
}) => {
|
|
41
42
|
let controller = env === "BACKTEST" ? createIndicators(data, btcData, {
|
|
42
43
|
periods,
|
|
43
44
|
btcBinanceData,
|
|
44
|
-
btcCoinbaseData
|
|
45
|
+
btcCoinbaseData,
|
|
46
|
+
pluginRegistryScope
|
|
45
47
|
}) : null;
|
|
46
48
|
let currentBarPair;
|
|
47
49
|
const withSnapshot = (value) => Object.assign(value, {
|
|
@@ -56,7 +58,8 @@ var createStrategyIndicatorsState = ({
|
|
|
56
58
|
controller = createIndicators(data.slice(0, -1), btcData.slice(0, -1), {
|
|
57
59
|
periods,
|
|
58
60
|
btcBinanceData,
|
|
59
|
-
btcCoinbaseData
|
|
61
|
+
btcCoinbaseData,
|
|
62
|
+
pluginRegistryScope
|
|
60
63
|
});
|
|
61
64
|
const lastCandle = data[data.length - 1];
|
|
62
65
|
const lastBtcCandle = btcData[btcData.length - 1];
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Browser-safe TradeJS public API for config, strategy authoring, indicators, figures, and shared helpers.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tradejs",
|
|
7
|
+
"trading",
|
|
8
|
+
"backtesting",
|
|
9
|
+
"typescript",
|
|
10
|
+
"strategy",
|
|
11
|
+
"indicators",
|
|
12
|
+
"pine-script"
|
|
13
|
+
],
|
|
5
14
|
"homepage": "https://tradejs.dev",
|
|
6
15
|
"files": [
|
|
7
16
|
"dist"
|
|
@@ -47,21 +56,11 @@
|
|
|
47
56
|
"import": "./dist/indicators.mjs",
|
|
48
57
|
"require": "./dist/indicators.js"
|
|
49
58
|
},
|
|
50
|
-
"./json": {
|
|
51
|
-
"types": "./dist/json.d.ts",
|
|
52
|
-
"import": "./dist/json.mjs",
|
|
53
|
-
"require": "./dist/json.js"
|
|
54
|
-
},
|
|
55
59
|
"./math": {
|
|
56
60
|
"types": "./dist/math.d.ts",
|
|
57
61
|
"import": "./dist/math.mjs",
|
|
58
62
|
"require": "./dist/math.js"
|
|
59
63
|
},
|
|
60
|
-
"./pine": {
|
|
61
|
-
"types": "./dist/pine.d.ts",
|
|
62
|
-
"import": "./dist/pine.mjs",
|
|
63
|
-
"require": "./dist/pine.js"
|
|
64
|
-
},
|
|
65
64
|
"./strategies": {
|
|
66
65
|
"types": "./dist/strategies.d.ts",
|
|
67
66
|
"import": "./dist/strategies.mjs",
|
|
@@ -79,7 +78,7 @@
|
|
|
79
78
|
}
|
|
80
79
|
},
|
|
81
80
|
"dependencies": {
|
|
82
|
-
"@tradejs/types": "^1.0.
|
|
81
|
+
"@tradejs/types": "^1.0.3",
|
|
83
82
|
"date-fns": "^3.3.1",
|
|
84
83
|
"klinecharts": "10.0.0-alpha9",
|
|
85
84
|
"lodash": "^4.17.21",
|
package/dist/json.d.mts
DELETED
package/dist/json.d.ts
DELETED
package/dist/json.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/json.ts
|
|
21
|
-
var json_exports = {};
|
|
22
|
-
__export(json_exports, {
|
|
23
|
-
toJson: () => toJson
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(json_exports);
|
|
26
|
-
|
|
27
|
-
// src/utils/toJson.ts
|
|
28
|
-
var toJson = (data, stringify = false) => {
|
|
29
|
-
return stringify ? JSON.stringify(data, null, 2) : JSON.stringify(data);
|
|
30
|
-
};
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
toJson
|
|
34
|
-
});
|
package/dist/json.mjs
DELETED
package/dist/pine.d.mts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Candle } from '@tradejs/types';
|
|
2
|
-
|
|
3
|
-
interface PinePlotPoint {
|
|
4
|
-
title?: string;
|
|
5
|
-
time?: number;
|
|
6
|
-
value?: unknown;
|
|
7
|
-
options?: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
interface PineContextLike {
|
|
10
|
-
plots?: Record<string, {
|
|
11
|
-
data?: PinePlotPoint[];
|
|
12
|
-
}>;
|
|
13
|
-
result?: Record<string, unknown>;
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
}
|
|
16
|
-
interface RunPineScriptParams {
|
|
17
|
-
candles: Candle[];
|
|
18
|
-
script: string;
|
|
19
|
-
symbol?: string;
|
|
20
|
-
timeframe?: string;
|
|
21
|
-
inputs?: Record<string, unknown>;
|
|
22
|
-
limit?: number;
|
|
23
|
-
}
|
|
24
|
-
declare const getPinePlotSeries: (context: PineContextLike, plotName: string) => PinePlotPoint[];
|
|
25
|
-
declare const getLatestPinePlotValue: (context: PineContextLike, plotName: string) => unknown;
|
|
26
|
-
declare const asFiniteNumber: (value: unknown) => number | undefined;
|
|
27
|
-
declare const asPineBoolean: (value: unknown) => boolean;
|
|
28
|
-
|
|
29
|
-
export { type PineContextLike, type PinePlotPoint, type RunPineScriptParams, asFiniteNumber, asPineBoolean, getLatestPinePlotValue, getPinePlotSeries };
|
package/dist/pine.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Candle } from '@tradejs/types';
|
|
2
|
-
|
|
3
|
-
interface PinePlotPoint {
|
|
4
|
-
title?: string;
|
|
5
|
-
time?: number;
|
|
6
|
-
value?: unknown;
|
|
7
|
-
options?: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
interface PineContextLike {
|
|
10
|
-
plots?: Record<string, {
|
|
11
|
-
data?: PinePlotPoint[];
|
|
12
|
-
}>;
|
|
13
|
-
result?: Record<string, unknown>;
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
}
|
|
16
|
-
interface RunPineScriptParams {
|
|
17
|
-
candles: Candle[];
|
|
18
|
-
script: string;
|
|
19
|
-
symbol?: string;
|
|
20
|
-
timeframe?: string;
|
|
21
|
-
inputs?: Record<string, unknown>;
|
|
22
|
-
limit?: number;
|
|
23
|
-
}
|
|
24
|
-
declare const getPinePlotSeries: (context: PineContextLike, plotName: string) => PinePlotPoint[];
|
|
25
|
-
declare const getLatestPinePlotValue: (context: PineContextLike, plotName: string) => unknown;
|
|
26
|
-
declare const asFiniteNumber: (value: unknown) => number | undefined;
|
|
27
|
-
declare const asPineBoolean: (value: unknown) => boolean;
|
|
28
|
-
|
|
29
|
-
export { type PineContextLike, type PinePlotPoint, type RunPineScriptParams, asFiniteNumber, asPineBoolean, getLatestPinePlotValue, getPinePlotSeries };
|
package/dist/pine.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/pine.ts
|
|
21
|
-
var pine_exports = {};
|
|
22
|
-
__export(pine_exports, {
|
|
23
|
-
asFiniteNumber: () => asFiniteNumber,
|
|
24
|
-
asPineBoolean: () => asPineBoolean,
|
|
25
|
-
getLatestPinePlotValue: () => getLatestPinePlotValue,
|
|
26
|
-
getPinePlotSeries: () => getPinePlotSeries
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(pine_exports);
|
|
29
|
-
|
|
30
|
-
// src/utils/pineShared.ts
|
|
31
|
-
var getPinePlotSeries = (context, plotName) => {
|
|
32
|
-
const name = String(plotName || "").trim();
|
|
33
|
-
if (!name) return [];
|
|
34
|
-
const data = context?.plots?.[name]?.data;
|
|
35
|
-
return Array.isArray(data) ? data : [];
|
|
36
|
-
};
|
|
37
|
-
var getLatestPinePlotValue = (context, plotName) => {
|
|
38
|
-
const series = getPinePlotSeries(context, plotName);
|
|
39
|
-
if (!series.length) return void 0;
|
|
40
|
-
return series[series.length - 1]?.value;
|
|
41
|
-
};
|
|
42
|
-
var asFiniteNumber = (value) => {
|
|
43
|
-
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
};
|
|
48
|
-
var asPineBoolean = (value) => {
|
|
49
|
-
if (typeof value === "boolean") return value;
|
|
50
|
-
if (typeof value === "number") return Number.isFinite(value) && value !== 0;
|
|
51
|
-
return false;
|
|
52
|
-
};
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
asFiniteNumber,
|
|
56
|
-
asPineBoolean,
|
|
57
|
-
getLatestPinePlotValue,
|
|
58
|
-
getPinePlotSeries
|
|
59
|
-
});
|
package/dist/pine.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// src/utils/pineShared.ts
|
|
2
|
-
var getPinePlotSeries = (context, plotName) => {
|
|
3
|
-
const name = String(plotName || "").trim();
|
|
4
|
-
if (!name) return [];
|
|
5
|
-
const data = context?.plots?.[name]?.data;
|
|
6
|
-
return Array.isArray(data) ? data : [];
|
|
7
|
-
};
|
|
8
|
-
var getLatestPinePlotValue = (context, plotName) => {
|
|
9
|
-
const series = getPinePlotSeries(context, plotName);
|
|
10
|
-
if (!series.length) return void 0;
|
|
11
|
-
return series[series.length - 1]?.value;
|
|
12
|
-
};
|
|
13
|
-
var asFiniteNumber = (value) => {
|
|
14
|
-
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
15
|
-
return void 0;
|
|
16
|
-
}
|
|
17
|
-
return value;
|
|
18
|
-
};
|
|
19
|
-
var asPineBoolean = (value) => {
|
|
20
|
-
if (typeof value === "boolean") return value;
|
|
21
|
-
if (typeof value === "number") return Number.isFinite(value) && value !== 0;
|
|
22
|
-
return false;
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
asFiniteNumber,
|
|
26
|
-
asPineBoolean,
|
|
27
|
-
getLatestPinePlotValue,
|
|
28
|
-
getPinePlotSeries
|
|
29
|
-
};
|