From 5a719eef618b9504c11def93090d8332ba07881b Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 17 Jan 2026 23:26:04 -0800 Subject: [PATCH] =?UTF-8?q?fix(trading):=20=E5=90=88=E5=B9=B6=E9=94=80?= =?UTF-8?q?=E6=AF=81=E5=92=8C=E5=BF=AB=E7=85=A7=E4=BB=BB=E5=8A=A1=E7=A1=AE?= =?UTF-8?q?=E4=BF=9DK=E7=BA=BF=E4=BB=B7=E6=A0=BC=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 executeMinuteBurn 和 createPriceSnapshot 合并为单个 cron 任务, 确保快照在销毁完成后创建,避免K线出现价格不变的间隔 Co-Authored-By: Claude Opus 4.5 --- .../application/schedulers/burn.scheduler.ts | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/backend/services/trading-service/src/application/schedulers/burn.scheduler.ts b/backend/services/trading-service/src/application/schedulers/burn.scheduler.ts index e9788be9..af88014e 100644 --- a/backend/services/trading-service/src/application/schedulers/burn.scheduler.ts +++ b/backend/services/trading-service/src/application/schedulers/burn.scheduler.ts @@ -27,30 +27,25 @@ export class BurnScheduler implements OnModuleInit { } /** - * 每分钟执行销毁 + * 每分钟执行销毁并创建价格快照 * 每分钟销毁量 = 100亿 ÷ (365×4×1440) = 4756.468797564687 进黑洞 + * + * 注意:销毁和快照必须在同一个任务中顺序执行, + * 确保快照总是捕获销毁后的最新价格,避免K线出现价格不变的情况 */ @Cron(CronExpression.EVERY_MINUTE) - async executeMinuteBurn(): Promise { + async executeMinuteBurnAndSnapshot(): Promise { try { + // 1. 先执行销毁 const burnAmount = await this.burnService.executeMinuteBurn(); if (!burnAmount.isZero()) { this.logger.debug(`Minute burn completed: ${burnAmount.toFixed(8)}`); } - } catch (error) { - this.logger.error('Failed to execute minute burn', error); - } - } - /** - * 每分钟创建价格快照 - */ - @Cron(CronExpression.EVERY_MINUTE) - async createPriceSnapshot(): Promise { - try { + // 2. 销毁完成后立即创建价格快照 await this.priceService.createSnapshot(); } catch (error) { - this.logger.error('Failed to create price snapshot', error); + this.logger.error('Failed to execute minute burn and snapshot', error); } }