Skip to content

Commit 1ed6487

Browse files
authored
fix: remove empty candles from spot tv chart (dydxprotocol#2023)
1 parent b4ce9e0 commit 1ed6487

File tree

1 file changed

+10
-7
lines changed
  • src/lib/tradingView/spotDatafeed

1 file changed

+10
-7
lines changed

src/lib/tradingView/spotDatafeed/index.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import type { DatafeedConfiguration, IBasicDataFeed } from 'public/tradingview/c
44

55
import { type RootStore } from '@/state/_store';
66

7-
import { getSpotBars, SpotApiGetBarsQuery } from '@/clients/spotApi';
7+
import {
8+
getSpotBars,
9+
SpotApiGetBarsQuery,
10+
SpotApiTokenPairStatisticsType,
11+
} from '@/clients/spotApi';
812
import { waitForSelector } from '@/lib/asyncUtils';
913
import {
1014
subscribeToSpotCandles,
@@ -56,11 +60,7 @@ export const getSpotDatafeed = (store: RootStore, spotApiUrl: string): IBasicDat
5660
},
5761

5862
getBars: async (symbolInfo, resolution, periodParams, onHistoryCallback, onErrorCallback) => {
59-
const { from, to } = periodParams;
60-
61-
// Clamp to parameter to current time to prevent API from returning future placeholder candles
62-
const currentTimeSeconds = Math.floor(Date.now() / 1000) + 1;
63-
const clampedTo = Math.min(to, currentTimeSeconds);
63+
const { from, to, countBack } = periodParams;
6464

6565
if (!symbolInfo.ticker) {
6666
const error = new Error('Symbol ticker is required');
@@ -76,7 +76,10 @@ export const getSpotDatafeed = (store: RootStore, spotApiUrl: string): IBasicDat
7676
tokenMint,
7777
resolution: interval,
7878
from,
79-
to: clampedTo,
79+
to,
80+
countback: Math.min(countBack, 1500),
81+
removeEmptyBars: true,
82+
statsType: SpotApiTokenPairStatisticsType.Filtered,
8083
};
8184

8285
const bars = await wrapAndLogBonsaiError(

0 commit comments

Comments
 (0)