@tradejs/core 1.0.0
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 +60 -0
- package/dist/api.d.mts +7 -0
- package/dist/api.d.ts +7 -0
- package/dist/api.js +64 -0
- package/dist/api.mjs +39 -0
- package/dist/async.d.mts +4 -0
- package/dist/async.d.ts +4 -0
- package/dist/async.js +48 -0
- package/dist/async.mjs +20 -0
- package/dist/backtest.d.mts +45 -0
- package/dist/backtest.d.ts +45 -0
- package/dist/backtest.js +574 -0
- package/dist/backtest.mjs +355 -0
- package/dist/chunk-AYC2QVKI.mjs +35 -0
- package/dist/chunk-JG2QPVAV.mjs +190 -0
- package/dist/chunk-LIGD3WWX.mjs +1545 -0
- package/dist/chunk-M7QGVZ3J.mjs +61 -0
- package/dist/chunk-NQ7D3T4E.mjs +10 -0
- package/dist/chunk-PXLXXXLA.mjs +67 -0
- package/dist/config.d.mts +14 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +49 -0
- package/dist/config.mjs +21 -0
- package/dist/constants.d.mts +41 -0
- package/dist/constants.d.ts +41 -0
- package/dist/constants.js +238 -0
- package/dist/constants.mjs +50 -0
- package/dist/data.d.mts +9 -0
- package/dist/data.d.ts +9 -0
- package/dist/data.js +100 -0
- package/dist/data.mjs +12 -0
- package/dist/figures.d.mts +103 -0
- package/dist/figures.d.ts +103 -0
- package/dist/figures.js +274 -0
- package/dist/figures.mjs +239 -0
- package/dist/indicators-x3xKl3_W.d.mts +90 -0
- package/dist/indicators-x3xKl3_W.d.ts +90 -0
- package/dist/indicators.d.mts +124 -0
- package/dist/indicators.d.ts +124 -0
- package/dist/indicators.js +1631 -0
- package/dist/indicators.mjs +66 -0
- package/dist/json.d.mts +3 -0
- package/dist/json.d.ts +3 -0
- package/dist/json.js +34 -0
- package/dist/json.mjs +7 -0
- package/dist/math.d.mts +35 -0
- package/dist/math.d.ts +35 -0
- package/dist/math.js +98 -0
- package/dist/math.mjs +38 -0
- package/dist/pine.d.mts +29 -0
- package/dist/pine.d.ts +29 -0
- package/dist/pine.js +59 -0
- package/dist/pine.mjs +29 -0
- package/dist/strategies.d.mts +104 -0
- package/dist/strategies.d.ts +104 -0
- package/dist/strategies.js +1080 -0
- package/dist/strategies.mjs +390 -0
- package/dist/tickers.d.mts +7 -0
- package/dist/tickers.d.ts +7 -0
- package/dist/tickers.js +166 -0
- package/dist/tickers.mjs +125 -0
- package/dist/time-DEyFa2vI.d.mts +11 -0
- package/dist/time-DEyFa2vI.d.ts +11 -0
- package/dist/time.d.mts +2 -0
- package/dist/time.d.ts +2 -0
- package/dist/time.js +58 -0
- package/dist/time.mjs +15 -0
- package/package.json +99 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/utils/array.ts
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
var intervalToMs = (interval) => {
|
|
4
|
+
const minutes = {
|
|
5
|
+
"1": 1,
|
|
6
|
+
"3": 3,
|
|
7
|
+
"5": 5,
|
|
8
|
+
"15": 15,
|
|
9
|
+
"30": 30,
|
|
10
|
+
"60": 60,
|
|
11
|
+
"120": 120,
|
|
12
|
+
"240": 240,
|
|
13
|
+
"360": 360,
|
|
14
|
+
"720": 720
|
|
15
|
+
};
|
|
16
|
+
if (interval in minutes) {
|
|
17
|
+
return minutes[interval] * 60 * 1e3;
|
|
18
|
+
}
|
|
19
|
+
switch (interval) {
|
|
20
|
+
case "D":
|
|
21
|
+
return 24 * 60 * 60 * 1e3;
|
|
22
|
+
case "W":
|
|
23
|
+
return 7 * 24 * 60 * 60 * 1e3;
|
|
24
|
+
case "M":
|
|
25
|
+
return 30 * 24 * 60 * 60 * 1e3;
|
|
26
|
+
default:
|
|
27
|
+
throw new Error(`Unknown interval: ${interval}`);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var mergeData = (a1, a2) => {
|
|
31
|
+
const res = {
|
|
32
|
+
..._.keyBy(a1, "timestamp"),
|
|
33
|
+
..._.keyBy(a2, "timestamp")
|
|
34
|
+
};
|
|
35
|
+
return Object.values(res).sort((b1, b2) => b1.timestamp - b2.timestamp);
|
|
36
|
+
};
|
|
37
|
+
var isWrongData = (interval, data) => {
|
|
38
|
+
if (data.length < 2) return false;
|
|
39
|
+
const step = intervalToMs(interval);
|
|
40
|
+
for (let i = 1; i < data.length; i++) {
|
|
41
|
+
const prev = data[i - 1].timestamp;
|
|
42
|
+
const curr = data[i].timestamp;
|
|
43
|
+
if (curr - prev !== step) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
};
|
|
49
|
+
var cloneArrayValues = (record) => Object.fromEntries(
|
|
50
|
+
Object.entries(record).map(([key, value]) => [
|
|
51
|
+
key,
|
|
52
|
+
Array.isArray(value) ? value.slice() : value
|
|
53
|
+
])
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
intervalToMs,
|
|
58
|
+
mergeData,
|
|
59
|
+
isWrongData,
|
|
60
|
+
cloneArrayValues
|
|
61
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BACKTEST_PRELOAD_DAYS
|
|
3
|
+
} from "./chunk-JG2QPVAV.mjs";
|
|
4
|
+
|
|
5
|
+
// src/utils/timestamp.ts
|
|
6
|
+
import { format } from "date-fns";
|
|
7
|
+
import { getUnixTime, subDays } from "date-fns";
|
|
8
|
+
var TIMELINE_STEP = 864e5;
|
|
9
|
+
var toMs = (ts) => ts < 1e12 ? ts * 1e3 : ts;
|
|
10
|
+
var getTimestamp = (days = 0) => {
|
|
11
|
+
if (days > 0) {
|
|
12
|
+
return getUnixTime(subDays(/* @__PURE__ */ new Date(), days)) * 1e3;
|
|
13
|
+
}
|
|
14
|
+
return getUnixTime(/* @__PURE__ */ new Date()) * 1e3;
|
|
15
|
+
};
|
|
16
|
+
var getItemTimestamp = (item) => item.timestamp;
|
|
17
|
+
var getDataTimestamp = (data) => {
|
|
18
|
+
if (!data.length) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return getItemTimestamp(data[data.length - 1]);
|
|
22
|
+
};
|
|
23
|
+
var formatUnix = (dt) => {
|
|
24
|
+
return format(new Date(dt), "d MMM u HH:mm:ss");
|
|
25
|
+
};
|
|
26
|
+
var getTimeline = (start = getTimestamp(BACKTEST_PRELOAD_DAYS), end = getTimestamp(), step = TIMELINE_STEP) => {
|
|
27
|
+
const res = new Array();
|
|
28
|
+
for (let ind = start; ind <= end; ind += step) {
|
|
29
|
+
res.push(ind);
|
|
30
|
+
}
|
|
31
|
+
return res;
|
|
32
|
+
};
|
|
33
|
+
var compactOrderLog = (timeline, orderLog) => {
|
|
34
|
+
const result = [];
|
|
35
|
+
let currentAmount = orderLog.length > 0 && orderLog[0].amount != null ? orderLog[0].amount : 100;
|
|
36
|
+
let orderLogCursor = 0;
|
|
37
|
+
for (let timelineIndex = 0; timelineIndex < timeline.length; timelineIndex++) {
|
|
38
|
+
const currentTimestamp = timeline[timelineIndex];
|
|
39
|
+
let lastApplicableOrderIndex = -1;
|
|
40
|
+
let nextCursor = orderLogCursor;
|
|
41
|
+
for (let checkIndex = orderLogCursor; checkIndex < orderLog.length; checkIndex++) {
|
|
42
|
+
const checkOrder = orderLog[checkIndex];
|
|
43
|
+
if (checkOrder.timestamp <= currentTimestamp) {
|
|
44
|
+
lastApplicableOrderIndex = checkIndex;
|
|
45
|
+
nextCursor = checkIndex + 1;
|
|
46
|
+
} else {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (lastApplicableOrderIndex !== -1) {
|
|
51
|
+
currentAmount = orderLog[lastApplicableOrderIndex].amount;
|
|
52
|
+
orderLogCursor = nextCursor;
|
|
53
|
+
}
|
|
54
|
+
result.push([currentTimestamp, currentAmount]);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
toMs,
|
|
61
|
+
getTimestamp,
|
|
62
|
+
getItemTimestamp,
|
|
63
|
+
getDataTimestamp,
|
|
64
|
+
formatUnix,
|
|
65
|
+
getTimeline,
|
|
66
|
+
compactOrderLog
|
|
67
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ConnectorPluginDefinition, IndicatorPluginDefinition, StrategyPluginDefinition } from '@tradejs/types';
|
|
2
|
+
|
|
3
|
+
type PluginModuleSpecifier = string;
|
|
4
|
+
interface TradejsConfig {
|
|
5
|
+
strategies?: PluginModuleSpecifier[];
|
|
6
|
+
indicators?: PluginModuleSpecifier[];
|
|
7
|
+
connectors?: PluginModuleSpecifier[];
|
|
8
|
+
}
|
|
9
|
+
declare function defineConfig(...configs: TradejsConfig[]): TradejsConfig;
|
|
10
|
+
declare const defineStrategyPlugin: <T extends StrategyPluginDefinition>(plugin: T) => T;
|
|
11
|
+
declare const defineIndicatorPlugin: <T extends IndicatorPluginDefinition>(plugin: T) => T;
|
|
12
|
+
declare const defineConnectorPlugin: <T extends ConnectorPluginDefinition>(plugin: T) => T;
|
|
13
|
+
|
|
14
|
+
export { type PluginModuleSpecifier, type TradejsConfig, defineConfig, defineConnectorPlugin, defineIndicatorPlugin, defineStrategyPlugin };
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ConnectorPluginDefinition, IndicatorPluginDefinition, StrategyPluginDefinition } from '@tradejs/types';
|
|
2
|
+
|
|
3
|
+
type PluginModuleSpecifier = string;
|
|
4
|
+
interface TradejsConfig {
|
|
5
|
+
strategies?: PluginModuleSpecifier[];
|
|
6
|
+
indicators?: PluginModuleSpecifier[];
|
|
7
|
+
connectors?: PluginModuleSpecifier[];
|
|
8
|
+
}
|
|
9
|
+
declare function defineConfig(...configs: TradejsConfig[]): TradejsConfig;
|
|
10
|
+
declare const defineStrategyPlugin: <T extends StrategyPluginDefinition>(plugin: T) => T;
|
|
11
|
+
declare const defineIndicatorPlugin: <T extends IndicatorPluginDefinition>(plugin: T) => T;
|
|
12
|
+
declare const defineConnectorPlugin: <T extends ConnectorPluginDefinition>(plugin: T) => T;
|
|
13
|
+
|
|
14
|
+
export { type PluginModuleSpecifier, type TradejsConfig, defineConfig, defineConnectorPlugin, defineIndicatorPlugin, defineStrategyPlugin };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
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/config.ts
|
|
21
|
+
var config_exports = {};
|
|
22
|
+
__export(config_exports, {
|
|
23
|
+
defineConfig: () => defineConfig,
|
|
24
|
+
defineConnectorPlugin: () => defineConnectorPlugin,
|
|
25
|
+
defineIndicatorPlugin: () => defineIndicatorPlugin,
|
|
26
|
+
defineStrategyPlugin: () => defineStrategyPlugin
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(config_exports);
|
|
29
|
+
var normalizePlugins = (values) => Array.isArray(values) ? values.map((value) => String(value ?? "").trim()).filter(Boolean) : [];
|
|
30
|
+
var mergePluginSpecifiers = (...groups) => [
|
|
31
|
+
...new Set(groups.flatMap((group) => normalizePlugins(group)))
|
|
32
|
+
];
|
|
33
|
+
function defineConfig(...configs) {
|
|
34
|
+
return {
|
|
35
|
+
strategies: mergePluginSpecifiers(...configs.map((cfg) => cfg.strategies)),
|
|
36
|
+
indicators: mergePluginSpecifiers(...configs.map((cfg) => cfg.indicators)),
|
|
37
|
+
connectors: mergePluginSpecifiers(...configs.map((cfg) => cfg.connectors))
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var defineStrategyPlugin = (plugin) => plugin;
|
|
41
|
+
var defineIndicatorPlugin = (plugin) => plugin;
|
|
42
|
+
var defineConnectorPlugin = (plugin) => plugin;
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
defineConfig,
|
|
46
|
+
defineConnectorPlugin,
|
|
47
|
+
defineIndicatorPlugin,
|
|
48
|
+
defineStrategyPlugin
|
|
49
|
+
});
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
var normalizePlugins = (values) => Array.isArray(values) ? values.map((value) => String(value ?? "").trim()).filter(Boolean) : [];
|
|
3
|
+
var mergePluginSpecifiers = (...groups) => [
|
|
4
|
+
...new Set(groups.flatMap((group) => normalizePlugins(group)))
|
|
5
|
+
];
|
|
6
|
+
function defineConfig(...configs) {
|
|
7
|
+
return {
|
|
8
|
+
strategies: mergePluginSpecifiers(...configs.map((cfg) => cfg.strategies)),
|
|
9
|
+
indicators: mergePluginSpecifiers(...configs.map((cfg) => cfg.indicators)),
|
|
10
|
+
connectors: mergePluginSpecifiers(...configs.map((cfg) => cfg.connectors))
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
var defineStrategyPlugin = (plugin) => plugin;
|
|
14
|
+
var defineIndicatorPlugin = (plugin) => plugin;
|
|
15
|
+
var defineConnectorPlugin = (plugin) => plugin;
|
|
16
|
+
export {
|
|
17
|
+
defineConfig,
|
|
18
|
+
defineConnectorPlugin,
|
|
19
|
+
defineIndicatorPlugin,
|
|
20
|
+
defineStrategyPlugin
|
|
21
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TestThresholds } from '@tradejs/types';
|
|
2
|
+
|
|
3
|
+
declare const FEE_PERCENT = 0.005;
|
|
4
|
+
declare const CORRELATION_WINDOW = 50;
|
|
5
|
+
declare const SPREAD_WINDOW = 50;
|
|
6
|
+
declare const PRELOAD_DAYS = 200;
|
|
7
|
+
declare const SIGNALS_PRELOAD_DAYS = 60;
|
|
8
|
+
declare const BACKTEST_PRELOAD_DAYS = 160;
|
|
9
|
+
declare const DASHBOARD_PRELOAD_DAYS = 160;
|
|
10
|
+
declare const BOT_PRELOAD_DAYS = 160;
|
|
11
|
+
declare const PRELOAD_FALLBACK_DAYS = 160;
|
|
12
|
+
declare const TTL_1H = 3600;
|
|
13
|
+
declare const TTL_3H = 10800;
|
|
14
|
+
declare const TTL_12H = 43300;
|
|
15
|
+
declare const TTL_1D = 86400;
|
|
16
|
+
declare const TTL_1M = 2600000;
|
|
17
|
+
declare const TTL_3M = 7800000;
|
|
18
|
+
declare const TESTS_TOP_LIMIT = 50;
|
|
19
|
+
declare const TESTS_LIMIT = 100000;
|
|
20
|
+
declare const TESTS_ORDERS_MIN_LIMIT = 3;
|
|
21
|
+
declare const MARKET_CATEGORY = "linear";
|
|
22
|
+
declare const ML_CANDLE_FEATURE_WINDOW = 50;
|
|
23
|
+
declare const ML_BASE_CANDLES_WINDOW = 50;
|
|
24
|
+
declare const TRENDLINE_DEFAULTS: {
|
|
25
|
+
maxLines: number;
|
|
26
|
+
range: number;
|
|
27
|
+
firstRange: number;
|
|
28
|
+
epsilon: number;
|
|
29
|
+
epsilonOffset: number;
|
|
30
|
+
minTouches: number;
|
|
31
|
+
minDistance: number;
|
|
32
|
+
minTouchGap: number;
|
|
33
|
+
maxTouchGap: number;
|
|
34
|
+
offset: number;
|
|
35
|
+
capture: boolean;
|
|
36
|
+
bestLines: number;
|
|
37
|
+
maxDistance: number;
|
|
38
|
+
};
|
|
39
|
+
declare const TestThresholdsConfig: TestThresholds;
|
|
40
|
+
|
|
41
|
+
export { BACKTEST_PRELOAD_DAYS, BOT_PRELOAD_DAYS, CORRELATION_WINDOW, DASHBOARD_PRELOAD_DAYS, FEE_PERCENT, MARKET_CATEGORY, ML_BASE_CANDLES_WINDOW, ML_CANDLE_FEATURE_WINDOW, PRELOAD_DAYS, PRELOAD_FALLBACK_DAYS, SIGNALS_PRELOAD_DAYS, SPREAD_WINDOW, TESTS_LIMIT, TESTS_ORDERS_MIN_LIMIT, TESTS_TOP_LIMIT, TRENDLINE_DEFAULTS, TTL_12H, TTL_1D, TTL_1H, TTL_1M, TTL_3H, TTL_3M, TestThresholdsConfig };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TestThresholds } from '@tradejs/types';
|
|
2
|
+
|
|
3
|
+
declare const FEE_PERCENT = 0.005;
|
|
4
|
+
declare const CORRELATION_WINDOW = 50;
|
|
5
|
+
declare const SPREAD_WINDOW = 50;
|
|
6
|
+
declare const PRELOAD_DAYS = 200;
|
|
7
|
+
declare const SIGNALS_PRELOAD_DAYS = 60;
|
|
8
|
+
declare const BACKTEST_PRELOAD_DAYS = 160;
|
|
9
|
+
declare const DASHBOARD_PRELOAD_DAYS = 160;
|
|
10
|
+
declare const BOT_PRELOAD_DAYS = 160;
|
|
11
|
+
declare const PRELOAD_FALLBACK_DAYS = 160;
|
|
12
|
+
declare const TTL_1H = 3600;
|
|
13
|
+
declare const TTL_3H = 10800;
|
|
14
|
+
declare const TTL_12H = 43300;
|
|
15
|
+
declare const TTL_1D = 86400;
|
|
16
|
+
declare const TTL_1M = 2600000;
|
|
17
|
+
declare const TTL_3M = 7800000;
|
|
18
|
+
declare const TESTS_TOP_LIMIT = 50;
|
|
19
|
+
declare const TESTS_LIMIT = 100000;
|
|
20
|
+
declare const TESTS_ORDERS_MIN_LIMIT = 3;
|
|
21
|
+
declare const MARKET_CATEGORY = "linear";
|
|
22
|
+
declare const ML_CANDLE_FEATURE_WINDOW = 50;
|
|
23
|
+
declare const ML_BASE_CANDLES_WINDOW = 50;
|
|
24
|
+
declare const TRENDLINE_DEFAULTS: {
|
|
25
|
+
maxLines: number;
|
|
26
|
+
range: number;
|
|
27
|
+
firstRange: number;
|
|
28
|
+
epsilon: number;
|
|
29
|
+
epsilonOffset: number;
|
|
30
|
+
minTouches: number;
|
|
31
|
+
minDistance: number;
|
|
32
|
+
minTouchGap: number;
|
|
33
|
+
maxTouchGap: number;
|
|
34
|
+
offset: number;
|
|
35
|
+
capture: boolean;
|
|
36
|
+
bestLines: number;
|
|
37
|
+
maxDistance: number;
|
|
38
|
+
};
|
|
39
|
+
declare const TestThresholdsConfig: TestThresholds;
|
|
40
|
+
|
|
41
|
+
export { BACKTEST_PRELOAD_DAYS, BOT_PRELOAD_DAYS, CORRELATION_WINDOW, DASHBOARD_PRELOAD_DAYS, FEE_PERCENT, MARKET_CATEGORY, ML_BASE_CANDLES_WINDOW, ML_CANDLE_FEATURE_WINDOW, PRELOAD_DAYS, PRELOAD_FALLBACK_DAYS, SIGNALS_PRELOAD_DAYS, SPREAD_WINDOW, TESTS_LIMIT, TESTS_ORDERS_MIN_LIMIT, TESTS_TOP_LIMIT, TRENDLINE_DEFAULTS, TTL_12H, TTL_1D, TTL_1H, TTL_1M, TTL_3H, TTL_3M, TestThresholdsConfig };
|
|
@@ -0,0 +1,238 @@
|
|
|
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/constants.ts
|
|
21
|
+
var constants_exports = {};
|
|
22
|
+
__export(constants_exports, {
|
|
23
|
+
BACKTEST_PRELOAD_DAYS: () => BACKTEST_PRELOAD_DAYS,
|
|
24
|
+
BOT_PRELOAD_DAYS: () => BOT_PRELOAD_DAYS,
|
|
25
|
+
CORRELATION_WINDOW: () => CORRELATION_WINDOW,
|
|
26
|
+
DASHBOARD_PRELOAD_DAYS: () => DASHBOARD_PRELOAD_DAYS,
|
|
27
|
+
FEE_PERCENT: () => FEE_PERCENT,
|
|
28
|
+
MARKET_CATEGORY: () => MARKET_CATEGORY,
|
|
29
|
+
ML_BASE_CANDLES_WINDOW: () => ML_BASE_CANDLES_WINDOW,
|
|
30
|
+
ML_CANDLE_FEATURE_WINDOW: () => ML_CANDLE_FEATURE_WINDOW,
|
|
31
|
+
PRELOAD_DAYS: () => PRELOAD_DAYS,
|
|
32
|
+
PRELOAD_FALLBACK_DAYS: () => PRELOAD_FALLBACK_DAYS,
|
|
33
|
+
SIGNALS_PRELOAD_DAYS: () => SIGNALS_PRELOAD_DAYS,
|
|
34
|
+
SPREAD_WINDOW: () => SPREAD_WINDOW,
|
|
35
|
+
TESTS_LIMIT: () => TESTS_LIMIT,
|
|
36
|
+
TESTS_ORDERS_MIN_LIMIT: () => TESTS_ORDERS_MIN_LIMIT,
|
|
37
|
+
TESTS_TOP_LIMIT: () => TESTS_TOP_LIMIT,
|
|
38
|
+
TRENDLINE_DEFAULTS: () => TRENDLINE_DEFAULTS,
|
|
39
|
+
TTL_12H: () => TTL_12H,
|
|
40
|
+
TTL_1D: () => TTL_1D,
|
|
41
|
+
TTL_1H: () => TTL_1H,
|
|
42
|
+
TTL_1M: () => TTL_1M,
|
|
43
|
+
TTL_3H: () => TTL_3H,
|
|
44
|
+
TTL_3M: () => TTL_3M,
|
|
45
|
+
TestThresholdsConfig: () => TestThresholdsConfig
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(constants_exports);
|
|
48
|
+
|
|
49
|
+
// src/constants/index.ts
|
|
50
|
+
var FEE_PERCENT = 5e-3;
|
|
51
|
+
var CORRELATION_WINDOW = 50;
|
|
52
|
+
var SPREAD_WINDOW = 50;
|
|
53
|
+
var PRELOAD_DAYS = 200;
|
|
54
|
+
var SIGNALS_PRELOAD_DAYS = 60;
|
|
55
|
+
var BACKTEST_PRELOAD_DAYS = 160;
|
|
56
|
+
var DASHBOARD_PRELOAD_DAYS = 160;
|
|
57
|
+
var BOT_PRELOAD_DAYS = 160;
|
|
58
|
+
var PRELOAD_FALLBACK_DAYS = 160;
|
|
59
|
+
var TTL_1H = 3600;
|
|
60
|
+
var TTL_3H = 10800;
|
|
61
|
+
var TTL_12H = 43300;
|
|
62
|
+
var TTL_1D = 86400;
|
|
63
|
+
var TTL_1M = 26e5;
|
|
64
|
+
var TTL_3M = 78e5;
|
|
65
|
+
var TESTS_TOP_LIMIT = 50;
|
|
66
|
+
var TESTS_LIMIT = 1e5;
|
|
67
|
+
var TESTS_ORDERS_MIN_LIMIT = 3;
|
|
68
|
+
var MARKET_CATEGORY = "linear";
|
|
69
|
+
var ML_CANDLE_FEATURE_WINDOW = 50;
|
|
70
|
+
var ML_BASE_CANDLES_WINDOW = 50;
|
|
71
|
+
var TRENDLINE_DEFAULTS = {
|
|
72
|
+
maxLines: 20,
|
|
73
|
+
range: 15,
|
|
74
|
+
firstRange: 80,
|
|
75
|
+
epsilon: 3e-3,
|
|
76
|
+
epsilonOffset: 5e-3,
|
|
77
|
+
minTouches: 4,
|
|
78
|
+
minDistance: 50,
|
|
79
|
+
minTouchGap: 15,
|
|
80
|
+
maxTouchGap: 60,
|
|
81
|
+
offset: 1e3,
|
|
82
|
+
capture: false,
|
|
83
|
+
bestLines: 4,
|
|
84
|
+
maxDistance: 2e3
|
|
85
|
+
};
|
|
86
|
+
var TestThresholdsConfig = {
|
|
87
|
+
// Период и частота — используем как требования к качеству теста, в скоринг не влияют
|
|
88
|
+
periodDays: {
|
|
89
|
+
thresholds: [30, 120],
|
|
90
|
+
direction: "higher",
|
|
91
|
+
precision: 0
|
|
92
|
+
},
|
|
93
|
+
periodMonths: {
|
|
94
|
+
thresholds: [1, 6],
|
|
95
|
+
direction: "higher",
|
|
96
|
+
precision: 2
|
|
97
|
+
},
|
|
98
|
+
orders: {
|
|
99
|
+
thresholds: [30, 200],
|
|
100
|
+
direction: "higher",
|
|
101
|
+
precision: 0
|
|
102
|
+
},
|
|
103
|
+
wins: {
|
|
104
|
+
thresholds: [30, 100],
|
|
105
|
+
direction: "higher",
|
|
106
|
+
precision: 0
|
|
107
|
+
},
|
|
108
|
+
losses: {
|
|
109
|
+
thresholds: [20, 50],
|
|
110
|
+
direction: "lower",
|
|
111
|
+
precision: 0
|
|
112
|
+
},
|
|
113
|
+
ordersPerMonth: {
|
|
114
|
+
thresholds: [4, 20],
|
|
115
|
+
direction: "higher",
|
|
116
|
+
precision: 2
|
|
117
|
+
},
|
|
118
|
+
exposure: {
|
|
119
|
+
thresholds: [20, 60],
|
|
120
|
+
direction: "higher",
|
|
121
|
+
isPercent: true,
|
|
122
|
+
precision: 1
|
|
123
|
+
},
|
|
124
|
+
// Доходность
|
|
125
|
+
amount: {
|
|
126
|
+
thresholds: [105, 120],
|
|
127
|
+
direction: "higher",
|
|
128
|
+
isAmount: true,
|
|
129
|
+
precision: 2
|
|
130
|
+
},
|
|
131
|
+
maxAmount: {
|
|
132
|
+
thresholds: [140, 180],
|
|
133
|
+
direction: "higher",
|
|
134
|
+
isAmount: true,
|
|
135
|
+
precision: 2
|
|
136
|
+
},
|
|
137
|
+
minAmount: {
|
|
138
|
+
thresholds: [80, 90],
|
|
139
|
+
direction: "higher",
|
|
140
|
+
isAmount: true,
|
|
141
|
+
precision: 2
|
|
142
|
+
},
|
|
143
|
+
netProfit: {
|
|
144
|
+
thresholds: [5, 20],
|
|
145
|
+
direction: "higher",
|
|
146
|
+
isAmount: true,
|
|
147
|
+
precision: 2
|
|
148
|
+
},
|
|
149
|
+
totalReturn: {
|
|
150
|
+
thresholds: [10, 50],
|
|
151
|
+
direction: "higher",
|
|
152
|
+
isPercent: true,
|
|
153
|
+
precision: 1
|
|
154
|
+
},
|
|
155
|
+
cagr: {
|
|
156
|
+
thresholds: [15, 40],
|
|
157
|
+
direction: "higher",
|
|
158
|
+
isPercent: true,
|
|
159
|
+
precision: 1
|
|
160
|
+
},
|
|
161
|
+
// Риск и риск/доходность
|
|
162
|
+
maxDrawdown: {
|
|
163
|
+
thresholds: [25, 12],
|
|
164
|
+
direction: "lower",
|
|
165
|
+
isPercent: true,
|
|
166
|
+
precision: 1
|
|
167
|
+
},
|
|
168
|
+
calmar: {
|
|
169
|
+
thresholds: [0.5, 2],
|
|
170
|
+
direction: "higher",
|
|
171
|
+
precision: 2
|
|
172
|
+
},
|
|
173
|
+
// Качество сделок
|
|
174
|
+
winRate: {
|
|
175
|
+
thresholds: [40, 60],
|
|
176
|
+
direction: "higher",
|
|
177
|
+
isPercent: true,
|
|
178
|
+
precision: 1
|
|
179
|
+
},
|
|
180
|
+
riskRewardRatio: {
|
|
181
|
+
thresholds: [1.5, 2.5],
|
|
182
|
+
direction: "higher",
|
|
183
|
+
precision: 2
|
|
184
|
+
},
|
|
185
|
+
expectancy: {
|
|
186
|
+
thresholds: [0.3, 1],
|
|
187
|
+
direction: "higher",
|
|
188
|
+
isPercent: true,
|
|
189
|
+
precision: 2
|
|
190
|
+
},
|
|
191
|
+
maxConsecutiveWins: {
|
|
192
|
+
thresholds: [2, 6],
|
|
193
|
+
direction: "higher",
|
|
194
|
+
precision: 0
|
|
195
|
+
},
|
|
196
|
+
maxConsecutiveLosses: {
|
|
197
|
+
thresholds: [5, 2],
|
|
198
|
+
direction: "lower",
|
|
199
|
+
precision: 0
|
|
200
|
+
},
|
|
201
|
+
// Sharpe (годовой, по месячным ретернам equity)
|
|
202
|
+
sharpeRatio: {
|
|
203
|
+
thresholds: [0.5, 1.5],
|
|
204
|
+
direction: "higher",
|
|
205
|
+
precision: 2
|
|
206
|
+
},
|
|
207
|
+
score: {
|
|
208
|
+
thresholds: [10, 100],
|
|
209
|
+
direction: "higher",
|
|
210
|
+
precision: 0
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
214
|
+
0 && (module.exports = {
|
|
215
|
+
BACKTEST_PRELOAD_DAYS,
|
|
216
|
+
BOT_PRELOAD_DAYS,
|
|
217
|
+
CORRELATION_WINDOW,
|
|
218
|
+
DASHBOARD_PRELOAD_DAYS,
|
|
219
|
+
FEE_PERCENT,
|
|
220
|
+
MARKET_CATEGORY,
|
|
221
|
+
ML_BASE_CANDLES_WINDOW,
|
|
222
|
+
ML_CANDLE_FEATURE_WINDOW,
|
|
223
|
+
PRELOAD_DAYS,
|
|
224
|
+
PRELOAD_FALLBACK_DAYS,
|
|
225
|
+
SIGNALS_PRELOAD_DAYS,
|
|
226
|
+
SPREAD_WINDOW,
|
|
227
|
+
TESTS_LIMIT,
|
|
228
|
+
TESTS_ORDERS_MIN_LIMIT,
|
|
229
|
+
TESTS_TOP_LIMIT,
|
|
230
|
+
TRENDLINE_DEFAULTS,
|
|
231
|
+
TTL_12H,
|
|
232
|
+
TTL_1D,
|
|
233
|
+
TTL_1H,
|
|
234
|
+
TTL_1M,
|
|
235
|
+
TTL_3H,
|
|
236
|
+
TTL_3M,
|
|
237
|
+
TestThresholdsConfig
|
|
238
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BACKTEST_PRELOAD_DAYS,
|
|
3
|
+
BOT_PRELOAD_DAYS,
|
|
4
|
+
CORRELATION_WINDOW,
|
|
5
|
+
DASHBOARD_PRELOAD_DAYS,
|
|
6
|
+
FEE_PERCENT,
|
|
7
|
+
MARKET_CATEGORY,
|
|
8
|
+
ML_BASE_CANDLES_WINDOW,
|
|
9
|
+
ML_CANDLE_FEATURE_WINDOW,
|
|
10
|
+
PRELOAD_DAYS,
|
|
11
|
+
PRELOAD_FALLBACK_DAYS,
|
|
12
|
+
SIGNALS_PRELOAD_DAYS,
|
|
13
|
+
SPREAD_WINDOW,
|
|
14
|
+
TESTS_LIMIT,
|
|
15
|
+
TESTS_ORDERS_MIN_LIMIT,
|
|
16
|
+
TESTS_TOP_LIMIT,
|
|
17
|
+
TRENDLINE_DEFAULTS,
|
|
18
|
+
TTL_12H,
|
|
19
|
+
TTL_1D,
|
|
20
|
+
TTL_1H,
|
|
21
|
+
TTL_1M,
|
|
22
|
+
TTL_3H,
|
|
23
|
+
TTL_3M,
|
|
24
|
+
TestThresholdsConfig
|
|
25
|
+
} from "./chunk-JG2QPVAV.mjs";
|
|
26
|
+
export {
|
|
27
|
+
BACKTEST_PRELOAD_DAYS,
|
|
28
|
+
BOT_PRELOAD_DAYS,
|
|
29
|
+
CORRELATION_WINDOW,
|
|
30
|
+
DASHBOARD_PRELOAD_DAYS,
|
|
31
|
+
FEE_PERCENT,
|
|
32
|
+
MARKET_CATEGORY,
|
|
33
|
+
ML_BASE_CANDLES_WINDOW,
|
|
34
|
+
ML_CANDLE_FEATURE_WINDOW,
|
|
35
|
+
PRELOAD_DAYS,
|
|
36
|
+
PRELOAD_FALLBACK_DAYS,
|
|
37
|
+
SIGNALS_PRELOAD_DAYS,
|
|
38
|
+
SPREAD_WINDOW,
|
|
39
|
+
TESTS_LIMIT,
|
|
40
|
+
TESTS_ORDERS_MIN_LIMIT,
|
|
41
|
+
TESTS_TOP_LIMIT,
|
|
42
|
+
TRENDLINE_DEFAULTS,
|
|
43
|
+
TTL_12H,
|
|
44
|
+
TTL_1D,
|
|
45
|
+
TTL_1H,
|
|
46
|
+
TTL_1M,
|
|
47
|
+
TTL_3H,
|
|
48
|
+
TTL_3M,
|
|
49
|
+
TestThresholdsConfig
|
|
50
|
+
};
|
package/dist/data.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _tradejs_types from '@tradejs/types';
|
|
2
|
+
import { Interval, KlineChartData } from '@tradejs/types';
|
|
3
|
+
|
|
4
|
+
declare const intervalToMs: (interval: Interval) => number;
|
|
5
|
+
declare const mergeData: (a1: KlineChartData, a2: KlineChartData) => _tradejs_types.KlineChartItem[];
|
|
6
|
+
declare const isWrongData: (interval: Interval, data: KlineChartData) => boolean;
|
|
7
|
+
declare const cloneArrayValues: <T>(record: Record<string, T>) => Record<string, T>;
|
|
8
|
+
|
|
9
|
+
export { cloneArrayValues, intervalToMs, isWrongData, mergeData };
|
package/dist/data.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _tradejs_types from '@tradejs/types';
|
|
2
|
+
import { Interval, KlineChartData } from '@tradejs/types';
|
|
3
|
+
|
|
4
|
+
declare const intervalToMs: (interval: Interval) => number;
|
|
5
|
+
declare const mergeData: (a1: KlineChartData, a2: KlineChartData) => _tradejs_types.KlineChartItem[];
|
|
6
|
+
declare const isWrongData: (interval: Interval, data: KlineChartData) => boolean;
|
|
7
|
+
declare const cloneArrayValues: <T>(record: Record<string, T>) => Record<string, T>;
|
|
8
|
+
|
|
9
|
+
export { cloneArrayValues, intervalToMs, isWrongData, mergeData };
|