@tradejs/core 1.0.0 → 1.0.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/README.md +0 -3
- 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/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`.
|
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
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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.2",
|
|
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
|
-
};
|