Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit f442244

Browse files
committed
Return correct type of list (ticks vs. candles)
1 parent 11eaf72 commit f442244

File tree

1 file changed

+44
-30
lines changed

1 file changed

+44
-30
lines changed

src/botPage/common/TicksService.js

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -208,39 +208,53 @@ export default class TicksService {
208208
});
209209
}
210210
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 [];
212230
}
213231
requestTicks(options) {
214232
const { symbol, granularity, style } = options;
215233

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+
});
245259
}
246260
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy