diff --git a/apps/vendor-ccxt/src/index.ts b/apps/vendor-ccxt/src/index.ts index ef41b59ac..7532d0fd9 100644 --- a/apps/vendor-ccxt/src/index.ts +++ b/apps/vendor-ccxt/src/index.ts @@ -24,6 +24,7 @@ import { delayWhen, expand, filter, + firstValueFrom, from, lastValueFrom, map, @@ -55,6 +56,25 @@ import { // @ts-ignore const ex: Exchange = new ccxt[EXCHANGE_ID](CCXT_PARAMS); + console.info( + formatTime(Date.now()), + `FeatureCheck`, + EXCHANGE_ID, + JSON.stringify({ + fetchAccounts: !!ex.has['fetchAccounts'], + fetchOHLCV: !!ex.has['fetchOHLCV'], + watchOHLCV: !!ex.has['watchOHLCV'], + fetchTicker: !!ex.has['fetchTicker'], + watchTicker: !!ex.has['watchTicker'], + fetchBalance: !!ex.has['fetchBalance'], + watchBalance: !!ex.has['watchBalance'], + fetchPositions: !!ex.has['fetchPositions'], + watchPositions: !!ex.has['watchPositions'], + fetchOpenOrders: !!ex.has['fetchOpenOrders'], + fetchFundingRate: !!ex.has['fetchFundingRate'], + }), + ); + if (EXCHANGE_ID === 'binance') { ex.options['warnOnFetchOpenOrdersWithoutSymbol'] = false; ex.options['defaultType'] = 'future'; @@ -111,6 +131,8 @@ import { ) .subscribe(); + await firstValueFrom(products$); + const mapPeriodInSecToCCXTTimeframe = (period_in_sec: number): string => { if (period_in_sec % 2592000 === 0) { return `${period_in_sec / 2592000}M`; @@ -238,7 +260,7 @@ import { }; const useFundingRate = memoize((symbol: string) => { - return from(ex.fetchFundingRate(symbol)).pipe( + return defer(() => ex.fetchFundingRate(symbol)).pipe( repeat({ delay: 10_000 }), retry({ delay: 5000 }), shareReplay(1), diff --git a/common/changes/@yuants/vendor-ccxt/2024-02-23-09-52.json b/common/changes/@yuants/vendor-ccxt/2024-02-23-09-52.json new file mode 100644 index 000000000..0ce5a15a6 --- /dev/null +++ b/common/changes/@yuants/vendor-ccxt/2024-02-23-09-52.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@yuants/vendor-ccxt", + "comment": "fix(vendor-ccxt): await symbol loading & fix funding rate", + "type": "patch" + } + ], + "packageName": "@yuants/vendor-ccxt" +} \ No newline at end of file