@@ -19,13 +19,21 @@ class TradePairs {
1919 limit : number ,
2020 ) : Promise < batchedOHLCV | undefined > {
2121 try {
22- const limitCandlestick = ~ ~ ( limit + ( ( _ . max ( intervalsTimeInSec ) as number ) / EXCHANGE_BASE_INTERVAL_IN_SEC ) * 1.5 ) ;
22+ const limitCandlestick = ~ ~ (
23+ limit +
24+ ( ( _ . max ( intervalsTimeInSec ) as number ) / EXCHANGE_BASE_INTERVAL_IN_SEC ) * 1.5
25+ ) ;
2326
2427 const batch = { } ;
2528 const result = new Map ( ) ;
2629
2730 if ( exchange && symbol && intervalsTimeInSec && limitCandlestick ) {
28- const candledata = await this . _getCandlestickFromDB ( exchange , symbol , EXCHANGE_BASE_INTERVAL_IN_SEC , limitCandlestick ) ;
31+ const candledata = await this . getCandlestickFromDB (
32+ exchange ,
33+ symbol ,
34+ EXCHANGE_BASE_INTERVAL_IN_SEC ,
35+ limitCandlestick ,
36+ ) ;
2937
3038 batch [ EXCHANGE_BASE_INTERVAL_IN_SEC ] = candledata ;
3139
@@ -55,14 +63,19 @@ class TradePairs {
5563 }
5664 }
5765
58- private async _getCandlestickFromDB ( exchange : string , symbol : string , interval : number , limit : number ) : Promise < OHLCV [ ] | undefined > {
66+ public async getCandlestickFromDB (
67+ exchange : string ,
68+ symbol : string ,
69+ interval : number ,
70+ limit : number ,
71+ ) : Promise < OHLCV [ ] | undefined > {
5972 try {
6073 // eslint-disable-next-line @typescript-eslint/no-explicit-any
6174 let rows : any = [ ] ;
6275
6376 // TODO add proper support Tick Chart values
6477 if ( [ 16 , 32 , 64 , 128 , 256 , 512 , 1024 ] . indexOf ( interval ) >= 0 ) {
65- rows = await this . getTickchartFromDB ( exchange , symbol , interval , limit ) ;
78+ rows = await this . _getTickchartFromDB ( exchange , symbol , interval , limit ) ;
6679
6780 // Sort by time asc
6881 rows = _ . sortBy ( rows , [ 'time' ] ) ;
@@ -71,10 +84,12 @@ class TradePairs {
7184 }
7285
7386 // Converted Candles
74- if ( interval != EXCHANGE_BASE_INTERVAL_IN_SEC && limit != 0 ) {
87+ if ( interval !== EXCHANGE_BASE_INTERVAL_IN_SEC && limit !== 0 ) {
88+ // eslint-disable-next-line no-param-reassign
7589 limit *= interval / EXCHANGE_BASE_INTERVAL_IN_SEC ;
7690
7791 // Limit should be always higher than convert ratio * 1,5 + 1
92+ // eslint-disable-next-line no-param-reassign
7893 limit += ( interval / EXCHANGE_BASE_INTERVAL_IN_SEC ) * 1.5 ;
7994 }
8095
@@ -83,7 +98,7 @@ class TradePairs {
8398 [ rows ] = await ExchangeDB . query ( 'SELECT * FROM ?? ORDER BY `time` DESC LIMIT ?;' , [ tableName , ~ ~ limit + 1 ] ) ;
8499
85100 // Convert into new time frame
86- if ( interval != EXCHANGE_BASE_INTERVAL_IN_SEC ) {
101+ if ( interval !== EXCHANGE_BASE_INTERVAL_IN_SEC ) {
87102 rows = CandleConvert . json ( rows , EXCHANGE_BASE_INTERVAL_IN_SEC , interval ) ;
88103 }
89104
@@ -96,11 +111,21 @@ class TradePairs {
96111 }
97112 }
98113
99- public async getTickchartFromDB ( exchange : string , symbol : string , tickLength : number , limit : number , time = 0 ) : Promise < OHLCV [ ] | undefined > {
114+ private async _getTickchartFromDB (
115+ exchange : string ,
116+ symbol : string ,
117+ tickLength : number ,
118+ limit : number ,
119+ time = 0 ,
120+ ) : Promise < OHLCV [ ] | undefined > {
100121 try {
101122 const tableName = Utils . tradesName ( exchange , symbol ) ;
102123
103- const [ rows ] = await ExchangeDB . query ( 'SELECT * FROM ?? WHERE time > ? ORDER BY `time` DESC LIMIT ?;' , [ tableName , time , limit ] ) ;
124+ const [ rows ] = await ExchangeDB . query ( 'SELECT * FROM ?? WHERE time > ? ORDER BY `time` DESC LIMIT ?;' , [
125+ tableName ,
126+ time ,
127+ limit ,
128+ ] ) ;
104129
105130 return CandleConvert . tick_chart ( rows as Trade [ ] , tickLength ) ;
106131 } catch ( e ) {
0 commit comments