VERSION 1.14 @ 2019-04-04 08:32:01.655131
x axis retains previous scale after restoring layout #3828 getVisiblePriceRange() not working in 1.14 (unstable) #3774 uppercase_instrument_names doesn't work for compare/overlay #3746 API method to trigger the Zoom Out #3739 Provide event that study properties was changed #3736 Fixed security issue in master #3699 widget.save have old data #3623 JS error on switching chart types #3602 Add a way to prevent scrolling beyond the beginning of bars #3597 Chart customization - overrides #3572 Theme override colors from saved_data #3557 Error while applying Pivot Points Indicator #3521 Month timeframe combining months #3510 initialSettings from settings adapter does not work #3479 Add Indexed to 100 mode for price scale #3391 RTL #3335 Add warning about incorrect usage disable_resolution_rebuild and has_empty_bars #3329 Unable to load DOME and Bottom Widget when open_account_manager disabled #3312 Randomly clickable area on chart that redirects user to tradingview.com #3299 Apply to all #3298 Save container element while charting library's life #3297 Gap appearing in chart layout #3246 User's colors not working when theme is enabled #3232 Chart is outside of visible range when in auto scale and load study template or load chart #3229 Please make getVisibleRange return the range in UTC #3173 Remove TradingView.onready from API #3162 Add API to export data from the chart #3152 Market status is not updated properly #3122 Placeholders disappear in "Compare or Add Symbol" popup when the cursor is set into the fields #2966 getVisibleRange to return 0, any way of getting the last bar in active chart ? #2757 "onListAdded" event is not fired when user click on "Save Watchlist As" #2654 Error report : Parabolic SAR #2205 TERMINAL: make a flag to disable support of stop orders #2181 Add Change % in the OHLC label Charting Library #2120 Request more bars for indicators #1362 Drawing tool does not work on Samsung Edge and Note 5 #984
This commit is contained in:
66
datafeeds/udf/src/history-provider.js
Normal file
66
datafeeds/udf/src/history-provider.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import { getErrorMessage, } from './helpers';
|
||||
var HistoryProvider = /** @class */ (function () {
|
||||
function HistoryProvider(datafeedUrl, requester) {
|
||||
this._datafeedUrl = datafeedUrl;
|
||||
this._requester = requester;
|
||||
}
|
||||
HistoryProvider.prototype.getBars = function (symbolInfo, resolution, rangeStartDate, rangeEndDate) {
|
||||
var _this = this;
|
||||
var requestParams = {
|
||||
symbol: symbolInfo.ticker || '',
|
||||
resolution: resolution,
|
||||
from: rangeStartDate,
|
||||
to: rangeEndDate,
|
||||
};
|
||||
return new Promise(function (resolve, reject) {
|
||||
_this._requester.sendRequest(_this._datafeedUrl, 'history', requestParams)
|
||||
.then(function (response) {
|
||||
if (response.s !== 'ok' && response.s !== 'no_data') {
|
||||
reject(response.errmsg);
|
||||
return;
|
||||
}
|
||||
var bars = [];
|
||||
var meta = {
|
||||
noData: false,
|
||||
};
|
||||
if (response.s === 'no_data') {
|
||||
meta.noData = true;
|
||||
meta.nextTime = response.nextTime;
|
||||
}
|
||||
else {
|
||||
var volumePresent = response.v !== undefined;
|
||||
var ohlPresent = response.o !== undefined;
|
||||
for (var i = 0; i < response.t.length; ++i) {
|
||||
var barValue = {
|
||||
time: response.t[i] * 1000,
|
||||
close: Number(response.c[i]),
|
||||
open: Number(response.c[i]),
|
||||
high: Number(response.c[i]),
|
||||
low: Number(response.c[i]),
|
||||
};
|
||||
if (ohlPresent) {
|
||||
barValue.open = Number(response.o[i]);
|
||||
barValue.high = Number(response.h[i]);
|
||||
barValue.low = Number(response.l[i]);
|
||||
}
|
||||
if (volumePresent) {
|
||||
barValue.volume = Number(response.v[i]);
|
||||
}
|
||||
bars.push(barValue);
|
||||
}
|
||||
}
|
||||
resolve({
|
||||
bars: bars,
|
||||
meta: meta,
|
||||
});
|
||||
})
|
||||
.catch(function (reason) {
|
||||
var reasonString = getErrorMessage(reason);
|
||||
console.warn("HistoryProvider: getBars() failed, error=" + reasonString);
|
||||
reject(reasonString);
|
||||
});
|
||||
});
|
||||
};
|
||||
return HistoryProvider;
|
||||
}());
|
||||
export { HistoryProvider };
|
||||
Reference in New Issue
Block a user