backtest-kit 7.6.0 → 7.7.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 +11 -9
- package/build/index.mjs +11 -9
- package/package.json +1 -1
- package/types.d.ts +8 -4
package/build/index.cjs
CHANGED
|
@@ -47978,6 +47978,7 @@ async function getMinutesSinceLatestSignalCreated(symbol) {
|
|
|
47978
47978
|
* SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25).
|
|
47979
47979
|
* Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.
|
|
47980
47980
|
*
|
|
47981
|
+
* @param symbol - Trading pair symbol
|
|
47981
47982
|
* @param dto.bucketName - State bucket name
|
|
47982
47983
|
* @param dto.initialValue - Default value when no persisted state exists
|
|
47983
47984
|
* @returns Promise resolving to current state value, or initialValue if no signal
|
|
@@ -47997,16 +47998,16 @@ async function getMinutesSinceLatestSignalCreated(symbol) {
|
|
|
47997
47998
|
* }
|
|
47998
47999
|
* ```
|
|
47999
48000
|
*/
|
|
48000
|
-
async function getSignalState(dto) {
|
|
48001
|
+
async function getSignalState(symbol, dto) {
|
|
48001
48002
|
const { bucketName, initialValue } = dto;
|
|
48002
|
-
backtest.loggerService.info(GET_SIGNAL_STATE_METHOD_NAME, { bucketName });
|
|
48003
|
+
backtest.loggerService.info(GET_SIGNAL_STATE_METHOD_NAME, { symbol, bucketName });
|
|
48003
48004
|
if (!ExecutionContextService.hasContext()) {
|
|
48004
48005
|
throw new Error("getSignalState requires an execution context");
|
|
48005
48006
|
}
|
|
48006
48007
|
if (!MethodContextService.hasContext()) {
|
|
48007
48008
|
throw new Error("getSignalState requires a method context");
|
|
48008
48009
|
}
|
|
48009
|
-
const { backtest: isBacktest
|
|
48010
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
48010
48011
|
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
48011
48012
|
const currentPrice = await backtest.exchangeConnectionService.getAveragePrice(symbol);
|
|
48012
48013
|
let signal;
|
|
@@ -48042,6 +48043,7 @@ async function getSignalState(dto) {
|
|
|
48042
48043
|
* SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25).
|
|
48043
48044
|
* Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.
|
|
48044
48045
|
*
|
|
48046
|
+
* @param symbol - Trading pair symbol
|
|
48045
48047
|
* @param dto.bucketName - State bucket name
|
|
48046
48048
|
* @param dto.initialValue - Default value when no persisted state exists
|
|
48047
48049
|
* @param dto.dispatch - New value or updater function receiving current value
|
|
@@ -48065,7 +48067,7 @@ async function getSignalState(dto) {
|
|
|
48065
48067
|
* );
|
|
48066
48068
|
* ```
|
|
48067
48069
|
*/
|
|
48068
|
-
async function setSignalState(dispatch, dto) {
|
|
48070
|
+
async function setSignalState(symbol, dispatch, dto) {
|
|
48069
48071
|
const { bucketName, initialValue } = dto;
|
|
48070
48072
|
backtest.loggerService.info(SET_SIGNAL_STATE_METHOD_NAME, { bucketName });
|
|
48071
48073
|
if (!ExecutionContextService.hasContext()) {
|
|
@@ -48074,7 +48076,7 @@ async function setSignalState(dispatch, dto) {
|
|
|
48074
48076
|
if (!MethodContextService.hasContext()) {
|
|
48075
48077
|
throw new Error("setSignalState requires a method context");
|
|
48076
48078
|
}
|
|
48077
|
-
const { backtest: isBacktest
|
|
48079
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
48078
48080
|
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
48079
48081
|
const currentPrice = await backtest.exchangeConnectionService.getAveragePrice(symbol);
|
|
48080
48082
|
let signal;
|
|
@@ -48632,14 +48634,14 @@ async function setSessionData(symbol, value) {
|
|
|
48632
48634
|
}
|
|
48633
48635
|
|
|
48634
48636
|
const CREATE_SIGNAL_STATE_METHOD_NAME = "state.createSignalState";
|
|
48635
|
-
const CREATE_SET_STATE_FN = (params) => async (dispatch) => {
|
|
48637
|
+
const CREATE_SET_STATE_FN = (params) => async (symbol, dispatch) => {
|
|
48636
48638
|
if (!ExecutionContextService.hasContext()) {
|
|
48637
48639
|
throw new Error("createSignalState requires an execution context");
|
|
48638
48640
|
}
|
|
48639
48641
|
if (!MethodContextService.hasContext()) {
|
|
48640
48642
|
throw new Error("createSignalState requires a method context");
|
|
48641
48643
|
}
|
|
48642
|
-
const { backtest: isBacktest
|
|
48644
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
48643
48645
|
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
48644
48646
|
const currentPrice = await backtest.exchangeConnectionService.getAveragePrice(symbol);
|
|
48645
48647
|
let signal;
|
|
@@ -48661,14 +48663,14 @@ const CREATE_SET_STATE_FN = (params) => async (dispatch) => {
|
|
|
48661
48663
|
}
|
|
48662
48664
|
throw new Error(`createSignalState requires a pending or scheduled signal for symbol=${symbol} bucketName=${params.bucketName}`);
|
|
48663
48665
|
};
|
|
48664
|
-
const CREATE_GET_STATE_FN = (params) => async () => {
|
|
48666
|
+
const CREATE_GET_STATE_FN = (params) => async (symbol) => {
|
|
48665
48667
|
if (!ExecutionContextService.hasContext()) {
|
|
48666
48668
|
throw new Error("createSignalState requires an execution context");
|
|
48667
48669
|
}
|
|
48668
48670
|
if (!MethodContextService.hasContext()) {
|
|
48669
48671
|
throw new Error("createSignalState requires a method context");
|
|
48670
48672
|
}
|
|
48671
|
-
const { backtest: isBacktest
|
|
48673
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
48672
48674
|
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
48673
48675
|
const currentPrice = await backtest.exchangeConnectionService.getAveragePrice(symbol);
|
|
48674
48676
|
let signal;
|
package/build/index.mjs
CHANGED
|
@@ -47958,6 +47958,7 @@ async function getMinutesSinceLatestSignalCreated(symbol) {
|
|
|
47958
47958
|
* SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25).
|
|
47959
47959
|
* Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.
|
|
47960
47960
|
*
|
|
47961
|
+
* @param symbol - Trading pair symbol
|
|
47961
47962
|
* @param dto.bucketName - State bucket name
|
|
47962
47963
|
* @param dto.initialValue - Default value when no persisted state exists
|
|
47963
47964
|
* @returns Promise resolving to current state value, or initialValue if no signal
|
|
@@ -47977,16 +47978,16 @@ async function getMinutesSinceLatestSignalCreated(symbol) {
|
|
|
47977
47978
|
* }
|
|
47978
47979
|
* ```
|
|
47979
47980
|
*/
|
|
47980
|
-
async function getSignalState(dto) {
|
|
47981
|
+
async function getSignalState(symbol, dto) {
|
|
47981
47982
|
const { bucketName, initialValue } = dto;
|
|
47982
|
-
backtest.loggerService.info(GET_SIGNAL_STATE_METHOD_NAME, { bucketName });
|
|
47983
|
+
backtest.loggerService.info(GET_SIGNAL_STATE_METHOD_NAME, { symbol, bucketName });
|
|
47983
47984
|
if (!ExecutionContextService.hasContext()) {
|
|
47984
47985
|
throw new Error("getSignalState requires an execution context");
|
|
47985
47986
|
}
|
|
47986
47987
|
if (!MethodContextService.hasContext()) {
|
|
47987
47988
|
throw new Error("getSignalState requires a method context");
|
|
47988
47989
|
}
|
|
47989
|
-
const { backtest: isBacktest
|
|
47990
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
47990
47991
|
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
47991
47992
|
const currentPrice = await backtest.exchangeConnectionService.getAveragePrice(symbol);
|
|
47992
47993
|
let signal;
|
|
@@ -48022,6 +48023,7 @@ async function getSignalState(dto) {
|
|
|
48022
48023
|
* SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25).
|
|
48023
48024
|
* Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.
|
|
48024
48025
|
*
|
|
48026
|
+
* @param symbol - Trading pair symbol
|
|
48025
48027
|
* @param dto.bucketName - State bucket name
|
|
48026
48028
|
* @param dto.initialValue - Default value when no persisted state exists
|
|
48027
48029
|
* @param dto.dispatch - New value or updater function receiving current value
|
|
@@ -48045,7 +48047,7 @@ async function getSignalState(dto) {
|
|
|
48045
48047
|
* );
|
|
48046
48048
|
* ```
|
|
48047
48049
|
*/
|
|
48048
|
-
async function setSignalState(dispatch, dto) {
|
|
48050
|
+
async function setSignalState(symbol, dispatch, dto) {
|
|
48049
48051
|
const { bucketName, initialValue } = dto;
|
|
48050
48052
|
backtest.loggerService.info(SET_SIGNAL_STATE_METHOD_NAME, { bucketName });
|
|
48051
48053
|
if (!ExecutionContextService.hasContext()) {
|
|
@@ -48054,7 +48056,7 @@ async function setSignalState(dispatch, dto) {
|
|
|
48054
48056
|
if (!MethodContextService.hasContext()) {
|
|
48055
48057
|
throw new Error("setSignalState requires a method context");
|
|
48056
48058
|
}
|
|
48057
|
-
const { backtest: isBacktest
|
|
48059
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
48058
48060
|
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
48059
48061
|
const currentPrice = await backtest.exchangeConnectionService.getAveragePrice(symbol);
|
|
48060
48062
|
let signal;
|
|
@@ -48612,14 +48614,14 @@ async function setSessionData(symbol, value) {
|
|
|
48612
48614
|
}
|
|
48613
48615
|
|
|
48614
48616
|
const CREATE_SIGNAL_STATE_METHOD_NAME = "state.createSignalState";
|
|
48615
|
-
const CREATE_SET_STATE_FN = (params) => async (dispatch) => {
|
|
48617
|
+
const CREATE_SET_STATE_FN = (params) => async (symbol, dispatch) => {
|
|
48616
48618
|
if (!ExecutionContextService.hasContext()) {
|
|
48617
48619
|
throw new Error("createSignalState requires an execution context");
|
|
48618
48620
|
}
|
|
48619
48621
|
if (!MethodContextService.hasContext()) {
|
|
48620
48622
|
throw new Error("createSignalState requires a method context");
|
|
48621
48623
|
}
|
|
48622
|
-
const { backtest: isBacktest
|
|
48624
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
48623
48625
|
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
48624
48626
|
const currentPrice = await backtest.exchangeConnectionService.getAveragePrice(symbol);
|
|
48625
48627
|
let signal;
|
|
@@ -48641,14 +48643,14 @@ const CREATE_SET_STATE_FN = (params) => async (dispatch) => {
|
|
|
48641
48643
|
}
|
|
48642
48644
|
throw new Error(`createSignalState requires a pending or scheduled signal for symbol=${symbol} bucketName=${params.bucketName}`);
|
|
48643
48645
|
};
|
|
48644
|
-
const CREATE_GET_STATE_FN = (params) => async () => {
|
|
48646
|
+
const CREATE_GET_STATE_FN = (params) => async (symbol) => {
|
|
48645
48647
|
if (!ExecutionContextService.hasContext()) {
|
|
48646
48648
|
throw new Error("createSignalState requires an execution context");
|
|
48647
48649
|
}
|
|
48648
48650
|
if (!MethodContextService.hasContext()) {
|
|
48649
48651
|
throw new Error("createSignalState requires a method context");
|
|
48650
48652
|
}
|
|
48651
|
-
const { backtest: isBacktest
|
|
48653
|
+
const { backtest: isBacktest } = backtest.executionContextService.context;
|
|
48652
48654
|
const { exchangeName, frameName, strategyName } = backtest.methodContextService.context;
|
|
48653
48655
|
const currentPrice = await backtest.exchangeConnectionService.getAveragePrice(symbol);
|
|
48654
48656
|
let signal;
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -9358,6 +9358,7 @@ declare function getMinutesSinceLatestSignalCreated(symbol: string): Promise<num
|
|
|
9358
9358
|
* SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25).
|
|
9359
9359
|
* Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.
|
|
9360
9360
|
*
|
|
9361
|
+
* @param symbol - Trading pair symbol
|
|
9361
9362
|
* @param dto.bucketName - State bucket name
|
|
9362
9363
|
* @param dto.initialValue - Default value when no persisted state exists
|
|
9363
9364
|
* @returns Promise resolving to current state value, or initialValue if no signal
|
|
@@ -9377,7 +9378,7 @@ declare function getMinutesSinceLatestSignalCreated(symbol: string): Promise<num
|
|
|
9377
9378
|
* }
|
|
9378
9379
|
* ```
|
|
9379
9380
|
*/
|
|
9380
|
-
declare function getSignalState<Value extends object = object>(dto: {
|
|
9381
|
+
declare function getSignalState<Value extends object = object>(symbol: string, dto: {
|
|
9381
9382
|
bucketName: string;
|
|
9382
9383
|
initialValue: Value;
|
|
9383
9384
|
}): Promise<Value>;
|
|
@@ -9395,6 +9396,7 @@ declare function getSignalState<Value extends object = object>(dto: {
|
|
|
9395
9396
|
* SL trades show peak < 0.15% (Feb08, Feb13) or never go positive (Feb25).
|
|
9396
9397
|
* Rule: if minutesOpen >= N and peakPercent < threshold (e.g. 0.3%) — exit.
|
|
9397
9398
|
*
|
|
9399
|
+
* @param symbol - Trading pair symbol
|
|
9398
9400
|
* @param dto.bucketName - State bucket name
|
|
9399
9401
|
* @param dto.initialValue - Default value when no persisted state exists
|
|
9400
9402
|
* @param dto.dispatch - New value or updater function receiving current value
|
|
@@ -9418,7 +9420,7 @@ declare function getSignalState<Value extends object = object>(dto: {
|
|
|
9418
9420
|
* );
|
|
9419
9421
|
* ```
|
|
9420
9422
|
*/
|
|
9421
|
-
declare function setSignalState<Value extends object = object>(dispatch: Value | Dispatch$1<Value>, dto: {
|
|
9423
|
+
declare function setSignalState<Value extends object = object>(symbol: string, dispatch: Value | Dispatch$1<Value>, dto: {
|
|
9422
9424
|
bucketName: string;
|
|
9423
9425
|
initialValue: Value;
|
|
9424
9426
|
}): Promise<Value>;
|
|
@@ -9771,18 +9773,20 @@ interface IStateParams<Value extends object = object> {
|
|
|
9771
9773
|
/**
|
|
9772
9774
|
* Reads the current state value for the active pending or scheduled signal.
|
|
9773
9775
|
* Resolved from execution context — no signalId argument required.
|
|
9776
|
+
* @param symbol - Trading pair symbol
|
|
9774
9777
|
* @returns Current state value
|
|
9775
9778
|
* @throws Error if no pending or scheduled signal exists
|
|
9776
9779
|
*/
|
|
9777
|
-
type GetStateFn<Value extends object = object> = () => Promise<Value>;
|
|
9780
|
+
type GetStateFn<Value extends object = object> = (symbol: string) => Promise<Value>;
|
|
9778
9781
|
/**
|
|
9779
9782
|
* Updates the state value for the active pending or scheduled signal.
|
|
9780
9783
|
* Resolved from execution context — no signalId argument required.
|
|
9784
|
+
* @param symbol - Trading pair symbol
|
|
9781
9785
|
* @param dispatch - New value or updater function receiving current value
|
|
9782
9786
|
* @returns Updated state value
|
|
9783
9787
|
* @throws Error if no pending or scheduled signal exists
|
|
9784
9788
|
*/
|
|
9785
|
-
type SetStateFn<Value extends object = object> = (dispatch: Value | Dispatch<Value>) => Promise<Value>;
|
|
9789
|
+
type SetStateFn<Value extends object = object> = (symbol: string, dispatch: Value | Dispatch<Value>) => Promise<Value>;
|
|
9786
9790
|
/**
|
|
9787
9791
|
* Tuple returned by createSignalState — [getState, setState] bound to the bucket.
|
|
9788
9792
|
* Both functions resolve the active signal and backtest flag from execution context automatically.
|