fix(trading): 合并销毁和快照任务确保K线价格正确

将 executeMinuteBurn 和 createPriceSnapshot 合并为单个 cron 任务,
确保快照在销毁完成后创建,避免K线出现价格不变的间隔

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-17 23:26:04 -08:00
parent b826511f3c
commit 5a719eef61
1 changed files with 8 additions and 13 deletions

View File

@ -27,30 +27,25 @@ export class BurnScheduler implements OnModuleInit {
}
/**
*
*
* = 100亿 ÷ (365×4×1440) = 4756.468797564687
*
*
* K线出现价格不变的情况
*/
@Cron(CronExpression.EVERY_MINUTE)
async executeMinuteBurn(): Promise<void> {
async executeMinuteBurnAndSnapshot(): Promise<void> {
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<void> {
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);
}
}