@@ -208,39 +208,53 @@ export default class TicksService {
208
208
} ) ;
209
209
}
210
210
requestStream ( options ) {
211
- return this . requestPipSizes ( ) . then ( ( ) => this . requestTicks ( options ) ) ;
211
+ const { style } = options ;
212
+
213
+ if ( style === 'ticks' ) {
214
+ if ( ! this . ticks_history_promise ) {
215
+ this . ticks_history_promise = this . requestPipSizes ( ) . then ( ( ) => this . requestTicks ( options ) ) ;
216
+ }
217
+
218
+ return this . ticks_history_promise ;
219
+ }
220
+
221
+ if ( style === 'candles' ) {
222
+ if ( ! this . candles_promise ) {
223
+ this . candles_promise = this . requestPipSizes ( ) . then ( ( ) => this . requestTicks ( options ) ) ;
224
+ }
225
+
226
+ return this . candles_promise ;
227
+ }
228
+
229
+ return [ ] ;
212
230
}
213
231
requestTicks ( options ) {
214
232
const { symbol, granularity, style } = options ;
215
233
216
- if ( ! this . ticks_history_promise ) {
217
- this . ticks_history_promise = new Promise ( ( resolve , reject ) => {
218
- doUntilDone ( ( ) =>
219
- this . api . getTickHistory ( symbol , {
220
- subscribe : 1 ,
221
- end : 'latest' ,
222
- count : 1000 ,
223
- granularity : granularity ? Number ( granularity ) : undefined ,
224
- style,
225
- } )
226
- )
227
- . then ( r => {
228
- if ( style === 'ticks' ) {
229
- const ticks = historyToTicks ( r . history ) ;
230
-
231
- this . updateTicksAndCallListeners ( symbol , ticks ) ;
232
- resolve ( ticks ) ;
233
- } else {
234
- const candles = parseCandles ( r . candles ) ;
235
-
236
- this . updateCandlesAndCallListeners ( [ symbol , Number ( granularity ) ] , candles ) ;
237
-
238
- resolve ( candles ) ;
239
- }
240
- } )
241
- . catch ( reject ) ;
242
- } ) ;
243
- }
244
- return this . ticks_history_promise ;
234
+ return new Promise ( ( resolve , reject ) => {
235
+ doUntilDone ( ( ) =>
236
+ this . api . getTickHistory ( symbol , {
237
+ subscribe : 1 ,
238
+ end : 'latest' ,
239
+ count : 1000 ,
240
+ granularity : granularity ? Number ( granularity ) : undefined ,
241
+ style,
242
+ } )
243
+ )
244
+ . then ( r => {
245
+ if ( style === 'ticks' ) {
246
+ const ticks = historyToTicks ( r . history ) ;
247
+
248
+ this . updateTicksAndCallListeners ( symbol , ticks ) ;
249
+ resolve ( ticks ) ;
250
+ } else {
251
+ const candles = parseCandles ( r . candles ) ;
252
+
253
+ this . updateCandlesAndCallListeners ( [ symbol , Number ( granularity ) ] , candles ) ;
254
+ resolve ( candles ) ;
255
+ }
256
+ } )
257
+ . catch ( reject ) ;
258
+ } ) ;
245
259
}
246
260
}
0 commit comments