Skip to content

Commit

Permalink
fix(vendor-ccxt): await symbol loading & fix funding rate (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thrimbda authored Feb 23, 2024
1 parent 9102cdb commit 62f86fd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
24 changes: 23 additions & 1 deletion apps/vendor-ccxt/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
delayWhen,
expand,
filter,
firstValueFrom,
from,
lastValueFrom,
map,
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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`;
Expand Down Expand Up @@ -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),
Expand Down
10 changes: 10 additions & 0 deletions common/changes/@yuants/vendor-ccxt/2024-02-23-09-52.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 62f86fd

Please sign in to comment.