fix(trading): 合并销毁和快照任务确保K线价格正确
将 executeMinuteBurn 和 createPriceSnapshot 合并为单个 cron 任务, 确保快照在销毁完成后创建,避免K线出现价格不变的间隔 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
b826511f3c
commit
5a719eef61
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue