diff --git a/apps/vendor-ccxt/src/index.ts b/apps/vendor-ccxt/src/index.ts index d4e9a657e..0fc3c9592 100644 --- a/apps/vendor-ccxt/src/index.ts +++ b/apps/vendor-ccxt/src/index.ts @@ -385,38 +385,36 @@ interface IGeneralSpecificRelation { if (!symbol) { return of([]); } - return ( - ex.has['watchOHLCV'] - ? defer(() => ex.watchOHLCV(symbol, timeframe)).pipe(repeat()) - : defer(() => { - const since = Date.now() - 3 * period_in_sec * 1000; - return ex.fetchOHLCV(symbol, timeframe, since); - }).pipe( - // - repeat({ delay: 1000 }), - ) - ).pipe( - mergeMap((x) => - from(x).pipe( - map( - ([t, o, h, l, c, vol]): IPeriod => ({ - datasource_id: EXCHANGE_ID, - product_id, - period_in_sec, - timestamp_in_us: t! * 1000, - start_at: t, - open: o!, - high: h!, - low: l!, - close: c!, - volume: vol!, - }), + return defer(() => { + const since = Date.now() - 3 * period_in_sec * 1000; + return ex.fetchOHLCV(symbol, timeframe, since); + }) + .pipe( + // + repeat({ delay: 1000 }), + ) + .pipe( + mergeMap((x) => + from(x).pipe( + map( + ([t, o, h, l, c, vol]): IPeriod => ({ + datasource_id: EXCHANGE_ID, + product_id, + period_in_sec, + timestamp_in_us: t! * 1000, + start_at: t, + open: o!, + high: h!, + low: l!, + close: c!, + volume: vol!, + }), + ), + toArray(), ), - toArray(), ), - ), - retry({ delay: 1000 }), - ); + retry({ delay: 1000 }), + ); }); if (!PUBLIC_ONLY) { diff --git a/common/changes/@yuants/vendor-ccxt/2024-02-25-14-57.json b/common/changes/@yuants/vendor-ccxt/2024-02-25-14-57.json new file mode 100644 index 000000000..7a4111455 --- /dev/null +++ b/common/changes/@yuants/vendor-ccxt/2024-02-25-14-57.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@yuants/vendor-ccxt", + "comment": "fetch ohlcv to correct error", + "type": "patch" + } + ], + "packageName": "@yuants/vendor-ccxt" +} \ No newline at end of file