@tradejs/node 2.0.15 → 2.0.16

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.
@@ -4,8 +4,8 @@ import {
4
4
  buildMlPayload,
5
5
  enrichSignalWithBinanceMarketContext,
6
6
  enrichSignalWithCoinMarketCapContext,
7
- enrichSignalWithDerivativesContext,
8
7
  enrichSignalWithHyperliquidWhaleContext,
8
+ enrichSignalWithMarketContextStages,
9
9
  getBinanceBreadthUniverseSnapshot,
10
10
  getBinanceBreadthUniverses,
11
11
  getHyperliquidPerpSymbols,
@@ -17,7 +17,7 @@ import {
17
17
  isTrackedHyperliquidWhale,
18
18
  loadHyperliquidWhaleFlowContext,
19
19
  resolveHyperliquidPerpFromSignalSymbol
20
- } from "./chunk-FEQR4XGR.mjs";
20
+ } from "./chunk-3BP3ETAD.mjs";
21
21
  import {
22
22
  require_lodash
23
23
  } from "./chunk-GPR56UYQ.mjs";
@@ -38,7 +38,7 @@ import {
38
38
  runAiPrompt,
39
39
  runAiPromptLocal,
40
40
  trimSeriesDeep
41
- } from "./chunk-DPHKRDD5.mjs";
41
+ } from "./chunk-WK5EUCX5.mjs";
42
42
  import {
43
43
  createPineScriptLoader
44
44
  } from "./chunk-IQKMII6L.mjs";
@@ -312,6 +312,7 @@ var markRuntimeTradeClosed = async (params) => {
312
312
  lastSyncedAt: now()
313
313
  };
314
314
  const dayKey = getRuntimeStorageDayKey(existing.entryTimestamp);
315
+ const closeDayKey = getRuntimeStorageDayKey(next.exitTimestamp);
315
316
  try {
316
317
  await Promise.all([
317
318
  setData(redisKeys.runtimeTrade(userName, orderId), next, {
@@ -323,6 +324,12 @@ var markRuntimeTradeClosed = async (params) => {
323
324
  next,
324
325
  { expire: TTL_1M }
325
326
  ),
327
+ setHashJsonField(
328
+ redisKeys.runtimeClosedTradeBucket(userName, closeDayKey),
329
+ orderId,
330
+ next,
331
+ { expire: TTL_1M }
332
+ ),
326
333
  delKey(
327
334
  redisKeys.runtimeActiveTrade(
328
335
  userName,
@@ -470,10 +477,7 @@ var enrichSignalWithMlAi = async ({
470
477
  ml,
471
478
  ai
472
479
  }) => {
473
- await enrichSignalWithBinanceMarketContext({ signal, env });
474
- await enrichSignalWithCoinMarketCapContext({ signal, env });
475
- await enrichSignalWithDerivativesContext({ signal, env });
476
- await enrichSignalWithHyperliquidWhaleContext({ signal, env });
480
+ await enrichSignalWithMarketContextStages({ signal, env });
477
481
  await enrichSignalWithMl({ signal, env, ml });
478
482
  return enrichSignalWithAi({ signal, userName, symbol, direction, env, ai });
479
483
  };
@@ -737,6 +741,7 @@ var executeEntryOrder = async ({
737
741
  deploymentId: signal.deploymentId,
738
742
  policyProfileId: signal.policyProfileId,
739
743
  runtimeConfigId: signal.runtimeConfigId,
744
+ runtimeLineage: signal.runtimeLineage,
740
745
  ...signal.aiAnalysis ? { aiAnalysis: signal.aiAnalysis } : {}
741
746
  });
742
747
  }
@@ -831,6 +836,10 @@ var resolveStrategyConfig = async ({
831
836
  import {
832
837
  BACKTEST_WARNING_CODES
833
838
  } from "@tradejs/types";
839
+ var cloneWithPropertyDescriptors = (value) => Object.create(
840
+ Object.getPrototypeOf(value),
841
+ Object.getOwnPropertyDescriptors(value)
842
+ );
834
843
  var buildExitOrderSignal = ({
835
844
  strategyName,
836
845
  symbol,
@@ -1947,6 +1956,9 @@ var createStrategyRuntime = ({
1947
1956
  sharedReplayKey: indicatorSharedReplayKey,
1948
1957
  useBtcReference: universe === "crypto"
1949
1958
  });
1959
+ const coreContextRequirements = new Set(
1960
+ strategyManifest?.contextRequirements?.core ?? []
1961
+ );
1950
1962
  const strategyApi = createStrategyAPI({
1951
1963
  strategy: strategyName,
1952
1964
  symbol,
@@ -1965,6 +1977,9 @@ var createStrategyRuntime = ({
1965
1977
  interval: decisionInterval
1966
1978
  }) => {
1967
1979
  if (!baseContext) return void 0;
1980
+ if (!coreContextRequirements.has("hyperliquidWhales")) {
1981
+ return baseContext;
1982
+ }
1968
1983
  const hyperliquidWhales = await loadHyperliquidWhaleFlowContext({
1969
1984
  symbol: decisionSymbol,
1970
1985
  interval: decisionInterval,
@@ -1973,13 +1988,23 @@ var createStrategyRuntime = ({
1973
1988
  useSeriesCache: env === "BACKTEST" || env === "PARITY"
1974
1989
  });
1975
1990
  if (!hyperliquidWhales) return baseContext;
1976
- return {
1977
- ...baseContext,
1978
- participation: {
1979
- ...baseContext.participation,
1980
- hyperliquidWhales
1981
- }
1982
- };
1991
+ const participation = cloneWithPropertyDescriptors(
1992
+ baseContext.participation
1993
+ );
1994
+ Object.defineProperty(participation, "hyperliquidWhales", {
1995
+ configurable: true,
1996
+ enumerable: true,
1997
+ value: hyperliquidWhales,
1998
+ writable: true
1999
+ });
2000
+ const enrichedBaseContext = cloneWithPropertyDescriptors(baseContext);
2001
+ Object.defineProperty(enrichedBaseContext, "participation", {
2002
+ configurable: true,
2003
+ enumerable: true,
2004
+ value: participation,
2005
+ writable: true
2006
+ });
2007
+ return enrichedBaseContext;
1983
2008
  }
1984
2009
  });
1985
2010
  const core = await createCore({
@@ -2370,17 +2395,10 @@ var createStrategyRuntime = ({
2370
2395
  let ai;
2371
2396
  if (signal) {
2372
2397
  try {
2373
- await enrichSignalWithBinanceMarketContext({
2398
+ await enrichSignalWithMarketContextStages({
2374
2399
  signal,
2375
- env
2376
- });
2377
- await enrichSignalWithCoinMarketCapContext({
2378
- signal,
2379
- env
2380
- });
2381
- await enrichSignalWithDerivativesContext({
2382
- signal,
2383
- env
2400
+ env,
2401
+ includeHyperliquidWhales: false
2384
2402
  });
2385
2403
  quality = await enrichSignalWithAi({
2386
2404
  signal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradejs/node",
3
- "version": "2.0.15",
3
+ "version": "2.0.16",
4
4
  "description": "Node-only runtime for the TradeJS TypeScript framework: strategies, backtests, Pine strategy loading, and plugin registries.",
5
5
  "keywords": [
6
6
  "tradejs",
@@ -67,9 +67,9 @@
67
67
  "dependencies": {
68
68
  "@langchain/core": "^1.2.3",
69
69
  "@langchain/openai": "^1.5.5",
70
- "@tradejs/core": "^2.0.15",
71
- "@tradejs/infra": "^2.0.15",
72
- "@tradejs/types": "^2.0.15",
70
+ "@tradejs/core": "^2.0.16",
71
+ "@tradejs/infra": "^2.0.16",
72
+ "@tradejs/types": "^2.0.16",
73
73
  "chalk": "4.1.2",
74
74
  "ioredis": "5.11.1",
75
75
  "pinets": "0.8.12",