refactor(data/exchanges): 多子类架构 + 工厂入口
- 每个交易所独立子类:BinanceRestClient extends BaseRestClient - 统一入口 createRestClient(exchangeId) 工厂函数 - KLINE_INTERVAL_MS 移至 constants.ts - fetchKlines 签名统一为 (symbol, startTime, limit?, endTime?) - throttle 限流实际生效 - convertBinanceKline interval 参数化 - 删除 filterConsecutive 死代码 - 更新 run/exchange.ts 和 service/bnkline.ts 调用方
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { logger } from "../utils/logger";
|
||||
import { getAllPairs, updatePairLastBackfillTime } from '../service/pair';
|
||||
import { upsertOrUpdateKlines } from "../service/kline";
|
||||
import { Client } from '../exchanges/rest';
|
||||
import { createRestClient } from '../exchanges';
|
||||
|
||||
function getNowMinuteMS() {
|
||||
const minuteMS = 1000 * 60;
|
||||
@@ -11,7 +11,7 @@ function getNowMinuteMS() {
|
||||
const allPairs = await getAllPairs();
|
||||
|
||||
for (const pair of allPairs) {
|
||||
const client = new Client("binance");
|
||||
const client = createRestClient("binance");
|
||||
let lastBackfillTime = pair.last_backfill_time.getTime();
|
||||
try {
|
||||
while (lastBackfillTime < getNowMinuteMS()) {
|
||||
|
||||
Reference in New Issue
Block a user