Add Binance depth monitoring configuration to MakerPoints

- Introduced new environment variables `MAKER_POINTS_BINANCE_DEPTH_WINDOW_BPS` and `MAKER_POINTS_BINANCE_DEPTH_IMBALANCE_RATIO` to configure Binance depth monitoring.
- Updated `MakerPointsConfig` interface and implementation to include these new parameters.
- Enhanced translations to reflect dynamic depth window information in the UI.
- Added tests to validate the new configuration options and their integration into the MakerPoints engine.
This commit is contained in:
discountry
2026-02-07 23:58:01 +08:00
parent 858b2f304b
commit 61e6e4cdde
8 changed files with 138 additions and 5 deletions
+6
View File
@@ -227,6 +227,10 @@ export interface MakerPointsConfig {
minRepriceBps: number;
/** 是否根据 Binance 盘口深度失衡自动取消单边挂单,默认 true */
enableBinanceDepthCancel: boolean;
/** Binance 深度监控窗口(bps),默认 5 */
binanceDepthWindowBps?: number;
/** Binance 深度失衡比例阈值,默认 8 */
binanceDepthImbalanceRatio?: number;
/** 各档位最小深度阈值 (BTC),盘口到目标价之间的挂单量低于此值则跳过该档位,默认 10 */
filterMinDepth: number;
}
@@ -254,6 +258,8 @@ export const makerPointsConfig: MakerPointsConfig = {
band30To100Amount: parseNumber(process.env.MAKER_POINTS_BAND_30_100_AMOUNT, defaultMakerPointsAmount),
minRepriceBps: parseNumber(process.env.MAKER_POINTS_MIN_REPRICE_BPS, 3),
enableBinanceDepthCancel: parseBoolean(process.env.MAKER_POINTS_BINANCE_DEPTH_CANCEL, true),
binanceDepthWindowBps: parseNumber(process.env.MAKER_POINTS_BINANCE_DEPTH_WINDOW_BPS, 5),
binanceDepthImbalanceRatio: parseNumber(process.env.MAKER_POINTS_BINANCE_DEPTH_IMBALANCE_RATIO, 8),
filterMinDepth: parseNumber(process.env.MAKER_POINTS_FILTER_MIN_DEPTH, 10),
};
+2 -2
View File
@@ -248,8 +248,8 @@ const translations: Record<string, TranslationEntry> = {
en: "Quote mode: {mode} | BUY {buy} | SELL {sell}",
},
"makerPoints.binanceLine": {
zh: "Binance 深度(±9bps): 买 {buy} 卖 {sell} 状态: {status}",
en: "Binance depth (±9bps): bid {buy} | ask {sell} | Status: {status}",
zh: "Binance 深度(±{windowBps}bps): 买 {buy} 卖 {sell} 状态: {status}",
en: "Binance depth (±{windowBps}bps): bid {buy} | ask {sell} | Status: {status}",
},
"makerPoints.bandDepthLine": {
zh: "StandX 档位 {band}bps 深度: 买 {buy} 卖 {sell}",
+6 -2
View File
@@ -206,8 +206,12 @@ export class MakerPointsEngine {
baseUrl: process.env.BINANCE_SPOT_WS_URL ?? process.env.BINANCE_WS_URL,
restBaseUrl: process.env.BINANCE_REST_URL,
levels: 20,
ratio: 2,
depthWindowBps: 9,
ratio: Number.isFinite(this.config.binanceDepthImbalanceRatio)
? Math.max(1.01, Number(this.config.binanceDepthImbalanceRatio))
: 8,
depthWindowBps: Number.isFinite(this.config.binanceDepthWindowBps)
? Math.max(1, Number(this.config.binanceDepthWindowBps))
: 5,
speedMs: 100,
logger: (context, error) => {
this.tradeLog.push("warn", `Binance ${context} 异常: ${extractMessage(error)}`);
+1
View File
@@ -162,6 +162,7 @@ export function MakerPointsApp({ onExit }: MakerPointsAppProps) {
{t("makerPoints.binanceLine", {
buy: formatNumber(snapshot.binanceDepth?.buySum ?? 0, 4),
sell: formatNumber(snapshot.binanceDepth?.sellSum ?? 0, 4),
windowBps: snapshot.binanceDepth?.windowBps ?? 5,
status: imbalanceLabel,
})}
</Text>