Add immediate reprice logic to MakerPointsEngine

- Enhanced the MakerPointsEngine by introducing a new method `shouldTriggerImmediateReprice` to trigger an immediate tick when the market depth deviates beyond a specified minimum reprice basis points threshold.
- Updated the existing depth protection logic to include this new reprice condition.
- Added a comprehensive test suite to validate the immediate reprice functionality and its integration with the MakerPoints engine.
This commit is contained in:
discountry
2026-02-08 00:08:38 +08:00
parent 61e6e4cdde
commit 3f67b99291
2 changed files with 135 additions and 1 deletions
+19 -1
View File
@@ -346,7 +346,7 @@ export class MakerPointsEngine {
this.lastStandxDepthTime = Date.now();
this.feedStatus.depth = true;
this.emitUpdate();
if (this.shouldTriggerImmediateDepthProtection(depth)) {
if (this.shouldTriggerImmediateDepthProtection(depth) || this.shouldTriggerImmediateReprice(depth)) {
this.forceTickRequested = true;
void this.tick();
}
@@ -914,6 +914,24 @@ export class MakerPointsEngine {
return false;
}
/**
* 当盘口相对上次报价偏移超过 minRepriceBps 时,立即触发一次主循环,优先撤销旧报价。
*/
private shouldTriggerImmediateReprice(depth: AsterDepth | null): boolean {
if (!depth) return false;
if (this.defenseMode || this.reconnectResetPending || this.stopLossProcessing) return false;
const hasActiveEntryOrders = this.openOrders.some(
(order) => order.symbol === this.config.symbol && !order.reduceOnly && isOrderActiveStatus(order.status)
);
if (!hasActiveEntryOrders) return false;
const { topBid, topAsk } = getTopPrices(depth);
if (topBid == null || topAsk == null) return false;
return this.shouldReprice(topBid, topAsk);
}
private buildCloseOnlyOrders(
position: PositionSnapshot,
bid1: number,