@tradejs/node 1.0.12 → 2.0.1

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/LICENSE ADDED
@@ -0,0 +1,96 @@
1
+ Business Source License 1.1
2
+
3
+ Parameters
4
+
5
+ Licensor: TradeJS-Dev
6
+
7
+ Licensed Work: The software contained in this package, version 2.0.0 and later.
8
+
9
+ Additional Use Grant: You may make production use of the Licensed Work,
10
+ provided that you do not use the Licensed Work to offer a Competing Offering
11
+ to third parties.
12
+
13
+ A "Competing Offering" is a product or hosted or managed service whose primary
14
+ purpose is to provide a substantial portion of the functionality of TradeJS,
15
+ including strategy authoring, backtesting, live signal generation, automated
16
+ trading, or machine-learning training and inference workflows.
17
+
18
+ Internal use by you or your organization, including use for your own trading,
19
+ research, analytics, or operations, is not a Competing Offering.
20
+
21
+ Change Date: 2030-07-17
22
+
23
+ Change License: GNU Affero General Public License Version 3
24
+
25
+ For commercial licensing of a Competing Offering, contact the TradeJS-Dev
26
+ maintainers through https://github.com/TradeJS-Dev/TradeJS.
27
+
28
+ License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
29
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
30
+
31
+ Terms
32
+
33
+ The Licensor hereby grants you the right to copy, modify, create derivative
34
+ works, redistribute, and make non-production use of the Licensed Work. The
35
+ Licensor may make an Additional Use Grant, above, permitting limited
36
+ production use.
37
+
38
+ Effective on the Change Date, or the fourth anniversary of the first publicly
39
+ available distribution of a specific version of the Licensed Work under this
40
+ License, whichever comes first, the Licensor hereby grants you rights under
41
+ the terms of the Change License, and the rights granted in the paragraph
42
+ above terminate.
43
+
44
+ If your use of the Licensed Work does not comply with the requirements
45
+ currently in effect as described in this License, you must purchase a
46
+ commercial license from the Licensor, its affiliated entities, or authorized
47
+ resellers, or you must refrain from using the Licensed Work.
48
+
49
+ All copies of the original and modified Licensed Work, and derivative works
50
+ of the Licensed Work, are subject to this License. This License applies
51
+ separately for each version of the Licensed Work and the Change Date may vary
52
+ for each version of the Licensed Work released by Licensor.
53
+
54
+ You must conspicuously display this License on each original or modified copy
55
+ of the Licensed Work. If you receive the Licensed Work in original or
56
+ modified form from a third party, the terms and conditions set forth in this
57
+ License apply to your use of that work.
58
+
59
+ Any use of the Licensed Work in violation of this License will automatically
60
+ terminate your rights under this License for the current and all other
61
+ versions of the Licensed Work.
62
+
63
+ This License does not grant you any right in any trademark or logo of
64
+ Licensor or its affiliates (provided that you may use a trademark or logo of
65
+ Licensor as expressly required by this License).
66
+
67
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
68
+ AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
69
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
70
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
71
+ TITLE.
72
+
73
+ MariaDB hereby grants you permission to use this License’s text to license
74
+ your works, and to refer to it using the trademark “Business Source License”,
75
+ as long as you comply with the Covenants of Licensor below.
76
+
77
+ Covenants of Licensor
78
+
79
+ In consideration of the right to use this License’s text and the “Business
80
+ Source License” name and trademark, Licensor covenants to MariaDB, and to all
81
+ other recipients of the licensed work to be provided by Licensor:
82
+
83
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
84
+ or a license that is compatible with GPL Version 2.0 or a later version,
85
+ where “compatible” means that software provided under the Change License can
86
+ be included in a program with software provided under GPL Version 2.0 or a
87
+ later version. Licensor may specify additional Change Licenses without
88
+ limitation.
89
+
90
+ 2. To either: (a) specify an additional grant of rights to use that does not
91
+ impose any additional restriction on the right granted in this License, as
92
+ the Additional Use Grant; or (b) insert the text “None”.
93
+
94
+ 3. To specify a Change Date.
95
+
96
+ 4. Not to modify this License in any other way.
package/README.md CHANGED
@@ -1,11 +1,19 @@
1
1
  # @tradejs/node
2
2
 
3
- Node-only runtime package for the TradeJS open-source framework.
3
+ Node-only runtime package for the TradeJS TypeScript framework.
4
4
 
5
5
  - Homepage: https://tradejs.dev
6
6
  - Documentation: https://docs.tradejs.dev
7
7
  - Quickstart: https://docs.tradejs.dev/getting-started/quickstart
8
8
 
9
+ ## License
10
+
11
+ Version 2.0.0 and later is licensed under Business Source License 1.1. The
12
+ Additional Use Grant permits internal and other non-competing production use;
13
+ providing a competing product or service requires a commercial license.
14
+ Earlier releases remain MIT-licensed. See the
15
+ [TradeJS licensing policy](https://github.com/TradeJS-Dev/TradeJS/blob/stable/LICENSING.md).
16
+
9
17
  ## Where It Fits
10
18
 
11
19
  `@tradejs/node` is the server/runtime half of TradeJS.
package/dist/backtest.js CHANGED
@@ -1842,7 +1842,8 @@ var import_strategies3 = require("@tradejs/core/strategies");
1842
1842
  var import_constants = require("@tradejs/core/constants");
1843
1843
  var import_timescale3 = require("@tradejs/infra/timescale");
1844
1844
  var import_logger5 = require("@tradejs/infra/logger");
1845
- var DEFAULT_INTERVALS = ["15m", "1h"];
1845
+ var SOURCE_INTERVALS = ["15m"];
1846
+ var CONTEXT_INTERVALS = ["15m", "1h"];
1846
1847
  var DEFAULT_LOOKBACK_HOURS = 48;
1847
1848
  var PRIMARY_DERIVATIVES_REFERENCE_SYMBOL = import_constants.DERIVATIVES_CONTEXT_BASE_REFERENCE_SYMBOLS[0];
1848
1849
  var SECONDARY_DERIVATIVES_REFERENCE_SYMBOL = import_constants.DERIVATIVES_CONTEXT_BASE_REFERENCE_SYMBOLS[1];
@@ -1867,12 +1868,10 @@ var parseLookbackMs = () => {
1867
1868
  const normalizedHours = Number.isFinite(hours) && hours > 0 ? hours : DEFAULT_LOOKBACK_HOURS;
1868
1869
  return normalizedHours * 60 * 60 * 1e3;
1869
1870
  };
1870
- var parseIntervals = () => {
1871
- const fromEnv = (0, import_indicators2.normalizeDerivativesIntervals)(
1872
- process.env.DERIVATIVES_CONTEXT_INTERVALS
1873
- );
1874
- return fromEnv.length ? fromEnv : DEFAULT_INTERVALS;
1875
- };
1871
+ var withDerivedHourlyRows = (rowsByInterval) => ({
1872
+ "15m": rowsByInterval["15m"] ?? [],
1873
+ "1h": (0, import_indicators2.deriveCoinalyzeHourlyRowsFrom15m)(rowsByInterval["15m"])
1874
+ });
1876
1875
  var getDerivativesContextReferenceSymbols = () => [
1877
1876
  ...(0, import_constants.resolveDerivativesContextReferenceSymbols)(
1878
1877
  process.env.DERIVATIVES_CONTEXT_EXTRA_REFERENCE_SYMBOLS
@@ -1992,7 +1991,6 @@ var enrichSignalWithDerivativesContext = async (params) => {
1992
1991
  return false;
1993
1992
  }
1994
1993
  try {
1995
- const intervals = parseIntervals();
1996
1994
  const referenceSymbols = getDerivativesContextReferenceSymbols();
1997
1995
  const targetSymbol = normalizeSymbol(signal.symbol);
1998
1996
  const lookbackMs = parseLookbackMs();
@@ -2000,7 +1998,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
2000
1998
  referenceSymbols.map(async (symbol) => {
2001
1999
  const rowsByInterval = await (0, import_timescale3.getDerivativesWindow)({
2002
2000
  symbol,
2003
- intervals,
2001
+ intervals: SOURCE_INTERVALS,
2004
2002
  endMs: signal.timestamp,
2005
2003
  lookbackMs
2006
2004
  });
@@ -2010,9 +2008,9 @@ var enrichSignalWithDerivativesContext = async (params) => {
2010
2008
  symbol,
2011
2009
  direction: signal.direction,
2012
2010
  timestamp: signal.timestamp,
2013
- rowsByInterval,
2011
+ rowsByInterval: withDerivedHourlyRows(rowsByInterval),
2014
2012
  priceChangePct1h: getSignalPriceChangePct1h(signal),
2015
- intervals
2013
+ intervals: CONTEXT_INTERVALS
2016
2014
  })
2017
2015
  ];
2018
2016
  })
@@ -2028,7 +2026,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
2028
2026
  const fetchedTargetContext = shouldFetchTargetContext ? await (async () => {
2029
2027
  const rowsByInterval = await (0, import_timescale3.getDerivativesWindow)({
2030
2028
  symbol: targetSymbol,
2031
- intervals,
2029
+ intervals: SOURCE_INTERVALS,
2032
2030
  endMs: signal.timestamp,
2033
2031
  lookbackMs
2034
2032
  });
@@ -2036,9 +2034,9 @@ var enrichSignalWithDerivativesContext = async (params) => {
2036
2034
  symbol: targetSymbol,
2037
2035
  direction: signal.direction,
2038
2036
  timestamp: signal.timestamp,
2039
- rowsByInterval,
2037
+ rowsByInterval: withDerivedHourlyRows(rowsByInterval),
2040
2038
  priceChangePct1h: getSignalPriceChangePct1h(signal),
2041
- intervals
2039
+ intervals: CONTEXT_INTERVALS
2042
2040
  });
2043
2041
  return hasDerivativesSymbolData(context) ? context : void 0;
2044
2042
  })() : void 0;
package/dist/backtest.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  enrichSignalWithBinanceMarketContext,
8
8
  enrichSignalWithCoinMarketCapContext,
9
9
  enrichSignalWithDerivativesContext
10
- } from "./chunk-37VNDZVX.mjs";
10
+ } from "./chunk-2XFDY6AT.mjs";
11
11
  import {
12
12
  buildAiPayload
13
13
  } from "./chunk-IUZML4RK.mjs";
@@ -747,7 +747,7 @@ var enrichSignalWithCoinMarketCapContext = async (params) => {
747
747
  // src/strategyHelpers/derivativesContext.ts
748
748
  import {
749
749
  buildDerivativesContext,
750
- normalizeDerivativesIntervals
750
+ deriveCoinalyzeHourlyRowsFrom15m
751
751
  } from "@tradejs/core/indicators";
752
752
  import { refreshSignalBaseContextGateFeatures as refreshSignalBaseContextGateFeatures3 } from "@tradejs/core/strategies";
753
753
  import {
@@ -756,7 +756,8 @@ import {
756
756
  } from "@tradejs/core/constants";
757
757
  import { getDerivativesWindow } from "@tradejs/infra/timescale";
758
758
  import { logger as logger3 } from "@tradejs/infra/logger";
759
- var DEFAULT_INTERVALS = ["15m", "1h"];
759
+ var SOURCE_INTERVALS = ["15m"];
760
+ var CONTEXT_INTERVALS = ["15m", "1h"];
760
761
  var DEFAULT_LOOKBACK_HOURS = 48;
761
762
  var PRIMARY_DERIVATIVES_REFERENCE_SYMBOL = DERIVATIVES_CONTEXT_BASE_REFERENCE_SYMBOLS[0];
762
763
  var SECONDARY_DERIVATIVES_REFERENCE_SYMBOL = DERIVATIVES_CONTEXT_BASE_REFERENCE_SYMBOLS[1];
@@ -781,12 +782,10 @@ var parseLookbackMs = () => {
781
782
  const normalizedHours = Number.isFinite(hours) && hours > 0 ? hours : DEFAULT_LOOKBACK_HOURS;
782
783
  return normalizedHours * 60 * 60 * 1e3;
783
784
  };
784
- var parseIntervals = () => {
785
- const fromEnv = normalizeDerivativesIntervals(
786
- process.env.DERIVATIVES_CONTEXT_INTERVALS
787
- );
788
- return fromEnv.length ? fromEnv : DEFAULT_INTERVALS;
789
- };
785
+ var withDerivedHourlyRows = (rowsByInterval) => ({
786
+ "15m": rowsByInterval["15m"] ?? [],
787
+ "1h": deriveCoinalyzeHourlyRowsFrom15m(rowsByInterval["15m"])
788
+ });
790
789
  var getDerivativesContextReferenceSymbols = () => [
791
790
  ...resolveDerivativesContextReferenceSymbols(
792
791
  process.env.DERIVATIVES_CONTEXT_EXTRA_REFERENCE_SYMBOLS
@@ -906,7 +905,6 @@ var enrichSignalWithDerivativesContext = async (params) => {
906
905
  return false;
907
906
  }
908
907
  try {
909
- const intervals = parseIntervals();
910
908
  const referenceSymbols = getDerivativesContextReferenceSymbols();
911
909
  const targetSymbol = normalizeSymbol(signal.symbol);
912
910
  const lookbackMs = parseLookbackMs();
@@ -914,7 +912,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
914
912
  referenceSymbols.map(async (symbol) => {
915
913
  const rowsByInterval = await getDerivativesWindow({
916
914
  symbol,
917
- intervals,
915
+ intervals: SOURCE_INTERVALS,
918
916
  endMs: signal.timestamp,
919
917
  lookbackMs
920
918
  });
@@ -924,9 +922,9 @@ var enrichSignalWithDerivativesContext = async (params) => {
924
922
  symbol,
925
923
  direction: signal.direction,
926
924
  timestamp: signal.timestamp,
927
- rowsByInterval,
925
+ rowsByInterval: withDerivedHourlyRows(rowsByInterval),
928
926
  priceChangePct1h: getSignalPriceChangePct1h(signal),
929
- intervals
927
+ intervals: CONTEXT_INTERVALS
930
928
  })
931
929
  ];
932
930
  })
@@ -942,7 +940,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
942
940
  const fetchedTargetContext = shouldFetchTargetContext ? await (async () => {
943
941
  const rowsByInterval = await getDerivativesWindow({
944
942
  symbol: targetSymbol,
945
- intervals,
943
+ intervals: SOURCE_INTERVALS,
946
944
  endMs: signal.timestamp,
947
945
  lookbackMs
948
946
  });
@@ -950,9 +948,9 @@ var enrichSignalWithDerivativesContext = async (params) => {
950
948
  symbol: targetSymbol,
951
949
  direction: signal.direction,
952
950
  timestamp: signal.timestamp,
953
- rowsByInterval,
951
+ rowsByInterval: withDerivedHourlyRows(rowsByInterval),
954
952
  priceChangePct1h: getSignalPriceChangePct1h(signal),
955
- intervals
953
+ intervals: CONTEXT_INTERVALS
956
954
  });
957
955
  return hasDerivativesSymbolData(context) ? context : void 0;
958
956
  })() : void 0;
@@ -7428,7 +7428,8 @@ var import_strategies = require("@tradejs/core/strategies");
7428
7428
  var import_constants2 = require("@tradejs/core/constants");
7429
7429
  var import_timescale = require("@tradejs/infra/timescale");
7430
7430
  var import_logger4 = require("@tradejs/infra/logger");
7431
- var DEFAULT_INTERVALS = ["15m", "1h"];
7431
+ var SOURCE_INTERVALS = ["15m"];
7432
+ var CONTEXT_INTERVALS = ["15m", "1h"];
7432
7433
  var DEFAULT_LOOKBACK_HOURS = 48;
7433
7434
  var PRIMARY_DERIVATIVES_REFERENCE_SYMBOL = import_constants2.DERIVATIVES_CONTEXT_BASE_REFERENCE_SYMBOLS[0];
7434
7435
  var SECONDARY_DERIVATIVES_REFERENCE_SYMBOL = import_constants2.DERIVATIVES_CONTEXT_BASE_REFERENCE_SYMBOLS[1];
@@ -7453,12 +7454,10 @@ var parseLookbackMs = () => {
7453
7454
  const normalizedHours = Number.isFinite(hours) && hours > 0 ? hours : DEFAULT_LOOKBACK_HOURS;
7454
7455
  return normalizedHours * 60 * 60 * 1e3;
7455
7456
  };
7456
- var parseIntervals = () => {
7457
- const fromEnv = (0, import_indicators2.normalizeDerivativesIntervals)(
7458
- process.env.DERIVATIVES_CONTEXT_INTERVALS
7459
- );
7460
- return fromEnv.length ? fromEnv : DEFAULT_INTERVALS;
7461
- };
7457
+ var withDerivedHourlyRows = (rowsByInterval) => ({
7458
+ "15m": rowsByInterval["15m"] ?? [],
7459
+ "1h": (0, import_indicators2.deriveCoinalyzeHourlyRowsFrom15m)(rowsByInterval["15m"])
7460
+ });
7462
7461
  var getDerivativesContextReferenceSymbols = () => [
7463
7462
  ...(0, import_constants2.resolveDerivativesContextReferenceSymbols)(
7464
7463
  process.env.DERIVATIVES_CONTEXT_EXTRA_REFERENCE_SYMBOLS
@@ -7578,7 +7577,6 @@ var enrichSignalWithDerivativesContext = async (params) => {
7578
7577
  return false;
7579
7578
  }
7580
7579
  try {
7581
- const intervals = parseIntervals();
7582
7580
  const referenceSymbols = getDerivativesContextReferenceSymbols();
7583
7581
  const targetSymbol = normalizeSymbol(signal.symbol);
7584
7582
  const lookbackMs = parseLookbackMs();
@@ -7586,7 +7584,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
7586
7584
  referenceSymbols.map(async (symbol) => {
7587
7585
  const rowsByInterval = await (0, import_timescale.getDerivativesWindow)({
7588
7586
  symbol,
7589
- intervals,
7587
+ intervals: SOURCE_INTERVALS,
7590
7588
  endMs: signal.timestamp,
7591
7589
  lookbackMs
7592
7590
  });
@@ -7596,9 +7594,9 @@ var enrichSignalWithDerivativesContext = async (params) => {
7596
7594
  symbol,
7597
7595
  direction: signal.direction,
7598
7596
  timestamp: signal.timestamp,
7599
- rowsByInterval,
7597
+ rowsByInterval: withDerivedHourlyRows(rowsByInterval),
7600
7598
  priceChangePct1h: getSignalPriceChangePct1h(signal),
7601
- intervals
7599
+ intervals: CONTEXT_INTERVALS
7602
7600
  })
7603
7601
  ];
7604
7602
  })
@@ -7614,7 +7612,7 @@ var enrichSignalWithDerivativesContext = async (params) => {
7614
7612
  const fetchedTargetContext = shouldFetchTargetContext ? await (async () => {
7615
7613
  const rowsByInterval = await (0, import_timescale.getDerivativesWindow)({
7616
7614
  symbol: targetSymbol,
7617
- intervals,
7615
+ intervals: SOURCE_INTERVALS,
7618
7616
  endMs: signal.timestamp,
7619
7617
  lookbackMs
7620
7618
  });
@@ -7622,9 +7620,9 @@ var enrichSignalWithDerivativesContext = async (params) => {
7622
7620
  symbol: targetSymbol,
7623
7621
  direction: signal.direction,
7624
7622
  timestamp: signal.timestamp,
7625
- rowsByInterval,
7623
+ rowsByInterval: withDerivedHourlyRows(rowsByInterval),
7626
7624
  priceChangePct1h: getSignalPriceChangePct1h(signal),
7627
- intervals
7625
+ intervals: CONTEXT_INTERVALS
7628
7626
  });
7629
7627
  return hasDerivativesSymbolData(context) ? context : void 0;
7630
7628
  })() : void 0;
@@ -3,7 +3,7 @@ import {
3
3
  enrichSignalWithBinanceMarketContext,
4
4
  enrichSignalWithCoinMarketCapContext,
5
5
  enrichSignalWithDerivativesContext
6
- } from "./chunk-37VNDZVX.mjs";
6
+ } from "./chunk-2XFDY6AT.mjs";
7
7
  import {
8
8
  require_lodash
9
9
  } from "./chunk-KZDHZ56N.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tradejs/node",
3
- "version": "1.0.12",
4
- "description": "Node-only runtime for the TradeJS open-source framework: strategies, backtests, Pine strategy loading, and plugin registries.",
3
+ "version": "2.0.1",
4
+ "description": "Node-only runtime for the TradeJS TypeScript framework: strategies, backtests, Pine strategy loading, and plugin registries.",
5
5
  "keywords": [
6
6
  "tradejs",
7
7
  "trading",
@@ -67,9 +67,9 @@
67
67
  "dependencies": {
68
68
  "@langchain/core": "^1.1.42",
69
69
  "@langchain/openai": "^1.4.5",
70
- "@tradejs/core": "^1.0.12",
71
- "@tradejs/infra": "^1.0.12",
72
- "@tradejs/types": "^1.0.12",
70
+ "@tradejs/core": "^2.0.1",
71
+ "@tradejs/infra": "^2.0.1",
72
+ "@tradejs/types": "^2.0.1",
73
73
  "chalk": "4.1.2",
74
74
  "ioredis": "5.8.0",
75
75
  "pinets": "0.8.12",
@@ -87,6 +87,6 @@
87
87
  "build": "tsup",
88
88
  "typecheck": "tsc -p ./tsconfig.json --noEmit"
89
89
  },
90
- "license": "MIT",
90
+ "license": "BUSL-1.1",
91
91
  "author": "aleksnick (https://github.com/aleksnick)"
92
92
  }