backtest-kit 6.14.0 → 6.15.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/build/index.cjs +470 -31
- package/build/index.mjs +469 -32
- package/package.json +1 -1
- package/types.d.ts +286 -2
package/build/index.mjs
CHANGED
|
@@ -7963,6 +7963,40 @@ class ClientStrategy {
|
|
|
7963
7963
|
}
|
|
7964
7964
|
return Math.floor((timestamp - this._pendingSignal._peak.timestamp) / 60000);
|
|
7965
7965
|
}
|
|
7966
|
+
/**
|
|
7967
|
+
* Returns the number of minutes the position has been active since it opened.
|
|
7968
|
+
*
|
|
7969
|
+
* Computed as elapsed minutes since `pendingAt` (the moment the signal was activated).
|
|
7970
|
+
* Returns null if no pending signal exists.
|
|
7971
|
+
*
|
|
7972
|
+
* @param symbol - Trading pair symbol
|
|
7973
|
+
* @param timestamp - Current Unix timestamp in milliseconds
|
|
7974
|
+
* @returns Promise resolving to active minutes (≥ 0) or null
|
|
7975
|
+
*/
|
|
7976
|
+
async getPositionActiveMinutes(symbol, timestamp) {
|
|
7977
|
+
this.params.logger.debug("ClientStrategy getPositionActiveMinutes", { symbol });
|
|
7978
|
+
if (!this._pendingSignal) {
|
|
7979
|
+
return null;
|
|
7980
|
+
}
|
|
7981
|
+
return Math.floor((timestamp - this._pendingSignal.pendingAt) / 60000);
|
|
7982
|
+
}
|
|
7983
|
+
/**
|
|
7984
|
+
* Returns the number of minutes the scheduled signal has been waiting for activation.
|
|
7985
|
+
*
|
|
7986
|
+
* Computed as elapsed minutes since `scheduledAt` (the moment the scheduled signal was created).
|
|
7987
|
+
* Returns null if no scheduled signal exists.
|
|
7988
|
+
*
|
|
7989
|
+
* @param symbol - Trading pair symbol
|
|
7990
|
+
* @param timestamp - Current Unix timestamp in milliseconds
|
|
7991
|
+
* @returns Promise resolving to waiting minutes (≥ 0) or null
|
|
7992
|
+
*/
|
|
7993
|
+
async getPositionWaitingMinutes(symbol, timestamp) {
|
|
7994
|
+
this.params.logger.debug("ClientStrategy getPositionWaitingMinutes", { symbol });
|
|
7995
|
+
if (!this._scheduledSignal) {
|
|
7996
|
+
return null;
|
|
7997
|
+
}
|
|
7998
|
+
return Math.floor((timestamp - this._scheduledSignal.scheduledAt) / 60000);
|
|
7999
|
+
}
|
|
7966
8000
|
/**
|
|
7967
8001
|
* Returns the number of minutes elapsed since the highest profit price was recorded.
|
|
7968
8002
|
*
|
|
@@ -11064,6 +11098,46 @@ class StrategyConnectionService {
|
|
|
11064
11098
|
const timestamp = await this.timeMetaService.getTimestamp(symbol, context, backtest);
|
|
11065
11099
|
return await strategy.getPositionCountdownMinutes(symbol, timestamp);
|
|
11066
11100
|
};
|
|
11101
|
+
/**
|
|
11102
|
+
* Returns the number of minutes the position has been active since it opened.
|
|
11103
|
+
*
|
|
11104
|
+
* Delegates to ClientStrategy.getPositionActiveMinutes().
|
|
11105
|
+
* Returns null if no pending signal exists.
|
|
11106
|
+
*
|
|
11107
|
+
* @param backtest - Whether running in backtest mode
|
|
11108
|
+
* @param symbol - Trading pair symbol
|
|
11109
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
11110
|
+
* @returns Promise resolving to active minutes (≥ 0) or null
|
|
11111
|
+
*/
|
|
11112
|
+
this.getPositionActiveMinutes = async (backtest, symbol, context) => {
|
|
11113
|
+
this.loggerService.log("strategyConnectionService getPositionActiveMinutes", {
|
|
11114
|
+
symbol,
|
|
11115
|
+
context,
|
|
11116
|
+
});
|
|
11117
|
+
const strategy = this.getStrategy(symbol, context.strategyName, context.exchangeName, context.frameName, backtest);
|
|
11118
|
+
const timestamp = await this.timeMetaService.getTimestamp(symbol, context, backtest);
|
|
11119
|
+
return await strategy.getPositionActiveMinutes(symbol, timestamp);
|
|
11120
|
+
};
|
|
11121
|
+
/**
|
|
11122
|
+
* Returns the number of minutes the scheduled signal has been waiting for activation.
|
|
11123
|
+
*
|
|
11124
|
+
* Delegates to ClientStrategy.getPositionWaitingMinutes().
|
|
11125
|
+
* Returns null if no scheduled signal exists.
|
|
11126
|
+
*
|
|
11127
|
+
* @param backtest - Whether running in backtest mode
|
|
11128
|
+
* @param symbol - Trading pair symbol
|
|
11129
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
11130
|
+
* @returns Promise resolving to waiting minutes (≥ 0) or null
|
|
11131
|
+
*/
|
|
11132
|
+
this.getPositionWaitingMinutes = async (backtest, symbol, context) => {
|
|
11133
|
+
this.loggerService.log("strategyConnectionService getPositionWaitingMinutes", {
|
|
11134
|
+
symbol,
|
|
11135
|
+
context,
|
|
11136
|
+
});
|
|
11137
|
+
const strategy = this.getStrategy(symbol, context.strategyName, context.exchangeName, context.frameName, backtest);
|
|
11138
|
+
const timestamp = await this.timeMetaService.getTimestamp(symbol, context, backtest);
|
|
11139
|
+
return await strategy.getPositionWaitingMinutes(symbol, timestamp);
|
|
11140
|
+
};
|
|
11067
11141
|
/**
|
|
11068
11142
|
* Returns the best price reached in the profit direction during this position's life.
|
|
11069
11143
|
*
|
|
@@ -15384,6 +15458,38 @@ class StrategyCoreService {
|
|
|
15384
15458
|
await this.validate(context);
|
|
15385
15459
|
return await this.strategyConnectionService.getPositionCountdownMinutes(backtest, symbol, context);
|
|
15386
15460
|
};
|
|
15461
|
+
/**
|
|
15462
|
+
* Returns the number of minutes the position has been active since it opened.
|
|
15463
|
+
*
|
|
15464
|
+
* @param backtest - Whether running in backtest mode
|
|
15465
|
+
* @param symbol - Trading pair symbol
|
|
15466
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
15467
|
+
* @returns Promise resolving to active minutes (≥ 0) or null
|
|
15468
|
+
*/
|
|
15469
|
+
this.getPositionActiveMinutes = async (backtest, symbol, context) => {
|
|
15470
|
+
this.loggerService.log("strategyCoreService getPositionActiveMinutes", {
|
|
15471
|
+
symbol,
|
|
15472
|
+
context,
|
|
15473
|
+
});
|
|
15474
|
+
await this.validate(context);
|
|
15475
|
+
return await this.strategyConnectionService.getPositionActiveMinutes(backtest, symbol, context);
|
|
15476
|
+
};
|
|
15477
|
+
/**
|
|
15478
|
+
* Returns the number of minutes the scheduled signal has been waiting for activation.
|
|
15479
|
+
*
|
|
15480
|
+
* @param backtest - Whether running in backtest mode
|
|
15481
|
+
* @param symbol - Trading pair symbol
|
|
15482
|
+
* @param context - Execution context with strategyName, exchangeName, frameName
|
|
15483
|
+
* @returns Promise resolving to waiting minutes (≥ 0) or null
|
|
15484
|
+
*/
|
|
15485
|
+
this.getPositionWaitingMinutes = async (backtest, symbol, context) => {
|
|
15486
|
+
this.loggerService.log("strategyCoreService getPositionWaitingMinutes", {
|
|
15487
|
+
symbol,
|
|
15488
|
+
context,
|
|
15489
|
+
});
|
|
15490
|
+
await this.validate(context);
|
|
15491
|
+
return await this.strategyConnectionService.getPositionWaitingMinutes(backtest, symbol, context);
|
|
15492
|
+
};
|
|
15387
15493
|
/**
|
|
15388
15494
|
* Returns the best price reached in the profit direction during this position's life.
|
|
15389
15495
|
*
|
|
@@ -32390,7 +32496,7 @@ class NotificationHelperService {
|
|
|
32390
32496
|
const pendingSignal = await this.strategyCoreService.getPendingSignal(backtest, symbol, currentPrice, {
|
|
32391
32497
|
strategyName: context.strategyName,
|
|
32392
32498
|
exchangeName: context.exchangeName,
|
|
32393
|
-
frameName:
|
|
32499
|
+
frameName: context.frameName,
|
|
32394
32500
|
});
|
|
32395
32501
|
if (!pendingSignal) {
|
|
32396
32502
|
throw new Error(`SignalUtils notify No pending signal found symbol=${symbol} `);
|
|
@@ -35530,6 +35636,8 @@ const GET_POSITION_PARTIALS_METHOD_NAME = "strategy.getPositionPartials";
|
|
|
35530
35636
|
const GET_POSITION_ENTRIES_METHOD_NAME = "strategy.getPositionEntries";
|
|
35531
35637
|
const GET_POSITION_ESTIMATE_MINUTES_METHOD_NAME = "strategy.getPositionEstimateMinutes";
|
|
35532
35638
|
const GET_POSITION_COUNTDOWN_MINUTES_METHOD_NAME = "strategy.getPositionCountdownMinutes";
|
|
35639
|
+
const GET_POSITION_ACTIVE_MINUTES_METHOD_NAME = "strategy.getPositionActiveMinutes";
|
|
35640
|
+
const GET_POSITION_WAITING_MINUTES_METHOD_NAME = "strategy.getPositionWaitingMinutes";
|
|
35533
35641
|
const GET_POSITION_HIGHEST_PROFIT_PRICE_METHOD_NAME = "strategy.getPositionHighestProfitPrice";
|
|
35534
35642
|
const GET_POSITION_HIGHEST_PROFIT_TIMESTAMP_METHOD_NAME = "strategy.getPositionHighestProfitTimestamp";
|
|
35535
35643
|
const GET_POSITION_HIGHEST_PNL_PERCENTAGE_METHOD_NAME = "strategy.getPositionHighestPnlPercentage";
|
|
@@ -36830,6 +36938,62 @@ async function getPositionCountdownMinutes(symbol) {
|
|
|
36830
36938
|
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
36831
36939
|
return await backtest.strategyCoreService.getPositionCountdownMinutes(isBacktest, symbol, { exchangeName, frameName, strategyName });
|
|
36832
36940
|
}
|
|
36941
|
+
/**
|
|
36942
|
+
* Returns the number of minutes the position has been active since it opened.
|
|
36943
|
+
*
|
|
36944
|
+
* Returns null if no pending signal exists.
|
|
36945
|
+
*
|
|
36946
|
+
* @param symbol - Trading pair symbol
|
|
36947
|
+
* @returns Promise resolving to active minutes (≥ 0) or null
|
|
36948
|
+
*
|
|
36949
|
+
* @example
|
|
36950
|
+
* ```typescript
|
|
36951
|
+
* import { getPositionActiveMinutes } from "backtest-kit";
|
|
36952
|
+
*
|
|
36953
|
+
* const minutes = await getPositionActiveMinutes("BTCUSDT");
|
|
36954
|
+
* // e.g. 120 (position has been open for 2 hours)
|
|
36955
|
+
* ```
|
|
36956
|
+
*/
|
|
36957
|
+
async function getPositionActiveMinutes(symbol) {
|
|
36958
|
+
backtest.loggerService.info(GET_POSITION_ACTIVE_MINUTES_METHOD_NAME, { symbol });
|
|
36959
|
+
if (!ExecutionContextService.hasContext()) {
|
|
36960
|
+
throw new Error("getPositionActiveMinutes requires an execution context");
|
|
36961
|
+
}
|
|
36962
|
+
if (!MethodContextService.hasContext()) {
|
|
36963
|
+
throw new Error("getPositionActiveMinutes requires a method context");
|
|
36964
|
+
}
|
|
36965
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
36966
|
+
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
36967
|
+
return await backtest.strategyCoreService.getPositionActiveMinutes(isBacktest, symbol, { exchangeName, frameName, strategyName });
|
|
36968
|
+
}
|
|
36969
|
+
/**
|
|
36970
|
+
* Returns the number of minutes the scheduled signal has been waiting for activation.
|
|
36971
|
+
*
|
|
36972
|
+
* Returns null if no scheduled signal exists.
|
|
36973
|
+
*
|
|
36974
|
+
* @param symbol - Trading pair symbol
|
|
36975
|
+
* @returns Promise resolving to waiting minutes (≥ 0) or null
|
|
36976
|
+
*
|
|
36977
|
+
* @example
|
|
36978
|
+
* ```typescript
|
|
36979
|
+
* import { getPositionWaitingMinutes } from "backtest-kit";
|
|
36980
|
+
*
|
|
36981
|
+
* const minutes = await getPositionWaitingMinutes("BTCUSDT");
|
|
36982
|
+
* // e.g. 15 (scheduled signal has been waiting 15 minutes for activation)
|
|
36983
|
+
* ```
|
|
36984
|
+
*/
|
|
36985
|
+
async function getPositionWaitingMinutes(symbol) {
|
|
36986
|
+
backtest.loggerService.info(GET_POSITION_WAITING_MINUTES_METHOD_NAME, { symbol });
|
|
36987
|
+
if (!ExecutionContextService.hasContext()) {
|
|
36988
|
+
throw new Error("getPositionWaitingMinutes requires an execution context");
|
|
36989
|
+
}
|
|
36990
|
+
if (!MethodContextService.hasContext()) {
|
|
36991
|
+
throw new Error("getPositionWaitingMinutes requires a method context");
|
|
36992
|
+
}
|
|
36993
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
36994
|
+
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
36995
|
+
return await backtest.strategyCoreService.getPositionWaitingMinutes(isBacktest, symbol, { exchangeName, frameName, strategyName });
|
|
36996
|
+
}
|
|
36833
36997
|
/**
|
|
36834
36998
|
* Returns the best price reached in the profit direction during this position's life.
|
|
36835
36999
|
*
|
|
@@ -39100,6 +39264,8 @@ const BACKTEST_METHOD_NAME_GET_POSITION_PARTIALS = "BacktestUtils.getPositionPar
|
|
|
39100
39264
|
const BACKTEST_METHOD_NAME_GET_POSITION_ENTRIES = "BacktestUtils.getPositionEntries";
|
|
39101
39265
|
const BACKTEST_METHOD_NAME_GET_POSITION_ESTIMATE_MINUTES = "BacktestUtils.getPositionEstimateMinutes";
|
|
39102
39266
|
const BACKTEST_METHOD_NAME_GET_POSITION_COUNTDOWN_MINUTES = "BacktestUtils.getPositionCountdownMinutes";
|
|
39267
|
+
const BACKTEST_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES = "BacktestUtils.getPositionActiveMinutes";
|
|
39268
|
+
const BACKTEST_METHOD_NAME_GET_POSITION_WAITING_MINUTES = "BacktestUtils.getPositionWaitingMinutes";
|
|
39103
39269
|
const BACKTEST_METHOD_NAME_GET_POSITION_HIGHEST_PROFIT_PRICE = "BacktestUtils.getPositionHighestProfitPrice";
|
|
39104
39270
|
const BACKTEST_METHOD_NAME_GET_POSITION_HIGHEST_PROFIT_TIMESTAMP = "BacktestUtils.getPositionHighestProfitTimestamp";
|
|
39105
39271
|
const BACKTEST_METHOD_NAME_GET_POSITION_HIGHEST_PNL_PERCENTAGE = "BacktestUtils.getPositionHighestPnlPercentage";
|
|
@@ -40055,6 +40221,60 @@ class BacktestUtils {
|
|
|
40055
40221
|
}
|
|
40056
40222
|
return await backtest.strategyCoreService.getPositionCountdownMinutes(true, symbol, context);
|
|
40057
40223
|
};
|
|
40224
|
+
/**
|
|
40225
|
+
* Returns the number of minutes the position has been active since it opened.
|
|
40226
|
+
*
|
|
40227
|
+
* Returns null if no pending signal exists.
|
|
40228
|
+
*
|
|
40229
|
+
* @param symbol - Trading pair symbol
|
|
40230
|
+
* @param context - Execution context with strategyName, exchangeName, and frameName
|
|
40231
|
+
* @returns Active minutes (≥ 0), or null if no active position
|
|
40232
|
+
*/
|
|
40233
|
+
this.getPositionActiveMinutes = async (symbol, context) => {
|
|
40234
|
+
backtest.loggerService.info(BACKTEST_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES, {
|
|
40235
|
+
symbol,
|
|
40236
|
+
context,
|
|
40237
|
+
});
|
|
40238
|
+
backtest.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
40239
|
+
backtest.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
40240
|
+
{
|
|
40241
|
+
const { riskName, riskList, actions } = backtest.strategySchemaService.get(context.strategyName);
|
|
40242
|
+
riskName &&
|
|
40243
|
+
backtest.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
40244
|
+
riskList &&
|
|
40245
|
+
riskList.forEach((riskName) => backtest.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES));
|
|
40246
|
+
actions &&
|
|
40247
|
+
actions.forEach((actionName) => backtest.actionValidationService.validate(actionName, BACKTEST_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES));
|
|
40248
|
+
}
|
|
40249
|
+
return await backtest.strategyCoreService.getPositionActiveMinutes(true, symbol, context);
|
|
40250
|
+
};
|
|
40251
|
+
/**
|
|
40252
|
+
* Returns the number of minutes the scheduled signal has been waiting for activation.
|
|
40253
|
+
*
|
|
40254
|
+
* Returns null if no scheduled signal exists.
|
|
40255
|
+
*
|
|
40256
|
+
* @param symbol - Trading pair symbol
|
|
40257
|
+
* @param context - Execution context with strategyName, exchangeName, and frameName
|
|
40258
|
+
* @returns Waiting minutes (≥ 0), or null if no scheduled signal
|
|
40259
|
+
*/
|
|
40260
|
+
this.getPositionWaitingMinutes = async (symbol, context) => {
|
|
40261
|
+
backtest.loggerService.info(BACKTEST_METHOD_NAME_GET_POSITION_WAITING_MINUTES, {
|
|
40262
|
+
symbol,
|
|
40263
|
+
context,
|
|
40264
|
+
});
|
|
40265
|
+
backtest.strategyValidationService.validate(context.strategyName, BACKTEST_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
40266
|
+
backtest.exchangeValidationService.validate(context.exchangeName, BACKTEST_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
40267
|
+
{
|
|
40268
|
+
const { riskName, riskList, actions } = backtest.strategySchemaService.get(context.strategyName);
|
|
40269
|
+
riskName &&
|
|
40270
|
+
backtest.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
40271
|
+
riskList &&
|
|
40272
|
+
riskList.forEach((riskName) => backtest.riskValidationService.validate(riskName, BACKTEST_METHOD_NAME_GET_POSITION_WAITING_MINUTES));
|
|
40273
|
+
actions &&
|
|
40274
|
+
actions.forEach((actionName) => backtest.actionValidationService.validate(actionName, BACKTEST_METHOD_NAME_GET_POSITION_WAITING_MINUTES));
|
|
40275
|
+
}
|
|
40276
|
+
return await backtest.strategyCoreService.getPositionWaitingMinutes(true, symbol, context);
|
|
40277
|
+
};
|
|
40058
40278
|
/**
|
|
40059
40279
|
* Returns the best price reached in the profit direction during this position's life.
|
|
40060
40280
|
*
|
|
@@ -41696,6 +41916,8 @@ const LIVE_METHOD_NAME_GET_POSITION_PARTIALS = "LiveUtils.getPositionPartials";
|
|
|
41696
41916
|
const LIVE_METHOD_NAME_GET_POSITION_ENTRIES = "LiveUtils.getPositionEntries";
|
|
41697
41917
|
const LIVE_METHOD_NAME_GET_POSITION_ESTIMATE_MINUTES = "LiveUtils.getPositionEstimateMinutes";
|
|
41698
41918
|
const LIVE_METHOD_NAME_GET_POSITION_COUNTDOWN_MINUTES = "LiveUtils.getPositionCountdownMinutes";
|
|
41919
|
+
const LIVE_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES = "LiveUtils.getPositionActiveMinutes";
|
|
41920
|
+
const LIVE_METHOD_NAME_GET_POSITION_WAITING_MINUTES = "LiveUtils.getPositionWaitingMinutes";
|
|
41699
41921
|
const LIVE_METHOD_NAME_GET_POSITION_HIGHEST_PROFIT_PRICE = "LiveUtils.getPositionHighestProfitPrice";
|
|
41700
41922
|
const LIVE_METHOD_NAME_GET_POSITION_HIGHEST_PROFIT_TIMESTAMP = "LiveUtils.getPositionHighestProfitTimestamp";
|
|
41701
41923
|
const LIVE_METHOD_NAME_GET_POSITION_HIGHEST_PNL_PERCENTAGE = "LiveUtils.getPositionHighestPnlPercentage";
|
|
@@ -42730,6 +42952,68 @@ class LiveUtils {
|
|
|
42730
42952
|
frameName: "",
|
|
42731
42953
|
});
|
|
42732
42954
|
};
|
|
42955
|
+
/**
|
|
42956
|
+
* Returns the number of minutes the position has been active since it opened.
|
|
42957
|
+
*
|
|
42958
|
+
* Returns null if no pending signal exists.
|
|
42959
|
+
*
|
|
42960
|
+
* @param symbol - Trading pair symbol
|
|
42961
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
42962
|
+
* @returns Active minutes (≥ 0), or null if no active position
|
|
42963
|
+
*/
|
|
42964
|
+
this.getPositionActiveMinutes = async (symbol, context) => {
|
|
42965
|
+
backtest.loggerService.info(LIVE_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES, {
|
|
42966
|
+
symbol,
|
|
42967
|
+
context,
|
|
42968
|
+
});
|
|
42969
|
+
backtest.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
42970
|
+
backtest.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
42971
|
+
{
|
|
42972
|
+
const { riskName, riskList, actions } = backtest.strategySchemaService.get(context.strategyName);
|
|
42973
|
+
riskName &&
|
|
42974
|
+
backtest.riskValidationService.validate(riskName, LIVE_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
42975
|
+
riskList &&
|
|
42976
|
+
riskList.forEach((riskName) => backtest.riskValidationService.validate(riskName, LIVE_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES));
|
|
42977
|
+
actions &&
|
|
42978
|
+
actions.forEach((actionName) => backtest.actionValidationService.validate(actionName, LIVE_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES));
|
|
42979
|
+
}
|
|
42980
|
+
return await backtest.strategyCoreService.getPositionActiveMinutes(false, symbol, {
|
|
42981
|
+
strategyName: context.strategyName,
|
|
42982
|
+
exchangeName: context.exchangeName,
|
|
42983
|
+
frameName: "",
|
|
42984
|
+
});
|
|
42985
|
+
};
|
|
42986
|
+
/**
|
|
42987
|
+
* Returns the number of minutes the scheduled signal has been waiting for activation.
|
|
42988
|
+
*
|
|
42989
|
+
* Returns null if no scheduled signal exists.
|
|
42990
|
+
*
|
|
42991
|
+
* @param symbol - Trading pair symbol
|
|
42992
|
+
* @param context - Execution context with strategyName and exchangeName
|
|
42993
|
+
* @returns Waiting minutes (≥ 0), or null if no scheduled signal
|
|
42994
|
+
*/
|
|
42995
|
+
this.getPositionWaitingMinutes = async (symbol, context) => {
|
|
42996
|
+
backtest.loggerService.info(LIVE_METHOD_NAME_GET_POSITION_WAITING_MINUTES, {
|
|
42997
|
+
symbol,
|
|
42998
|
+
context,
|
|
42999
|
+
});
|
|
43000
|
+
backtest.strategyValidationService.validate(context.strategyName, LIVE_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
43001
|
+
backtest.exchangeValidationService.validate(context.exchangeName, LIVE_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
43002
|
+
{
|
|
43003
|
+
const { riskName, riskList, actions } = backtest.strategySchemaService.get(context.strategyName);
|
|
43004
|
+
riskName &&
|
|
43005
|
+
backtest.riskValidationService.validate(riskName, LIVE_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
43006
|
+
riskList &&
|
|
43007
|
+
riskList.forEach((riskName) => backtest.riskValidationService.validate(riskName, LIVE_METHOD_NAME_GET_POSITION_WAITING_MINUTES));
|
|
43008
|
+
actions &&
|
|
43009
|
+
actions.forEach((actionName) => backtest.actionValidationService.validate(actionName, LIVE_METHOD_NAME_GET_POSITION_WAITING_MINUTES));
|
|
43010
|
+
}
|
|
43011
|
+
return await backtest.strategyCoreService.getPositionWaitingMinutes(false, symbol, {
|
|
43012
|
+
strategyName: context.strategyName,
|
|
43013
|
+
exchangeName: context.exchangeName,
|
|
43014
|
+
frameName: "",
|
|
43015
|
+
});
|
|
43016
|
+
};
|
|
42733
43017
|
/**
|
|
42734
43018
|
* Returns the best price reached in the profit direction during this position's life.
|
|
42735
43019
|
*
|
|
@@ -48183,7 +48467,7 @@ const LOGGER_SERVICE$2 = new LoggerService();
|
|
|
48183
48467
|
* Default configuration that enables all report services.
|
|
48184
48468
|
* Used when no specific configuration is provided to enable().
|
|
48185
48469
|
*/
|
|
48186
|
-
const WILDCARD_TARGET$
|
|
48470
|
+
const WILDCARD_TARGET$2 = {
|
|
48187
48471
|
backtest: true,
|
|
48188
48472
|
strategy: true,
|
|
48189
48473
|
breakeven: true,
|
|
@@ -48234,7 +48518,7 @@ class ReportUtils {
|
|
|
48234
48518
|
*
|
|
48235
48519
|
* @returns Cleanup function that unsubscribes from all enabled services
|
|
48236
48520
|
*/
|
|
48237
|
-
this.enable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, schedule = false, walker = false, strategy = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$
|
|
48521
|
+
this.enable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, schedule = false, walker = false, strategy = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$2) => {
|
|
48238
48522
|
LOGGER_SERVICE$2.debug(REPORT_UTILS_METHOD_NAME_ENABLE, {
|
|
48239
48523
|
backtest: bt,
|
|
48240
48524
|
breakeven,
|
|
@@ -48326,7 +48610,7 @@ class ReportUtils {
|
|
|
48326
48610
|
* Report.disable();
|
|
48327
48611
|
* ```
|
|
48328
48612
|
*/
|
|
48329
|
-
this.disable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, schedule = false, walker = false, strategy = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$
|
|
48613
|
+
this.disable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, schedule = false, walker = false, strategy = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$2) => {
|
|
48330
48614
|
LOGGER_SERVICE$2.debug(REPORT_UTILS_METHOD_NAME_DISABLE, {
|
|
48331
48615
|
backtest: bt,
|
|
48332
48616
|
breakeven,
|
|
@@ -48450,7 +48734,7 @@ const LOGGER_SERVICE$1 = new LoggerService();
|
|
|
48450
48734
|
* Default configuration that enables all markdown services.
|
|
48451
48735
|
* Used when no specific configuration is provided to `enable()`.
|
|
48452
48736
|
*/
|
|
48453
|
-
const WILDCARD_TARGET = {
|
|
48737
|
+
const WILDCARD_TARGET$1 = {
|
|
48454
48738
|
backtest: true,
|
|
48455
48739
|
breakeven: true,
|
|
48456
48740
|
heat: true,
|
|
@@ -48501,7 +48785,7 @@ class MarkdownUtils {
|
|
|
48501
48785
|
*
|
|
48502
48786
|
* @returns Cleanup function that unsubscribes from all enabled services
|
|
48503
48787
|
*/
|
|
48504
|
-
this.enable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, strategy = false, risk = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET) => {
|
|
48788
|
+
this.enable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, strategy = false, risk = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$1) => {
|
|
48505
48789
|
LOGGER_SERVICE$1.debug(MARKDOWN_METHOD_NAME_ENABLE, {
|
|
48506
48790
|
backtest: bt,
|
|
48507
48791
|
breakeven,
|
|
@@ -48595,7 +48879,7 @@ class MarkdownUtils {
|
|
|
48595
48879
|
* Markdown.disable();
|
|
48596
48880
|
* ```
|
|
48597
48881
|
*/
|
|
48598
|
-
this.disable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, strategy = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET) => {
|
|
48882
|
+
this.disable = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, strategy = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$1) => {
|
|
48599
48883
|
LOGGER_SERVICE$1.debug(MARKDOWN_METHOD_NAME_DISABLE, {
|
|
48600
48884
|
backtest: bt,
|
|
48601
48885
|
breakeven,
|
|
@@ -48676,7 +48960,7 @@ class MarkdownUtils {
|
|
|
48676
48960
|
* @param config.highest_profit - Clear highest profit report data
|
|
48677
48961
|
* @param config.max_drawdown - Clear max drawdown report data
|
|
48678
48962
|
*/
|
|
48679
|
-
this.clear = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, strategy = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET) => {
|
|
48963
|
+
this.clear = ({ backtest: bt = false, breakeven = false, heat = false, live = false, partial = false, performance = false, risk = false, strategy = false, schedule = false, walker = false, sync = false, highest_profit = false, max_drawdown = false, } = WILDCARD_TARGET$1) => {
|
|
48680
48964
|
LOGGER_SERVICE$1.debug(MARKDOWN_METHOD_NAME_CLEAR, {
|
|
48681
48965
|
backtest: bt,
|
|
48682
48966
|
breakeven,
|
|
@@ -51088,6 +51372,8 @@ const REFLECT_METHOD_NAME_GET_POSITION_HIGHEST_PROFIT_TIMESTAMP = "ReflectUtils.
|
|
|
51088
51372
|
const REFLECT_METHOD_NAME_GET_POSITION_HIGHEST_PNL_PERCENTAGE = "ReflectUtils.getPositionHighestPnlPercentage";
|
|
51089
51373
|
const REFLECT_METHOD_NAME_GET_POSITION_HIGHEST_PNL_COST = "ReflectUtils.getPositionHighestPnlCost";
|
|
51090
51374
|
const REFLECT_METHOD_NAME_GET_POSITION_HIGHEST_PROFIT_BREAKEVEN = "ReflectUtils.getPositionHighestProfitBreakeven";
|
|
51375
|
+
const REFLECT_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES = "ReflectUtils.getPositionActiveMinutes";
|
|
51376
|
+
const REFLECT_METHOD_NAME_GET_POSITION_WAITING_MINUTES = "ReflectUtils.getPositionWaitingMinutes";
|
|
51091
51377
|
const REFLECT_METHOD_NAME_GET_POSITION_DRAWDOWN_MINUTES = "ReflectUtils.getPositionDrawdownMinutes";
|
|
51092
51378
|
const REFLECT_METHOD_NAME_GET_POSITION_HIGHEST_PROFIT_MINUTES = "ReflectUtils.getPositionHighestProfitMinutes";
|
|
51093
51379
|
const REFLECT_METHOD_NAME_GET_POSITION_MAX_DRAWDOWN_MINUTES = "ReflectUtils.getPositionMaxDrawdownMinutes";
|
|
@@ -51362,6 +51648,52 @@ class ReflectUtils {
|
|
|
51362
51648
|
}
|
|
51363
51649
|
return await backtest.strategyCoreService.getPositionHighestProfitBreakeven(backtest$1, symbol, context);
|
|
51364
51650
|
};
|
|
51651
|
+
/**
|
|
51652
|
+
* Returns the number of minutes the position has been active since it opened.
|
|
51653
|
+
*
|
|
51654
|
+
* Returns null if no pending signal exists.
|
|
51655
|
+
*
|
|
51656
|
+
* @param symbol - Trading pair symbol
|
|
51657
|
+
* @param context - Execution context with strategyName, exchangeName and frameName
|
|
51658
|
+
* @param backtest - True if backtest mode, false if live mode (default: false)
|
|
51659
|
+
* @returns Promise resolving to active minutes (≥ 0) or null
|
|
51660
|
+
*/
|
|
51661
|
+
this.getPositionActiveMinutes = async (symbol, context, backtest$1 = false) => {
|
|
51662
|
+
backtest.loggerService.info(REFLECT_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES, { symbol, context });
|
|
51663
|
+
backtest.strategyValidationService.validate(context.strategyName, REFLECT_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
51664
|
+
backtest.exchangeValidationService.validate(context.exchangeName, REFLECT_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
51665
|
+
context.frameName && backtest.frameValidationService.validate(context.frameName, REFLECT_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
51666
|
+
{
|
|
51667
|
+
const { riskName, riskList, actions } = backtest.strategySchemaService.get(context.strategyName);
|
|
51668
|
+
riskName && backtest.riskValidationService.validate(riskName, REFLECT_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES);
|
|
51669
|
+
riskList && riskList.forEach((riskName) => backtest.riskValidationService.validate(riskName, REFLECT_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES));
|
|
51670
|
+
actions && actions.forEach((actionName) => backtest.actionValidationService.validate(actionName, REFLECT_METHOD_NAME_GET_POSITION_ACTIVE_MINUTES));
|
|
51671
|
+
}
|
|
51672
|
+
return await backtest.strategyCoreService.getPositionActiveMinutes(backtest$1, symbol, context);
|
|
51673
|
+
};
|
|
51674
|
+
/**
|
|
51675
|
+
* Returns the number of minutes the scheduled signal has been waiting for activation.
|
|
51676
|
+
*
|
|
51677
|
+
* Returns null if no scheduled signal exists.
|
|
51678
|
+
*
|
|
51679
|
+
* @param symbol - Trading pair symbol
|
|
51680
|
+
* @param context - Execution context with strategyName, exchangeName and frameName
|
|
51681
|
+
* @param backtest - True if backtest mode, false if live mode (default: false)
|
|
51682
|
+
* @returns Promise resolving to waiting minutes (≥ 0) or null
|
|
51683
|
+
*/
|
|
51684
|
+
this.getPositionWaitingMinutes = async (symbol, context, backtest$1 = false) => {
|
|
51685
|
+
backtest.loggerService.info(REFLECT_METHOD_NAME_GET_POSITION_WAITING_MINUTES, { symbol, context });
|
|
51686
|
+
backtest.strategyValidationService.validate(context.strategyName, REFLECT_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
51687
|
+
backtest.exchangeValidationService.validate(context.exchangeName, REFLECT_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
51688
|
+
context.frameName && backtest.frameValidationService.validate(context.frameName, REFLECT_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
51689
|
+
{
|
|
51690
|
+
const { riskName, riskList, actions } = backtest.strategySchemaService.get(context.strategyName);
|
|
51691
|
+
riskName && backtest.riskValidationService.validate(riskName, REFLECT_METHOD_NAME_GET_POSITION_WAITING_MINUTES);
|
|
51692
|
+
riskList && riskList.forEach((riskName) => backtest.riskValidationService.validate(riskName, REFLECT_METHOD_NAME_GET_POSITION_WAITING_MINUTES));
|
|
51693
|
+
actions && actions.forEach((actionName) => backtest.actionValidationService.validate(actionName, REFLECT_METHOD_NAME_GET_POSITION_WAITING_MINUTES));
|
|
51694
|
+
}
|
|
51695
|
+
return await backtest.strategyCoreService.getPositionWaitingMinutes(backtest$1, symbol, context);
|
|
51696
|
+
};
|
|
51365
51697
|
/**
|
|
51366
51698
|
* Returns the number of minutes elapsed since the highest profit price was recorded.
|
|
51367
51699
|
*
|
|
@@ -53638,6 +53970,23 @@ const StorageLive = new StorageLiveAdapter();
|
|
|
53638
53970
|
*/
|
|
53639
53971
|
const StorageBacktest = new StorageBacktestAdapter();
|
|
53640
53972
|
|
|
53973
|
+
/**
|
|
53974
|
+
* Default configuration that enables all notification types.
|
|
53975
|
+
* Used when no specific configuration is provided to enable().
|
|
53976
|
+
*/
|
|
53977
|
+
const WILDCARD_TARGET = {
|
|
53978
|
+
signal: true,
|
|
53979
|
+
partial_profit: true,
|
|
53980
|
+
partial_loss: true,
|
|
53981
|
+
breakeven: true,
|
|
53982
|
+
strategy_commit: true,
|
|
53983
|
+
signal_sync: true,
|
|
53984
|
+
risk: true,
|
|
53985
|
+
info: true,
|
|
53986
|
+
common_error: true,
|
|
53987
|
+
critical_error: true,
|
|
53988
|
+
validation_error: true,
|
|
53989
|
+
};
|
|
53641
53990
|
/**
|
|
53642
53991
|
* Generates a unique key for notification identification.
|
|
53643
53992
|
* @returns Random string identifier
|
|
@@ -55693,64 +56042,152 @@ class NotificationAdapter {
|
|
|
55693
56042
|
*
|
|
55694
56043
|
* @returns Cleanup function that unsubscribes from all emitters
|
|
55695
56044
|
*/
|
|
55696
|
-
this.enable = singleshot(() => {
|
|
56045
|
+
this.enable = singleshot(({ signal = false, info = false, partial_profit = false, partial_loss = false, breakeven = false, strategy_commit = false, signal_sync = false, risk = false, common_error = false, critical_error = false, validation_error = false, } = WILDCARD_TARGET) => {
|
|
55697
56046
|
backtest.loggerService.info(NOTIFICATION_ADAPTER_METHOD_NAME_ENABLE);
|
|
55698
56047
|
let unLive;
|
|
55699
56048
|
let unBacktest;
|
|
55700
56049
|
{
|
|
55701
|
-
const unBacktestSignal = signalBacktestEmitter.subscribe((data) =>
|
|
56050
|
+
const unBacktestSignal = signalBacktestEmitter.subscribe(async (data) => {
|
|
56051
|
+
if (signal) {
|
|
56052
|
+
await NotificationBacktest.handleSignal(data);
|
|
56053
|
+
}
|
|
56054
|
+
});
|
|
55702
56055
|
const unBacktestPartialProfit = partialProfitSubject
|
|
55703
56056
|
.filter(({ backtest }) => backtest)
|
|
55704
|
-
.connect((data) =>
|
|
56057
|
+
.connect(async (data) => {
|
|
56058
|
+
if (partial_profit) {
|
|
56059
|
+
await NotificationBacktest.handlePartialProfit(data);
|
|
56060
|
+
}
|
|
56061
|
+
});
|
|
55705
56062
|
const unBacktestPartialLoss = partialLossSubject
|
|
55706
56063
|
.filter(({ backtest }) => backtest)
|
|
55707
|
-
.connect((data) =>
|
|
56064
|
+
.connect(async (data) => {
|
|
56065
|
+
if (partial_loss) {
|
|
56066
|
+
await NotificationBacktest.handlePartialLoss(data);
|
|
56067
|
+
}
|
|
56068
|
+
});
|
|
55708
56069
|
const unBacktestBreakeven = breakevenSubject
|
|
55709
56070
|
.filter(({ backtest }) => backtest)
|
|
55710
|
-
.connect((data) =>
|
|
56071
|
+
.connect(async (data) => {
|
|
56072
|
+
if (breakeven) {
|
|
56073
|
+
await NotificationBacktest.handleBreakeven(data);
|
|
56074
|
+
}
|
|
56075
|
+
});
|
|
55711
56076
|
const unBacktestStrategyCommit = strategyCommitSubject
|
|
55712
56077
|
.filter(({ backtest }) => backtest)
|
|
55713
|
-
.connect((data) =>
|
|
56078
|
+
.connect(async (data) => {
|
|
56079
|
+
if (strategy_commit) {
|
|
56080
|
+
await NotificationBacktest.handleStrategyCommit(data);
|
|
56081
|
+
}
|
|
56082
|
+
});
|
|
55714
56083
|
const unBacktestSync = syncSubject
|
|
55715
56084
|
.filter(({ backtest }) => backtest)
|
|
55716
|
-
.connect((data) =>
|
|
56085
|
+
.connect(async (data) => {
|
|
56086
|
+
if (signal_sync) {
|
|
56087
|
+
await NotificationBacktest.handleSync(data);
|
|
56088
|
+
}
|
|
56089
|
+
});
|
|
55717
56090
|
const unBacktestRisk = riskSubject
|
|
55718
56091
|
.filter(({ backtest }) => backtest)
|
|
55719
|
-
.connect((data) =>
|
|
55720
|
-
|
|
55721
|
-
|
|
55722
|
-
|
|
56092
|
+
.connect(async (data) => {
|
|
56093
|
+
if (risk) {
|
|
56094
|
+
await NotificationBacktest.handleRisk(data);
|
|
56095
|
+
}
|
|
56096
|
+
});
|
|
56097
|
+
const unBacktestError = errorEmitter.subscribe(async (error) => {
|
|
56098
|
+
if (common_error) {
|
|
56099
|
+
await NotificationBacktest.handleError(error);
|
|
56100
|
+
}
|
|
56101
|
+
});
|
|
56102
|
+
const unBacktestExit = exitEmitter.subscribe(async (error) => {
|
|
56103
|
+
if (critical_error) {
|
|
56104
|
+
await NotificationBacktest.handleCriticalError(error);
|
|
56105
|
+
}
|
|
56106
|
+
});
|
|
56107
|
+
const unBacktestValidation = validationSubject.subscribe(async (error) => {
|
|
56108
|
+
if (validation_error) {
|
|
56109
|
+
await NotificationBacktest.handleValidationError(error);
|
|
56110
|
+
}
|
|
56111
|
+
});
|
|
55723
56112
|
const unBacktestSignalNotify = signalNotifySubject
|
|
55724
56113
|
.filter(({ backtest }) => backtest)
|
|
55725
|
-
.connect((data) =>
|
|
56114
|
+
.connect(async (data) => {
|
|
56115
|
+
if (info) {
|
|
56116
|
+
await NotificationBacktest.handleSignalNotify(data);
|
|
56117
|
+
}
|
|
56118
|
+
});
|
|
55726
56119
|
unBacktest = compose(() => unBacktestSignal(), () => unBacktestPartialProfit(), () => unBacktestPartialLoss(), () => unBacktestBreakeven(), () => unBacktestStrategyCommit(), () => unBacktestSync(), () => unBacktestRisk(), () => unBacktestError(), () => unBacktestExit(), () => unBacktestValidation(), () => unBacktestSignalNotify());
|
|
55727
56120
|
}
|
|
55728
56121
|
{
|
|
55729
|
-
const unLiveSignal = signalLiveEmitter.subscribe((data) =>
|
|
56122
|
+
const unLiveSignal = signalLiveEmitter.subscribe(async (data) => {
|
|
56123
|
+
if (signal) {
|
|
56124
|
+
await NotificationLive.handleSignal(data);
|
|
56125
|
+
}
|
|
56126
|
+
});
|
|
55730
56127
|
const unLivePartialProfit = partialProfitSubject
|
|
55731
56128
|
.filter(({ backtest }) => !backtest)
|
|
55732
|
-
.connect((data) =>
|
|
56129
|
+
.connect(async (data) => {
|
|
56130
|
+
if (partial_profit) {
|
|
56131
|
+
await NotificationLive.handlePartialProfit(data);
|
|
56132
|
+
}
|
|
56133
|
+
});
|
|
55733
56134
|
const unLivePartialLoss = partialLossSubject
|
|
55734
56135
|
.filter(({ backtest }) => !backtest)
|
|
55735
|
-
.connect((data) =>
|
|
56136
|
+
.connect(async (data) => {
|
|
56137
|
+
if (partial_loss) {
|
|
56138
|
+
await NotificationLive.handlePartialLoss(data);
|
|
56139
|
+
}
|
|
56140
|
+
});
|
|
55736
56141
|
const unLiveBreakeven = breakevenSubject
|
|
55737
56142
|
.filter(({ backtest }) => !backtest)
|
|
55738
|
-
.connect((data) =>
|
|
56143
|
+
.connect(async (data) => {
|
|
56144
|
+
if (breakeven) {
|
|
56145
|
+
await NotificationLive.handleBreakeven(data);
|
|
56146
|
+
}
|
|
56147
|
+
});
|
|
55739
56148
|
const unLiveStrategyCommit = strategyCommitSubject
|
|
55740
56149
|
.filter(({ backtest }) => !backtest)
|
|
55741
|
-
.connect((data) =>
|
|
56150
|
+
.connect(async (data) => {
|
|
56151
|
+
if (strategy_commit) {
|
|
56152
|
+
await NotificationLive.handleStrategyCommit(data);
|
|
56153
|
+
}
|
|
56154
|
+
});
|
|
55742
56155
|
const unLiveSync = syncSubject
|
|
55743
56156
|
.filter(({ backtest }) => !backtest)
|
|
55744
|
-
.connect((data) =>
|
|
56157
|
+
.connect(async (data) => {
|
|
56158
|
+
if (signal_sync) {
|
|
56159
|
+
await NotificationLive.handleSync(data);
|
|
56160
|
+
}
|
|
56161
|
+
});
|
|
55745
56162
|
const unLiveRisk = riskSubject
|
|
55746
56163
|
.filter(({ backtest }) => !backtest)
|
|
55747
|
-
.connect((data) =>
|
|
55748
|
-
|
|
55749
|
-
|
|
55750
|
-
|
|
56164
|
+
.connect(async (data) => {
|
|
56165
|
+
if (risk) {
|
|
56166
|
+
await NotificationLive.handleRisk(data);
|
|
56167
|
+
}
|
|
56168
|
+
});
|
|
56169
|
+
const unLiveError = errorEmitter.subscribe(async (error) => {
|
|
56170
|
+
if (common_error) {
|
|
56171
|
+
await NotificationLive.handleError(error);
|
|
56172
|
+
}
|
|
56173
|
+
});
|
|
56174
|
+
const unLiveExit = exitEmitter.subscribe(async (error) => {
|
|
56175
|
+
if (critical_error) {
|
|
56176
|
+
await NotificationLive.handleCriticalError(error);
|
|
56177
|
+
}
|
|
56178
|
+
});
|
|
56179
|
+
const unLiveValidation = validationSubject.subscribe(async (error) => {
|
|
56180
|
+
if (validation_error) {
|
|
56181
|
+
await NotificationLive.handleValidationError(error);
|
|
56182
|
+
}
|
|
56183
|
+
});
|
|
55751
56184
|
const unLiveSignalNotify = signalNotifySubject
|
|
55752
56185
|
.filter(({ backtest }) => !backtest)
|
|
55753
|
-
.connect((data) =>
|
|
56186
|
+
.connect(async (data) => {
|
|
56187
|
+
if (info) {
|
|
56188
|
+
await NotificationLive.handleSignalNotify(data);
|
|
56189
|
+
}
|
|
56190
|
+
});
|
|
55754
56191
|
unLive = compose(() => unLiveSignal(), () => unLivePartialProfit(), () => unLivePartialLoss(), () => unLiveBreakeven(), () => unLiveStrategyCommit(), () => unLiveSync(), () => unLiveRisk(), () => unLiveError(), () => unLiveExit(), () => unLiveValidation(), () => unLiveSignalNotify());
|
|
55755
56192
|
}
|
|
55756
56193
|
return () => {
|
|
@@ -58141,4 +58578,4 @@ const validateSignal = (signal, currentPrice) => {
|
|
|
58141
58578
|
return !errors.length;
|
|
58142
58579
|
};
|
|
58143
58580
|
|
|
58144
|
-
export { ActionBase, Backtest, Breakeven, Broker, BrokerBase, Cache, Constant, Dump, Exchange, ExecutionContextService, Heat, HighestProfit, Interval, Live, Log, Markdown, MarkdownFileBase, MarkdownFolderBase, MarkdownWriter, MaxDrawdown, Memory, MethodContextService, Notification, NotificationBacktest, NotificationLive, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistIntervalAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRecentAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, Position, PositionSize, Recent, RecentBacktest, RecentLive, Reflect$1 as Reflect, Report, ReportBase, ReportWriter, Risk, Schedule, Session, Storage, StorageBacktest, StorageLive, Strategy, Sync, Walker, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitSignalNotify, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getLatestSignal, getMaxDrawdownDistancePnlCost, getMaxDrawdownDistancePnlPercentage, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestMaxDrawdownPnlCost, getPositionHighestMaxDrawdownPnlPercentage, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitDistancePnlCost, getPositionHighestProfitDistancePnlPercentage, getPositionHighestProfitMinutes, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionMaxDrawdownMinutes, getPositionMaxDrawdownPnlCost, getPositionMaxDrawdownPnlPercentage, getPositionMaxDrawdownPrice, getPositionMaxDrawdownTimestamp, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenMaxDrawdown, listenMaxDrawdownOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalNotify, listenSignalNotifyOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, warmCandles, writeMemory };
|
|
58581
|
+
export { ActionBase, Backtest, Breakeven, Broker, BrokerBase, Cache, Constant, Dump, Exchange, ExecutionContextService, Heat, HighestProfit, Interval, Live, Log, Markdown, MarkdownFileBase, MarkdownFolderBase, MarkdownWriter, MaxDrawdown, Memory, MethodContextService, Notification, NotificationBacktest, NotificationLive, Partial, Performance, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistIntervalAdapter, PersistLogAdapter, PersistMeasureAdapter, PersistMemoryAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRecentAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, Position, PositionSize, Recent, RecentBacktest, RecentLive, Reflect$1 as Reflect, Report, ReportBase, ReportWriter, Risk, Schedule, Session, Storage, StorageBacktest, StorageLive, Strategy, Sync, Walker, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, alignToInterval, checkCandles, commitActivateScheduled, commitAverageBuy, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialLossCost, commitPartialProfit, commitPartialProfitCost, commitSignalNotify, commitTrailingStop, commitTrailingStopCost, commitTrailingTake, commitTrailingTakeCost, dumpAgentAnswer, dumpError, dumpJson, dumpRecord, dumpTable, dumpText, emitters, formatPrice, formatQuantity, get, getActionSchema, getAggregatedTrades, getAveragePrice, getBacktestTimeframe, getBreakeven, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getEffectivePriceOpen, getExchangeSchema, getFrameSchema, getLatestSignal, getMaxDrawdownDistancePnlCost, getMaxDrawdownDistancePnlPercentage, getMode, getNextCandles, getOrderBook, getPendingSignal, getPositionActiveMinutes, getPositionCountdownMinutes, getPositionDrawdownMinutes, getPositionEffectivePrice, getPositionEntries, getPositionEntryOverlap, getPositionEstimateMinutes, getPositionHighestMaxDrawdownPnlCost, getPositionHighestMaxDrawdownPnlPercentage, getPositionHighestPnlCost, getPositionHighestPnlPercentage, getPositionHighestProfitBreakeven, getPositionHighestProfitDistancePnlCost, getPositionHighestProfitDistancePnlPercentage, getPositionHighestProfitMinutes, getPositionHighestProfitPrice, getPositionHighestProfitTimestamp, getPositionInvestedCost, getPositionInvestedCount, getPositionLevels, getPositionMaxDrawdownMinutes, getPositionMaxDrawdownPnlCost, getPositionMaxDrawdownPnlPercentage, getPositionMaxDrawdownPrice, getPositionMaxDrawdownTimestamp, getPositionPartialOverlap, getPositionPartials, getPositionPnlCost, getPositionPnlPercent, getPositionWaitingMinutes, getRawCandles, getRiskSchema, getScheduledSignal, getSizingSchema, getStrategySchema, getSymbol, getTimestamp, getTotalClosed, getTotalCostClosed, getTotalPercentClosed, getWalkerSchema, hasNoPendingSignal, hasNoScheduledSignal, hasTradeContext, investedCostToPercent, backtest as lib, listExchangeSchema, listFrameSchema, listMemory, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenHighestProfit, listenHighestProfitOnce, listenMaxDrawdown, listenMaxDrawdownOnce, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalNotify, listenSignalNotifyOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenSync, listenSyncOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, percentDiff, percentToCloseCost, percentValue, readMemory, removeMemory, roundTicks, runInMockContext, searchMemory, set, setColumns, setConfig, setLogger, shutdown, slPercentShiftToPrice, slPriceToPercentShift, stopStrategy, toProfitLossDto, tpPercentShiftToPrice, tpPriceToPercentShift, validate, validateCommonSignal, validatePendingSignal, validateScheduledSignal, validateSignal, waitForCandle, warmCandles, writeMemory };
|