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

aaron/Return correct type of list (ticks vs. candles) #3035

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Return correct type of list (ticks vs. candles)
  • Loading branch information
aaimio committed Oct 9, 2020
commit f442244c6f3a1c1f92cbd77287b00b5286e8406c
74 changes: 44 additions & 30 deletions src/botPage/common/TicksService.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,39 +208,53 @@ export default class TicksService {
});
}
requestStream(options) {
return this.requestPipSizes().then(() => this.requestTicks(options));
const { style } = options;

if (style === 'ticks') {
if (!this.ticks_history_promise) {
this.ticks_history_promise = this.requestPipSizes().then(() => this.requestTicks(options));
}

return this.ticks_history_promise;
}

if (style === 'candles') {
if (!this.candles_promise) {
this.candles_promise = this.requestPipSizes().then(() => this.requestTicks(options));
}

return this.candles_promise;
}

return [];
}
requestTicks(options) {
const { symbol, granularity, style } = options;

if (!this.ticks_history_promise) {
this.ticks_history_promise = new Promise((resolve, reject) => {
doUntilDone(() =>
this.api.getTickHistory(symbol, {
subscribe : 1,
end : 'latest',
count : 1000,
granularity: granularity ? Number(granularity) : undefined,
style,
})
)
.then(r => {
if (style === 'ticks') {
const ticks = historyToTicks(r.history);

this.updateTicksAndCallListeners(symbol, ticks);
resolve(ticks);
} else {
const candles = parseCandles(r.candles);

this.updateCandlesAndCallListeners([symbol, Number(granularity)], candles);

resolve(candles);
}
})
.catch(reject);
});
}
return this.ticks_history_promise;
return new Promise((resolve, reject) => {
doUntilDone(() =>
this.api.getTickHistory(symbol, {
subscribe : 1,
end : 'latest',
count : 1000,
granularity: granularity ? Number(granularity) : undefined,
style,
})
)
.then(r => {
if (style === 'ticks') {
const ticks = historyToTicks(r.history);

this.updateTicksAndCallListeners(symbol, ticks);
resolve(ticks);
} else {
const candles = parseCandles(r.candles);

this.updateCandlesAndCallListeners([symbol, Number(granularity)], candles);
resolve(candles);
}
})
.catch(reject);
});
}
}
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