commit 2020-02-14 16:01:23.101677
Watermark settings are not saved to LocalStorage #4681
This commit is contained in:
@@ -326,13 +326,13 @@ c=Object(o.ensureNotNull)(t.source.priceScale()).coordinateToPrice(e.localY,Obje
|
||||
o=this.pointToScreenPoint(this._points[2])[0],this._dist=r(i,n,o).distance||0)},n.prototype._preparePoint=function(e,t){var i=this._preparePointInternal(e,t,!1);return t&&t.shift()&&this._points[0].index===this._points[1].index&&this._fixVerticalDiameterPoints(this._points[1],this._points[0],i),i},n.prototype._preparePointInternal=function(e,t,i){var n,r,a,l,c,u,h,d,p,_,f=Object.assign({},e);if(t&&t.shift()){if(n=this.points().length,!this._fakePointAdded&&3===n&&!i)return f;(this._fakePointAdded||2===n||i)&&(this._snapPoint45Degree(e,this._points[0]),this._fakePointAdded?this._points[1]=e:i||(this._fakePointAdded=!0,s.prototype._addPointIntenal.call(this,e)),r=this.pointToScreenPoint(this._points[0])[0],l=(a=this.pointToScreenPoint(this._points[1])[0]).x-r.x,c=a.y-r.y,u=Math.sqrt(l*l+c*c)/2,h=a.subtract(r),d=r.add(a).scaled(.5),p=(p=new o(-h.y,h.x)).normalized(),_=d.add(p.scaled(u)),f=this.screenPointToPoint(_),(TradingView.isNaN(f.price)||TradingView.isNaN(f.index))&&(f=this.screenPointToPoint(d)))}else this._fakePointAdded&&(this._points.splice(1,1),this._fakePointAdded=!1);return f},n.prototype._fixVerticalDiameterPoints=function(e,t,i){var n=this.pointToScreenPoint(e)[0],o=this.pointToScreenPoint(t)[0],r=this._model.timeScale(),s=r.indexToCoordinate(e.index),a=r.indexToCoordinate(i.index),l=2*Math.abs(s-a);l*=t.price>e.price?1:-1,e.price=this.screenPointToPoint({x:n.x,y:o.y+l}).price},n.prototype.addPoint=function(e,t,i){var n=s.prototype.addPoint.call(this,e,t,i);return n&&(this._fakePointAdded=!1),n},n.prototype.setPoint=function(e,t,i){var n,s,a,l,c=Object.assign({},t),u=this.pointToScreenPoint(this._points[0])[0],h=this.pointToScreenPoint(this._points[1])[0],d=this.pointToScreenPoint(this._points[2])[0];switch(e){case 0:if(i&&i.shift()){this._snapPoint45Degree(c,this._points[1]),this._points[0]=c,this._points[2]=this._preparePointInternal(this._points[2],i,!0),this._points[0].index===this._points[1].index&&this._fixVerticalDiameterPoints(this._points[0],this._points[1],this._points[2]);break}u=this.pointToScreenPoint(c)[0],n=h.subtract(u),s=u.add(h).scaled(.5),a=(a=new o(-n.y,n.x)).normalized(),d=s.add(a.scaled(this._dist)),d=this.screenPointToPoint(d),this._points[0]=c,this._points[2]=d;break;case 1:if(i&&i.shift()){this._snapPoint45Degree(c,this._points[0]),this._points[1]=c,this._points[2]=this._preparePointInternal(this._points[2],i,!0),this._points[0].index===this._points[1].index&&this._fixVerticalDiameterPoints(this._points[1],this._points[0],this._points[2]);break}n=(h=this.pointToScreenPoint(c)[0]).subtract(u),s=u.add(h).scaled(.5),a=(a=new o(-n.y,n.x)).normalized(),d=s.add(a.scaled(this._dist)),d=this.screenPointToPoint(d),this._points[1]=c,this._points[2]=d;break;case 2:case 3:c=this.pointToScreenPoint(c)[0],l=r(u,h,c).distance,n=h.subtract(u),s=u.add(h).scaled(.5),a=(a=new o(-n.y,n.x)).normalized(),d=s.add(a.scaled(l)),d=this.screenPointToPoint(d),this._points[2]=d}this.normalizePoints()},n.prototype.pointsCount=function(){return 3},n.prototype.title=function(){return"Ellipse"},
|
||||
n.prototype.name=function(){return"Ellipse"},n.version=2,n.prototype.migrateVersion=function(e,t,i){var n,o,r;1===e&&2===this._points.length&&(n=this._points[0].price,o=.5*(this._points[0].price+this._points[1].price),this._points[0]={price:o,index:this._points[0].index},this._points[1]={price:o,index:this._points[1].index},this._points.push({price:n,index:this._points[0].index})),1===e&&2===this._timePoint.length&&(n=this._timePoint[0].price,o=.5*(this._timePoint[0].price+this._timePoint[1].price),this._timePoint[0].price=o,this._timePoint[1].price=o,r={price:n,offset:this._timePoint[0].offset,time_t:this._timePoint[0].time_t},this._timePoint.push(r))},n.prototype.getInputsPropertyPage=function(){return null},n.prototype.getStylesPropertyPage=function(){return l.LineToolEllipseStylesPropertyPage},t.LineToolEllipse=n},V3Oj:function(e,t,i){"use strict";function n(e,t){this._constructor="LineToolText";var n=t||new l("linetooltext");n.hasChild("text")||n.addChild("text",new a(window.t("Text"))),n.addExclusion("text"),r.call(this,e,n),this._timeScale=e.timeScale(),this._barSpacing=e.timeScale().barSpacing(),i.e("lt-pane-views").then(function(e){var t=i("mr3a").TextPaneView;this._setPaneViews([new t(this,this._model)])}.bind(this).bind(null,i)).catch(i.oe)}function o(e,t){var i=t||new l("linetooltextabsolute");i.locked.value()||i.locked.setValue(!0),n.call(this,e,i)}var r=i("Ss5c").LineDataSource,s=i("fgLi").DataSource,a=i("tc+8"),l=i("Ocx9").DefaultProperty,c=i("hayr").propertyPages;inherit(n,r),n.MIN_WIDTH=100,n.prototype.setPoint=function(e,t){var i,o,r=this.properties();if(0===e&&r.wordWrapWidth&&r.wordWrapWidth.value()){if(i=r.locked&&r.locked.value()?this.fixedPoints()[0].x:this._timeScale.indexToCoordinate(this.points()[0].index),o=this._timeScale.indexToCoordinate(t.index)-i-~~(r.fontsize.value()/6),!isFinite(o))return;r.wordWrapWidth.setValue(Math.max(n.MIN_WIDTH,o))}},n.prototype.pointsCount=function(){return 1},n.prototype.title=function(){return window.t("Text",{context:"tool"})},n.prototype.name=function(){return"Text"},n.prototype.setPriceScale=function(e){s.prototype.setPriceScale.call(this,e),e&&e.priceRange()&&(this._priceDencity=e.height()/e.priceRange().length(),this._isPriceDencityLog=e.isLog())},n.prototype.restoreSize=function(){this._barSpacing=this._model.timeScale().barSpacing(),this._priceDencity=this.priceScale().height()/this.priceScale().priceRange().length(),this.updateAllViews(),this._model.updateSource(this)},n.prototype.applyTemplate=function(e){delete e.locked,delete e.text,r.prototype.applyTemplate.call(this,e)},inherit(o,n),o.prototype.title=function(){return window.t("Anchored Text")},o.prototype.name=function(){return"Anchored Text"},n.prototype.state=function(e){var t=r.prototype.state.call(this,e);return e&&(t.state.fixedSize=!1),t},n.prototype.getInputsPropertyPage=function(){return null},n.prototype.getStylesPropertyPage=function(){return c.LineToolTextStylesPropertyPage},t.LineToolText=n,t.LineToolTextAbsolute=o},VNzU:function(e,t,i){"use strict";function n(e){return"s"===e}
|
||||
function o(e){return!n(e)}var r,s,a,l;i.r(t),r=i("mrSG"),i("Dq3s"),i.d(t,"layouts",function(){return l}),i.d(t,"isSingleLayout",function(){return n}),i.d(t,"isMultipleLayout",function(){return o}),s={s:{title:"1 chart",count:1,sizer:function(e,t){if(0!==t)throw new RangeError("invalid index");return e}}},a={},l=r.__assign({},s,a)},VVxS:function(e,t,i){"use strict";var n,o=function(){try{this.isAvailable=!0,this.localStorage=window.localStorage,this.localStorage.setItem("tvlocalstorage.available","true")}catch(e){delete this.isAvailable,delete this.localStorage}this._updateLength()};o.prototype.length=0,o.prototype.isAvailable=!1,o.prototype.localStorage={"tvlocalstorage.available":"false"},o.prototype._updateLength=function(){var e,t;if(this.isAvailable)this.length=this.localStorage.length;else{for(t in e=0,this.localStorage)this.localStorage.hasOwnProperty(t)&&e++;this.length=e}},o.prototype.key=function(e){return this.isAvailable?this.localStorage.key(e):Object.keys(this.localStorage)[e]},o.prototype.getItem=function(e){return this.isAvailable?this.localStorage.getItem(e):this.localStorage[e]},o.prototype.setItem=function(e,t){this.isAvailable?this.localStorage.setItem(e,t):this.localStorage[e]=t,this._updateLength()},o.prototype.removeItem=function(e){this.isAvailable?this.localStorage.removeItem(e):delete this.localStorage[e],this._updateLength()},o.prototype.clear=function(){this.isAvailable?this.localStorage.clear():this.localStorage={},this._updateLength()},(n=function(e){this.storage=e}).prototype.getItem=function(e){return Promise.resolve(this.storage.getItem(e))},n.prototype.setItem=function(e,t){return Promise.resolve(this.storage.setItem(e,t))},window.TVLocalStorage=new o,window.TVLocalStorageAsync=new n(window.TVLocalStorage),e.exports={TVLocalStorage:window.TVLocalStorage,TVLocalStorageAsync:window.TVLocalStorageAsync}},VdBB:function(e,t,i){"use strict";i.r(t),i.d(t,"HitTestResult",function(){return n});var n=function(){function e(e,t,i){this._result=e,this._data=t,this._eraseMarker=i}return e.prototype.result=function(){return this._result},e.prototype.data=function(){return this._data},e.prototype.eraseMarker=function(){return this._eraseMarker},e.MOVEPOINT_BACKGROUND=1,e.REGULAR=2,e.MOVEPOINT=3,e.CHANGEPOINT=4,e.CUSTOM=5,e.CUSTOM_MOVE=6,e}()},Vdly:function(e,t,i){"use strict";(function(e,t){var n,o,r,s,a,l;i("qFKp"),n=i("dTSQ").regExpEscape,o=i("FBuY").TVXWindowEvents,r=i("VVxS").TVLocalStorage,s=i("aIyQ"),a=["s.tradingview.com","betacdn.tradingview.com"],l=window.TVSettings=function(){function t(e){return w+"."+e}function i(e,t){var i;return i=P[e],window.is_authenticated&&!k||null!=i||(i=P[e]),null==i?t:i}function c(e,t,i){i=i||{};var n=""+t;return P[e]!==n&&(P[e]=n,d(e)),i.forceFlush&&!T&&(T=setTimeout(function(){T=void 0,p()},b)),l}function u(e,t){return t=t||{},null!=P[e]&&(delete P[e],d(e)),t.forceFlush&&p(),l}function h(){C=void 0,x.length&&p()}function d(e){if(M)null==P[e]?M.removeValue(e):M.setValue(e,P[e]);else if(!window.is_authenticated||k)try{
|
||||
null==P[e]?r.removeItem(t(e)):r.setItem(t(e),P[e])}catch(e){}else x.push(e),C||(C=setTimeout(h,S));o.emit("settings",JSON.stringify({key:e,value:P[e]}))}function p(t){e.enabled("widget")||window.is_authenticated&&!k&&x.length}function _(){return Object.keys(P)}function f(e){for(var t=0;t<I.length;++t)if(I[t].exec(e))return!0;return!1}function m(e){var t,i,n,o;for(P={},t=0===Object.keys(e).length,i=w+".",n=r.length;n--;)(o=r.key(n))&&o.substring(0,i.length)===i&&(t&&c(o.substring(i.length),r.getItem(o)),r.removeItem(o));Object.keys(e).forEach(function(t){P[t]=e[t]+""})}var y,g,v,S,b,w,P,x,C,T,I,L,A=!1,k=e.enabled("cqg_terminal"),M=null;try{A=!TradingView.onWidget()&&parent&&parent!==window&&!!parent.IS_DEMO_PAGE}catch(e){}return A?(y={"widgetbar.layout-settings":{widgets:{},settings:{minimized:!0}},notShowMainWizard:!0},{loaded:!1,loadedModel:!1,getValue:g=function(e,t,i){var n=y[e];return null==n?t:n},getJSON:g,getBool:g,getFloat:g,getInt:g,setValue:v=function(){},setJSON:v,remove:v,keys:function(){return Object.keys(y)},keysMask:function(){return[]},sync:v,onSync:{subscribe:function(){}}}):(S=12e4,b=10,"local"===window.environment&&(S=5e3),w=TradingView.onWidget()?"tradingview-widget":"tradingview",P={},x=[],I=[/^widgetbar\.widget\.watchlist.+/,/.+quicks$/,/^widgetbar\.layout-settings$/,/^ChartSideToolbarWidget\.visible$/,/^onwidget\.watchlist$/,/^domepanel.visible$/,/^orderpanel.visible$/,/^chart\.favoriteDrawings$/,/^chart\.favoriteDrawingsPosition$/,/^loadChartDialog.favorites$/,/^ChartFavoriteDrawingToolbarWidget\.visible/,/^trading\.chart\.proterty$/,/^trading_floating_toolbar\.position$/,/^trading\.orderWidgetMode\./],o.on("settings",function(e){var t=JSON.parse(e);null==t.value?delete P[t.key]:P[t.key]=t.value}),L=new s,document.addEventListener("visibilitychange",function(){"hidden"!==document.visibiltyState&&!0!==document.hidden||p()}),window.addEventListener("unload",function(){p()}),{loaded:!1,loadedModel:!1,getValue:i,getJSON:function(e,t){var n=i(e,void 0);if(null==n)return t;try{return JSON.parse(n)}catch(i){return u(e),t}},getBool:function(e,t){var n=i(e);return null==n?t:!(!n||"false"===n||0==+n)},getFloat:function(e,t,n){var o,r=i(e,void 0);if(null==r)return t;if(o=parseFloat(r),!isFinite(o))throw new TypeError('"'+r+'" is not float (key: "'+e+'")');return o},getInt:function(e,t,n){var o,r=i(e,void 0);if(null==r)return t;if(o=parseInt(r,10),!isFinite(o))throw new TypeError('"'+r+'" is not int (key: "'+e+'")');return o},setValue:c,setJSON:function(e,t,i){return c(e,JSON.stringify(t),i),l},remove:u,keys:_,keysMask:function(e,t){var i,o=_(),r=[];for(e=new RegExp("^"+n(e).replace(/\\\*\\\*/gi,".+").replace(/\\\*/gi,"[^.]+")+"$","gi"),i=o.length-1;i>=0;i--)e.test(o[i])&&r.push(o[i]),e.lastIndex=0;return r},sync:function(t){M?m(M.initialSettings||{}):window.is_authenticated&&!k?m(t||{}):(function(){var e,t,i,n;if(TradingView.onWidget()&&a.includes(window.location.host))for(e="tradingview.",t=r.length;t--;)0===(i=r.key(t)).indexOf(e)&&(n=i.replace(e,w+"."),r.setItem(n,r.getItem(i)),r.removeItem(i))}(),
|
||||
function(){var t,i,n,o,s;for(P={},t=w+".",i=!e.enabled("save_chart_properties_to_local_storage"),n=r.length;n--;)(o=r.key(n))&&o.substring(0,t.length)===t&&(s=o.substring(t.length),i&&!f(s)||(P[s]=r.getItem(o)))}()),L.fire()},onSync:L,setSettingsAdapter:function(e){M=e}})}(),t&&t.exports&&(t.exports=l)}).call(this,i("Kxc7"),i("YuTi")(e))},VfPj:function(e,t,i){"use strict";function n(e){this._items=e.items,this._y=e.y,this._h=e.h,this._w=e.w}n.prototype.draw=function(e){},n.prototype.drawBackground=function(e){var t,i,n;for(e.save(),e.translate(-.5,-.5),t=0;t<this._items.length;++t)null!=(i=this._items[t]).color&&(e.fillStyle=i.color,n=t===this._items.length-1?this._w:this._items[t+1].x-i.x,e.fillRect(i.x,this._y,n,this._h));e.restore()},n.prototype.hitTest=function(e){return null},t.PaneRendererBackground=TradingView.PaneRendererBackground=n},VgjZ:function(e,t,i){"use strict";var n,o;i.r(t),i.d(t,"PriceAxisRendererOptionsProvider",function(){return o}),n=i("XlJ7"),o=function(){function e(e){this._rendererOptions={borderSize:1,tickLength:4,offsetSize:1,fontSize:NaN,font:"",color:"",paddingBottom:0,paddingInner:0,paddingOuter:0,paddingTop:0,baselineOffset:0},this._chartModel=e}return e.prototype.options=function(){var e=this._rendererOptions,t=this._fontSize();return e.fontSize!==t&&(e.fontSize=t,e.font=Object(n.makeFont)(t,"'Trebuchet MS', Arial, sans-serif",""),e.paddingTop=Math.floor(t/3.5),e.paddingBottom=e.paddingTop,e.paddingInner=Math.max(Math.ceil(t/2-e.tickLength/2),0),e.paddingOuter=Math.ceil(t/2+e.tickLength/2),e.baselineOffset=Math.round(t/5)),e.color=this._textColor(),this._rendererOptions},e.prototype._textColor=function(){return this._chartModel.properties().scalesProperties.textColor.value()},e.prototype._fontSize=function(){return this._chartModel.properties().scalesProperties.fontSize.value()},e}()},VuJ3:function(e,t,i){"use strict";function n(e){this.bars=e.bars,this.barSpacing=e.barSpacing,this.barWidth=o.optimalBarWidth(e.barSpacing),this.barLineWidth=e.thinBars?1:Math.max(1,Math.round(this.barWidth)),this.dontDrawOpen=e.dontDrawOpen,this._thinBars=e.thinBars}var o=i("Zp/P"),r=i("VdBB").HitTestResult;n.prototype.draw=function(e){var t,i,n,o,r,s;for(e.save(),e.translate(.5,.5),i=this.barLineWidth,n=this._thinBars?1:Math.round(this.barWidth),o=this._thinBars?1:n/2,r=0;r<this.bars.length;++r)t!==(s=this.bars[r]).color&&(e.fillStyle=s.color,t=s.color),e.fillRect(Math.round(s.time-i/2),Math.round(s.high-o),Math.round(i),Math.round(s.low-s.high+n)),i<this.barSpacing-1&&(this.dontDrawOpen||e.fillRect(Math.round(s.time-1.5*this.barWidth),Math.floor(s.open-o),Math.round(1.5*this.barWidth),n),e.fillRect(Math.round(s.time),Math.floor(s.close-o),Math.round(1.5*this.barWidth),n));e.restore()},n.prototype.hitTest=function(e){var t,i,n,s,a,l,c=this.bars,u=.5*this.barSpacing;if(0===c.length)return null;if(e.x<c[0].time-u)return null;if(e.x>c[c.length-1].time+u)return null;for(t=null,i=0;i<c.length;++i)if(n=c[i],e.x<=n.time+u){t=n;break}return t?(s=o.selectionTolerance(this.barLineWidth),a=Math.min(t.high,t.low),
|
||||
l=Math.max(t.high,t.low),a-s<=e.y&&e.y<=l+s?new r(r.REGULAR):null):null},t.PaneRendererBars=TradingView.PaneRendererBars=n},W5mg:function(e,t,i){"use strict";function n(e){return!e.groupId&&"time"!==e.type&&!e.isHidden&&!o.includes(e.id)}i.d(t,"a",function(){return n});var o=["first_visible_bar_time","last_visible_bar_time"]},WIS0:function(e,t,i){"use strict";function n(e,t){return e.ticker+"_"+t}function o(e){return new Date(e).toISOString()}var r,s,a,l,c,u;i.r(t),i.d(t,"DatafeedRequestsCachedProcessor",function(){return u}),r=i("LxhU"),s=i("Y7w9"),a=i("ocLq"),l=i("Kxc7"),i("HbRj"),c=function(){function e(e,t,i,n){this._cache={bars:[]},this._nextSubscriptionId=0,this._pendingSubscribers=[],this._subscribers=[],this._requesting=!1,this._leftDate=null,this._gaps=[],this._needPurgeCache=!1,this._realtimeOn=!1,this._endOfData=!1,this._resetCacheTimeout=null,this._errorMessage=null,this._destroyed=!1,this._emptyResponsesCount=0,this._datafeed=e,this._symbolInfo=t,this._resolution=i,this._dwmAligner=n}return e.prototype.destroy=function(){0!==this._subscribers.length&&console.warn("Destroying with not-empty state"),this._clearResetCacheTimeout(),this._unsubscribeRealtime(),this._purgeCache(),delete this._datafeed,this._destroyed=!0},e.prototype.addSubscription=function(e,t,i){var n=this,o=this._getNextSubscriptionId(),r=Math.floor(e.from/1e3),s=Math.floor(e.to/1e3);return this._pendingSubscribers.push({key:o,range:{from:r,to:s},onHistoryCallback:t,onErrorCallback:i}),this._clearResetCacheTimeout(),setTimeout(function(){n._destroyed||n._processPendingSubscribers()},0),o},e.prototype.removeSubscription=function(e){var t,i=this,n=this._pendingSubscribers.find(function(t){return t.key===e});if(n)this._pendingSubscribers.splice(this._pendingSubscribers.indexOf(n),1);else{if(t=this._subscribers.find(function(t){return t.key===e}))return this._subscribers.splice(this._subscribers.indexOf(t),1),void(this._subscribers.length||(this._symbolInfo.expired||this._symbolInfo.expiration_date?this._unsubscribeRealtime():this._resetCacheTimeout=setTimeout(function(){i._purgeCacheDelayed(),i._unsubscribeRealtime()})));console.warn("Unknown subscription symbol={0}, resolution={1}, key={2}".format(this._symbolInfo.name,this._resolution,e))}},e.prototype._purgeCacheDelayed=function(){this._logMessage("Reset cache"),this._needPurgeCache=!0,this._clearResetCacheTimeout()},e.prototype._logMessage=function(e,t){(l.enabled("charting_library_debug_mode")||t)&&console.log("FEED [{0}|{1}]: {2}".format(this._symbolInfo.name,this._resolution,e))},e.prototype._clearResetCacheTimeout=function(){null!==this._resetCacheTimeout&&(clearTimeout(this._resetCacheTimeout),this._resetCacheTimeout=null)},e.prototype._purgeCache=function(){this._cache={bars:[]},this._gaps=[],this._errorMessage=null,this._needPurgeCache=!1,this._leftDate=null,this._endOfData=!1},e.prototype._processPendingSubscribers=function(){var e,t,i,n,s,a=this,l=this._pendingSubscribers;if(l.length)if(this._requesting)this._logMessage("Processing is skipped due active request");else{
|
||||
if(this._logMessage("Processing pending subscribers, count="+l.length),this._needPurgeCache&&this._purgeCache(),this._errorMessage)return e=this._errorMessage,this._logMessage("Return error: "+e),this._pendingSubscribers=[],void l.forEach(function(t){t.onErrorCallback(e)});t=l.reduce(function(e,t){return Math.min(t.range.from,e)},1/0),this._logMessage('Leftmost requested "from" is '+o(1e3*t)),this._leftDate&&!(t<this._leftDate)||(i=(new r.Interval(this._resolution).inMilliseconds(Date.now())||0)/1e3,s=!(n=!this._leftDate)&&!!this._cache.bars.length&&this._cache.bars[0].time/1e3-t<i,!n&&s||this._endOfData)?(this._pendingSubscribers=[],l.forEach(function(e){var t=a._moveSubscriberToRealtime(e);a._returnHistoryDataToSubscriber(e,t)}),this._subscribeRealtimeIfNeeded()):this._ensureRequestedTo(t)}},e.prototype._moveSubscriberToRealtime=function(e){var t={key:e.key,onHistoryCallback:e.onHistoryCallback,barset:null};return this._subscribers.push(t),t},e.prototype._subscribeRealtimeIfNeeded=function(){!this._subscribers.length||this._realtimeOn||this._symbolInfo.expired||this._symbolInfo.expiration_date||this._subscribeRealtime()},e.prototype._subscribeRealtime=function(){var e,t,i=this;this._symbolInfo.expired||this._realtimeOn||(e=function(e){i._dwmAligner&&(e.time=i._dwmAligner.tradingDayToSessionStart(e.time)),i._putToCacheNewBar(e),i._subscribers.forEach(function(t){var i=t.barset;if(null===i)throw new Error("subscirber.barset is null");i.add(e),t.onHistoryCallback(i)})},t=function(){i._unsubscribeRealtime();var e=i._leftDate;i._purgeCache(),e&&i._ensureRequestedTo(e)},this._realtimeOn=!0,this._datafeed.subscribeBars(this._symbolInfo,this._resolution,e,n(this._symbolInfo,this._resolution),t),this._logMessage("Subscribed to realtime"))},e.prototype._unsubscribeRealtime=function(){!this._symbolInfo.expired&&this._realtimeOn&&(this._datafeed.unsubscribeBars(n(this._symbolInfo,this._resolution)),this._logMessage("Unsubscribed from realtime"),this._realtimeOn=!1)},e.prototype._returnHistoryDataToSubscriber=function(e,t){var i,n,r=e.range,s=this._createBarset(r.from);s.count()>0?this._logMessage("Bars to return for request {0}: total {1} bars in [{2} ... {3}] ".format(e.key,s.count(),o(s.bars[0].time),o(s.bars[s.count()-1].time))):this._logMessage("Request {0}. Nothing to return.".format(e.key)),t.barset=s,(i=this._inGapNextTime(r.from))?(this._logMessage("Request {0} is in gap, nextTime = {1}".format(e.key,o(1e3*i))),s.nextTime=i):0===s.count()&&(n=this._cache.bars.length&&this._cache.bars[this._cache.bars.length-1].time/1e3)&&r.from>n&&(this._logMessage("Request {0} is in gap, nextTime = {1}".format(e.key,o(1e3*n))),s.nextTime=n||void 0),this._endOfData&&null!==this._leftDate&&e.range.from<=this._leftDate&&(s.endOfData=!0),e.onHistoryCallback(s)},e.prototype._createBarset=function(e){var t=Object(s.lowerbound)(this._cache.bars,1e3*e,function(e,t){return e.time<t});return new a.BarSet(this._symbolInfo,this._cache.bars.slice(t))},e.prototype._ensureRequestedTo=function(t){var i,n,r,s=this
|
||||
;this._leftDate&&this._leftDate<t?this._processPendingSubscribers():(i=!this._leftDate,this._requesting=!0,n=t,r=this._leftDate?this._leftDate-1:this._symbolInfo.expiration_date||Math.floor(e._now()/1e3),this._leftDate=t,this._logMessage("Requesting data: [{0} ... {1}] ".format(o(1e3*n),o(1e3*r))),this._datafeed.getBars(this._symbolInfo,this._resolution,n,r,function(e,t){s._destroyed||(s._requesting=!1,s._processBars(e,t))},function(e){s._requesting=!1,s._errorMessage=e||null,s._processPendingSubscribers()},i))},e.prototype._processBars=function(e,t){this._checkBars(e),this._alignBarsTime(e),e.length>0?(this._emptyResponsesCount=0,this._processFullBarset(e,t)):(this._emptyResponsesCount+=1,this._processEmptyBarset(t)),this._processPendingSubscribers()},e.prototype._processEmptyBarset=function(t){this._logMessage("Receiving bars: barset is empty"),t&&t.nextTime?(this._logMessage("Next time received: `{0}`".format(o(1e3*t.nextTime))),this._addGap(t.nextTime),this._leftDate=Math.min(this._leftDate||e._now()/1e3,t.nextTime+1)):t&&t.noData?(this._logMessage("EOD received"),this._setEndOfData()):this._logMessage("nextTime or noData should present in metainfo when empty barset is returned"),50===this._emptyResponsesCount&&(this._logMessage("EOD detected due 50 empty responses in a row"),this._setEndOfData())},e.prototype._setEndOfData=function(){this._endOfData=!0,this._cache.bars.length&&(this._leftDate=this._cache.bars[0].time/1e3)},e.prototype._processFullBarset=function(e,t){var i=e[0].time,n=e[e.length-1].time;this._logMessage("Receiving bars: total {0} bars in [{1} ... {2}] ".format(e.length,o(i),o(n))),null!==this._leftDate&&i<1e3*this._leftDate&&this._logMessage("Returned more data than needed"),this._putToCache(e)?null!==this._leftDate&&this._cache.bars.length&&this._leftDate>this._cache.bars[0].time/1e3&&(this._leftDate=this._cache.bars[0].time/1e3):this._logMessage("Incremental update failed. Starting full update. Returned data should be in the requested range.",!0),t&&t.nextTime?console.warn("nextTime should be set when there is no data in the requested period only"):t&&t.noData&&console.warn("noData should be set when there is no data in the requested period and earlier only")},e.prototype._addGap=function(t){var i,n=this._gaps.find(function(e){return e.from===t});n||(i=(this._cache.bars.length?this._cache.bars[0].time:e._now())/1e3,this._gaps.push({from:t,to:i}))},e.prototype._inGapNextTime=function(e){var t=this._gaps.find(function(t){return t.from<e&&t.to>e});return t?t.from:null},e.prototype._getNextSubscriptionId=function(){return this._nextSubscriptionId++},e.prototype._checkBars=function(e,t){var i,n;if(void 0===t&&(t=!1),l.enabled("charting_library_debug_mode"))for(i=1;i<e.length;i++)e[i].time<=e[i-1].time&&(n="Wrong bars time: time {0} of bar {1} should be more than time {2} of bar {3}".format(e[i].time,i,e[i-1].time,i-1),t&&this._dwmAligner&&(n+="\nCheck that you provide DWM bars without time part, i.e. 00:00 GMT"),console.error(n))},e.prototype._putToCache=function(e){if(0===e.length)return!0
|
||||
;if(this._cache.bars.length===e.length&&this._cache.bars[0].time===e[0].time&&this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time)return this._logMessage("Time range of received data is the same as cached one. Skip the update."),!0;if(0!==this._cache.bars.length&&e[e.length-1].time===this._cache.bars[0].time&&this._cache.bars.splice(0,1),0!==this._cache.bars.length&&e[e.length-1].time>=this._cache.bars[0].time){var t=this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time;if(this._cache.bars=[],!t)return this._leftDate=null,!1;this._logMessage("Received history up to now instead of incremental update. Return exactly what is requested.")}return this._cache.bars=e.concat(this._cache.bars),this._checkBars(this._cache.bars,!0),!0},e.prototype._putToCacheNewBar=function(e){var t=this._cache.bars.length,i=e.time,n=0===t?NaN:this._cache.bars[t-1].time,r=0===t||n<i;r?this._cache.bars.push(e):n===i?this._cache.bars[t-1]=e:console.error("putToCacheNewBar: time violation, previous bar time: "+o(n)+" should be less or equal to new time: "+o(i))},e.prototype._alignBarsTime=function(e){if(this._dwmAligner)for(var t=0;t<e.length;t++)e[t].time=this._dwmAligner.tradingDayToSessionStart(e[t].time)},e._now=function(){return Date.now()+6e4},e}(),u=function(){function e(e,t){this._threads={},this._datafeed=e,this._dwmAlignerCreator=t}return e.prototype.destroy=function(){this._forEachThread(function(e,t){return t.destroy()}),this._threads={},delete this._datafeed},e.prototype.purgeCache=function(){this._forEachThread(function(e,t){return t.destroy()}),this._threads={}},e.prototype.subscribe=function(e,t,i,o,r){var s=n(e,t);return this._threads[s]||(this._threads[s]=this._createThread(e,t)),s+'"'+this._threads[s].addSubscription(i,o,r)},e.prototype.unsubscribe=function(e){var t,i,n=e.split('"');2===n.length?(t=n[0],i=parseInt(n[1]),this._threads.hasOwnProperty(t)?this._threads[t].removeSubscription(i):console.warn("Data thread doesnt exist: "+e)):console.warn("Wrong guid format")},e.prototype._createThread=function(e,t){return new c(this._datafeed,e,t,this._dwmAlignerCreator(t,e.timezone,e.session))},e.prototype._forEachThread=function(e){var t=this;Object.keys(this._threads).forEach(function(i){return e(i,t._threads[i])})},e}()},WPQD:function(e,t,i){"use strict";function n(){var e,t,i;this._registeredSources={},this._sourcesToRow={},this._rowsToSources={},this._currentSymbol="",this._actualCapacity=0,this._actualWidth=0,this._canvas=document.createElement("canvas"),this._cache=this._canvas.getContext("2d"),this._currentWidth=400,this._canvas.width=this._currentWidth,this._canvas.height=1,this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.zIndex="1000",this._canvas.style.left="0",this._ctx=this._canvas.getContext("2d"),this._ctx.font=h.fontSize+"px"+h.font,t=h.fontSize+(e=h.lineSpacing),i=3,this._padding=8,this._rowHeight=t*i-e+2*this._padding+2}function o(e,t){this._constructor="LineToolTrendLine";var o=t||new a("linetooltrendline");s.call(this,e,o),
|
||||
e._trendLineStatsCache||(e._trendLineStatsCache=new n),i.e("lt-pane-views").then(function(e){var t=i("ocVb").TrendLinePaneView;this._setPaneViews([new t(this,this._model)])}.bind(this).bind(null,i)).catch(i.oe)}var r=i("aO4+").Point,s=i("Ss5c").LineDataSource,a=i("Ocx9").DefaultProperty,l=i("hayr").propertyPages,c=i("uOxu").getLogger("Chart.LineToolTrendLine"),u=i("5/lF").TrendLineStatsRenderer,h=i("8xAY").LabelSettings;n.prototype.canvas=function(){return this._canvas},n.prototype.topByRow=function(e){return e*this._rowHeight},n.prototype.rowHeight=function(e){return this._rowHeight},n.prototype.rowWidth=function(e){var t=this._rowsToSources[e];return this._sourcesToRow[t].width},n.prototype.currentWidth=function(){return this._currentWidth},n.prototype._findEmptyRow=function(e){for(var t=0;this._rowsToSources[t];)t++;return this._rowsToSources[t]=e,t>=this._actualCapacity&&(this._actualCapacity++,TradingView.resizeCanvas(this._canvas,this._currentWidth,this._rowHeight*this._actualCapacity),this._ctx=this._canvas.getContext("2d"),c.logDebug("TrendLineCache. Expanging cache to "+this._actualCapacity+" items")),t},n.prototype._effectiveState=function(e){var t,i={};return i.p1=Object.assign({},e.points()[0]),i.p2=Object.assign({},e.points()[1]),t=e.properties(),i.showBars=t.showBarsRange.value(),i.showTimeRange=t.showDateTimeRange.value(),i.showDistance=t.showDistance.value(),i.showPriceRange=t.showPriceRange.value(),i.showAngle=t.showAngle.value(),i.color=t.textcolor.value(),i.showAngle&&(i.priceRange=e.priceScale().priceRange().state(),i.barSpacing=e._model.timeScale().barSpacing()),i},n.prototype._effectiveStatesEquals=function(e,t){var i=function(e,t){return!(!e&&!t)&&(!(!e||t)||(!(e||!t)||(e.index!==t.index||e.price!==t.price)))};if(e&&!t)return!1;if(!e&&t)return!1;if(i(e.p1,t.p1))return!1;if(i(e.p2,t.p2))return!1;if(e.color!==t.color)return!1;if(e.showBars!==t.showBars)return!1;if(e.showTimeRange!==t.showTimeRange)return!1;if(e.showDistance!==t.showDistance)return!1;if(e.showPriceRange!==t.showPriceRange)return!1;if(e.showAngle!==t.showAngle)return!1;if(e.showAngle){if(e.priceRange.min!==t.priceRange.min)return!1;if(e.priceRange.max!==t.priceRange.max)return!1;if(e.barSpacing!==t.barSpacing)return!1}return!0},n.prototype.removeSource=function(e){if(this._sourcesToRow[e]){var t=this._sourcesToRow[e].row;this._ctx.save(),this._ctx.clearRect(0,this.topByRow(t),this._currentWidth,this.rowHeight(t)),this._ctx.restore(),delete this._sourcesToRow[e],delete this._rowsToSources[t]}},n.prototype._repaintSource=function(e,t,i){var n;this._ctx.save(),this._ctx.translate(0,this.topByRow(t)+.5),i.points[0]=new r(0,0),i.offsetX=0,i.offsetY=0,delete i.horzAlign,delete i.vertAlign,this._ctx.clearRect(0,0,this._currentWidth,this.rowHeight(t)),n=new u(i,{}).draw(this._ctx),this._sourcesToRow[e].width=n.width,this._ctx.restore()},n.prototype.updateSource=function(e,t){var i,n,o,r,s,a=e.properties().symbol.value()
|
||||
null==P[e]?r.removeItem(t(e)):r.setItem(t(e),P[e])}catch(e){}else x.push(e),C||(C=setTimeout(h,S));o.emit("settings",JSON.stringify({key:e,value:P[e]}))}function p(t){e.enabled("widget")||window.is_authenticated&&!k&&x.length}function _(){return Object.keys(P)}function f(e){for(var t=0;t<I.length;++t)if(I[t].exec(e))return!0;return!1}function m(e){var t,i,n,o;for(P={},t=0===Object.keys(e).length,i=w+".",n=r.length;n--;)(o=r.key(n))&&o.substring(0,i.length)===i&&(t&&c(o.substring(i.length),r.getItem(o)),r.removeItem(o));Object.keys(e).forEach(function(t){P[t]=e[t]+""})}var y,g,v,S,b,w,P,x,C,T,I,L,A=!1,k=e.enabled("cqg_terminal"),M=null;try{A=!TradingView.onWidget()&&parent&&parent!==window&&!!parent.IS_DEMO_PAGE}catch(e){}return A?(y={"widgetbar.layout-settings":{widgets:{},settings:{minimized:!0}},notShowMainWizard:!0},{loaded:!1,loadedModel:!1,getValue:g=function(e,t,i){var n=y[e];return null==n?t:n},getJSON:g,getBool:g,getFloat:g,getInt:g,setValue:v=function(){},setJSON:v,remove:v,keys:function(){return Object.keys(y)},keysMask:function(){return[]},sync:v,onSync:{subscribe:function(){}}}):(S=12e4,b=10,"local"===window.environment&&(S=5e3),w=TradingView.onWidget()?"tradingview-widget":"tradingview",P={},x=[],I=[/^widgetbar\.widget\.watchlist.+/,/.+quicks$/,/^widgetbar\.layout-settings$/,/^ChartSideToolbarWidget\.visible$/,/^onwidget\.watchlist$/,/^domepanel.visible$/,/^orderpanel.visible$/,/^chart\.favoriteDrawings$/,/^chart\.favoriteDrawingsPosition$/,/^loadChartDialog.favorites$/,/^ChartFavoriteDrawingToolbarWidget\.visible/,/^trading\.chart\.proterty$/,/^trading_floating_toolbar\.position$/,/^trading\.orderWidgetMode\./,/^symbolWatermark$/],o.on("settings",function(e){var t=JSON.parse(e);null==t.value?delete P[t.key]:P[t.key]=t.value}),L=new s,document.addEventListener("visibilitychange",function(){"hidden"!==document.visibiltyState&&!0!==document.hidden||p()}),window.addEventListener("unload",function(){p()}),{loaded:!1,loadedModel:!1,getValue:i,getJSON:function(e,t){var n=i(e,void 0);if(null==n)return t;try{return JSON.parse(n)}catch(i){return u(e),t}},getBool:function(e,t){var n=i(e);return null==n?t:!(!n||"false"===n||0==+n)},getFloat:function(e,t,n){var o,r=i(e,void 0);if(null==r)return t;if(o=parseFloat(r),!isFinite(o))throw new TypeError('"'+r+'" is not float (key: "'+e+'")');return o},getInt:function(e,t,n){var o,r=i(e,void 0);if(null==r)return t;if(o=parseInt(r,10),!isFinite(o))throw new TypeError('"'+r+'" is not int (key: "'+e+'")');return o},setValue:c,setJSON:function(e,t,i){return c(e,JSON.stringify(t),i),l},remove:u,keys:_,keysMask:function(e,t){var i,o=_(),r=[];for(e=new RegExp("^"+n(e).replace(/\\\*\\\*/gi,".+").replace(/\\\*/gi,"[^.]+")+"$","gi"),i=o.length-1;i>=0;i--)e.test(o[i])&&r.push(o[i]),e.lastIndex=0;return r},sync:function(t){M?m(M.initialSettings||{}):window.is_authenticated&&!k?m(t||{}):(function(){var e,t,i,n;if(TradingView.onWidget()&&a.includes(window.location.host))for(e="tradingview.",t=r.length;t--;)0===(i=r.key(t)).indexOf(e)&&(n=i.replace(e,w+"."),r.setItem(n,r.getItem(i)),
|
||||
r.removeItem(i))}(),function(){var t,i,n,o,s;for(P={},t=w+".",i=!e.enabled("save_chart_properties_to_local_storage"),n=r.length;n--;)(o=r.key(n))&&o.substring(0,t.length)===t&&(s=o.substring(t.length),i&&!f(s)||(P[s]=r.getItem(o)))}()),L.fire()},onSync:L,setSettingsAdapter:function(e){M=e}})}(),t&&t.exports&&(t.exports=l)}).call(this,i("Kxc7"),i("YuTi")(e))},VfPj:function(e,t,i){"use strict";function n(e){this._items=e.items,this._y=e.y,this._h=e.h,this._w=e.w}n.prototype.draw=function(e){},n.prototype.drawBackground=function(e){var t,i,n;for(e.save(),e.translate(-.5,-.5),t=0;t<this._items.length;++t)null!=(i=this._items[t]).color&&(e.fillStyle=i.color,n=t===this._items.length-1?this._w:this._items[t+1].x-i.x,e.fillRect(i.x,this._y,n,this._h));e.restore()},n.prototype.hitTest=function(e){return null},t.PaneRendererBackground=TradingView.PaneRendererBackground=n},VgjZ:function(e,t,i){"use strict";var n,o;i.r(t),i.d(t,"PriceAxisRendererOptionsProvider",function(){return o}),n=i("XlJ7"),o=function(){function e(e){this._rendererOptions={borderSize:1,tickLength:4,offsetSize:1,fontSize:NaN,font:"",color:"",paddingBottom:0,paddingInner:0,paddingOuter:0,paddingTop:0,baselineOffset:0},this._chartModel=e}return e.prototype.options=function(){var e=this._rendererOptions,t=this._fontSize();return e.fontSize!==t&&(e.fontSize=t,e.font=Object(n.makeFont)(t,"'Trebuchet MS', Arial, sans-serif",""),e.paddingTop=Math.floor(t/3.5),e.paddingBottom=e.paddingTop,e.paddingInner=Math.max(Math.ceil(t/2-e.tickLength/2),0),e.paddingOuter=Math.ceil(t/2+e.tickLength/2),e.baselineOffset=Math.round(t/5)),e.color=this._textColor(),this._rendererOptions},e.prototype._textColor=function(){return this._chartModel.properties().scalesProperties.textColor.value()},e.prototype._fontSize=function(){return this._chartModel.properties().scalesProperties.fontSize.value()},e}()},VuJ3:function(e,t,i){"use strict";function n(e){this.bars=e.bars,this.barSpacing=e.barSpacing,this.barWidth=o.optimalBarWidth(e.barSpacing),this.barLineWidth=e.thinBars?1:Math.max(1,Math.round(this.barWidth)),this.dontDrawOpen=e.dontDrawOpen,this._thinBars=e.thinBars}var o=i("Zp/P"),r=i("VdBB").HitTestResult;n.prototype.draw=function(e){var t,i,n,o,r,s;for(e.save(),e.translate(.5,.5),i=this.barLineWidth,n=this._thinBars?1:Math.round(this.barWidth),o=this._thinBars?1:n/2,r=0;r<this.bars.length;++r)t!==(s=this.bars[r]).color&&(e.fillStyle=s.color,t=s.color),e.fillRect(Math.round(s.time-i/2),Math.round(s.high-o),Math.round(i),Math.round(s.low-s.high+n)),i<this.barSpacing-1&&(this.dontDrawOpen||e.fillRect(Math.round(s.time-1.5*this.barWidth),Math.floor(s.open-o),Math.round(1.5*this.barWidth),n),e.fillRect(Math.round(s.time),Math.floor(s.close-o),Math.round(1.5*this.barWidth),n));e.restore()},n.prototype.hitTest=function(e){var t,i,n,s,a,l,c=this.bars,u=.5*this.barSpacing;if(0===c.length)return null;if(e.x<c[0].time-u)return null;if(e.x>c[c.length-1].time+u)return null;for(t=null,i=0;i<c.length;++i)if(n=c[i],e.x<=n.time+u){t=n;break}return t?(s=o.selectionTolerance(this.barLineWidth),
|
||||
a=Math.min(t.high,t.low),l=Math.max(t.high,t.low),a-s<=e.y&&e.y<=l+s?new r(r.REGULAR):null):null},t.PaneRendererBars=TradingView.PaneRendererBars=n},W5mg:function(e,t,i){"use strict";function n(e){return!e.groupId&&"time"!==e.type&&!e.isHidden&&!o.includes(e.id)}i.d(t,"a",function(){return n});var o=["first_visible_bar_time","last_visible_bar_time"]},WIS0:function(e,t,i){"use strict";function n(e,t){return e.ticker+"_"+t}function o(e){return new Date(e).toISOString()}var r,s,a,l,c,u;i.r(t),i.d(t,"DatafeedRequestsCachedProcessor",function(){return u}),r=i("LxhU"),s=i("Y7w9"),a=i("ocLq"),l=i("Kxc7"),i("HbRj"),c=function(){function e(e,t,i,n){this._cache={bars:[]},this._nextSubscriptionId=0,this._pendingSubscribers=[],this._subscribers=[],this._requesting=!1,this._leftDate=null,this._gaps=[],this._needPurgeCache=!1,this._realtimeOn=!1,this._endOfData=!1,this._resetCacheTimeout=null,this._errorMessage=null,this._destroyed=!1,this._emptyResponsesCount=0,this._datafeed=e,this._symbolInfo=t,this._resolution=i,this._dwmAligner=n}return e.prototype.destroy=function(){0!==this._subscribers.length&&console.warn("Destroying with not-empty state"),this._clearResetCacheTimeout(),this._unsubscribeRealtime(),this._purgeCache(),delete this._datafeed,this._destroyed=!0},e.prototype.addSubscription=function(e,t,i){var n=this,o=this._getNextSubscriptionId(),r=Math.floor(e.from/1e3),s=Math.floor(e.to/1e3);return this._pendingSubscribers.push({key:o,range:{from:r,to:s},onHistoryCallback:t,onErrorCallback:i}),this._clearResetCacheTimeout(),setTimeout(function(){n._destroyed||n._processPendingSubscribers()},0),o},e.prototype.removeSubscription=function(e){var t,i=this,n=this._pendingSubscribers.find(function(t){return t.key===e});if(n)this._pendingSubscribers.splice(this._pendingSubscribers.indexOf(n),1);else{if(t=this._subscribers.find(function(t){return t.key===e}))return this._subscribers.splice(this._subscribers.indexOf(t),1),void(this._subscribers.length||(this._symbolInfo.expired||this._symbolInfo.expiration_date?this._unsubscribeRealtime():this._resetCacheTimeout=setTimeout(function(){i._purgeCacheDelayed(),i._unsubscribeRealtime()})));console.warn("Unknown subscription symbol={0}, resolution={1}, key={2}".format(this._symbolInfo.name,this._resolution,e))}},e.prototype._purgeCacheDelayed=function(){this._logMessage("Reset cache"),this._needPurgeCache=!0,this._clearResetCacheTimeout()},e.prototype._logMessage=function(e,t){(l.enabled("charting_library_debug_mode")||t)&&console.log("FEED [{0}|{1}]: {2}".format(this._symbolInfo.name,this._resolution,e))},e.prototype._clearResetCacheTimeout=function(){null!==this._resetCacheTimeout&&(clearTimeout(this._resetCacheTimeout),this._resetCacheTimeout=null)},e.prototype._purgeCache=function(){this._cache={bars:[]},this._gaps=[],this._errorMessage=null,this._needPurgeCache=!1,this._leftDate=null,this._endOfData=!1},e.prototype._processPendingSubscribers=function(){var e,t,i,n,s,a=this,l=this._pendingSubscribers
|
||||
;if(l.length)if(this._requesting)this._logMessage("Processing is skipped due active request");else{if(this._logMessage("Processing pending subscribers, count="+l.length),this._needPurgeCache&&this._purgeCache(),this._errorMessage)return e=this._errorMessage,this._logMessage("Return error: "+e),this._pendingSubscribers=[],void l.forEach(function(t){t.onErrorCallback(e)});t=l.reduce(function(e,t){return Math.min(t.range.from,e)},1/0),this._logMessage('Leftmost requested "from" is '+o(1e3*t)),this._leftDate&&!(t<this._leftDate)||(i=(new r.Interval(this._resolution).inMilliseconds(Date.now())||0)/1e3,s=!(n=!this._leftDate)&&!!this._cache.bars.length&&this._cache.bars[0].time/1e3-t<i,!n&&s||this._endOfData)?(this._pendingSubscribers=[],l.forEach(function(e){var t=a._moveSubscriberToRealtime(e);a._returnHistoryDataToSubscriber(e,t)}),this._subscribeRealtimeIfNeeded()):this._ensureRequestedTo(t)}},e.prototype._moveSubscriberToRealtime=function(e){var t={key:e.key,onHistoryCallback:e.onHistoryCallback,barset:null};return this._subscribers.push(t),t},e.prototype._subscribeRealtimeIfNeeded=function(){!this._subscribers.length||this._realtimeOn||this._symbolInfo.expired||this._symbolInfo.expiration_date||this._subscribeRealtime()},e.prototype._subscribeRealtime=function(){var e,t,i=this;this._symbolInfo.expired||this._realtimeOn||(e=function(e){i._dwmAligner&&(e.time=i._dwmAligner.tradingDayToSessionStart(e.time)),i._putToCacheNewBar(e),i._subscribers.forEach(function(t){var i=t.barset;if(null===i)throw new Error("subscirber.barset is null");i.add(e),t.onHistoryCallback(i)})},t=function(){i._unsubscribeRealtime();var e=i._leftDate;i._purgeCache(),e&&i._ensureRequestedTo(e)},this._realtimeOn=!0,this._datafeed.subscribeBars(this._symbolInfo,this._resolution,e,n(this._symbolInfo,this._resolution),t),this._logMessage("Subscribed to realtime"))},e.prototype._unsubscribeRealtime=function(){!this._symbolInfo.expired&&this._realtimeOn&&(this._datafeed.unsubscribeBars(n(this._symbolInfo,this._resolution)),this._logMessage("Unsubscribed from realtime"),this._realtimeOn=!1)},e.prototype._returnHistoryDataToSubscriber=function(e,t){var i,n,r=e.range,s=this._createBarset(r.from);s.count()>0?this._logMessage("Bars to return for request {0}: total {1} bars in [{2} ... {3}] ".format(e.key,s.count(),o(s.bars[0].time),o(s.bars[s.count()-1].time))):this._logMessage("Request {0}. Nothing to return.".format(e.key)),t.barset=s,(i=this._inGapNextTime(r.from))?(this._logMessage("Request {0} is in gap, nextTime = {1}".format(e.key,o(1e3*i))),s.nextTime=i):0===s.count()&&(n=this._cache.bars.length&&this._cache.bars[this._cache.bars.length-1].time/1e3)&&r.from>n&&(this._logMessage("Request {0} is in gap, nextTime = {1}".format(e.key,o(1e3*n))),s.nextTime=n||void 0),this._endOfData&&null!==this._leftDate&&e.range.from<=this._leftDate&&(s.endOfData=!0),e.onHistoryCallback(s)},e.prototype._createBarset=function(e){var t=Object(s.lowerbound)(this._cache.bars,1e3*e,function(e,t){return e.time<t});return new a.BarSet(this._symbolInfo,this._cache.bars.slice(t))
|
||||
},e.prototype._ensureRequestedTo=function(t){var i,n,r,s=this;this._leftDate&&this._leftDate<t?this._processPendingSubscribers():(i=!this._leftDate,this._requesting=!0,n=t,r=this._leftDate?this._leftDate-1:this._symbolInfo.expiration_date||Math.floor(e._now()/1e3),this._leftDate=t,this._logMessage("Requesting data: [{0} ... {1}] ".format(o(1e3*n),o(1e3*r))),this._datafeed.getBars(this._symbolInfo,this._resolution,n,r,function(e,t){s._destroyed||(s._requesting=!1,s._processBars(e,t))},function(e){s._requesting=!1,s._errorMessage=e||null,s._processPendingSubscribers()},i))},e.prototype._processBars=function(e,t){this._checkBars(e),this._alignBarsTime(e),e.length>0?(this._emptyResponsesCount=0,this._processFullBarset(e,t)):(this._emptyResponsesCount+=1,this._processEmptyBarset(t)),this._processPendingSubscribers()},e.prototype._processEmptyBarset=function(t){this._logMessage("Receiving bars: barset is empty"),t&&t.nextTime?(this._logMessage("Next time received: `{0}`".format(o(1e3*t.nextTime))),this._addGap(t.nextTime),this._leftDate=Math.min(this._leftDate||e._now()/1e3,t.nextTime+1)):t&&t.noData?(this._logMessage("EOD received"),this._setEndOfData()):this._logMessage("nextTime or noData should present in metainfo when empty barset is returned"),50===this._emptyResponsesCount&&(this._logMessage("EOD detected due 50 empty responses in a row"),this._setEndOfData())},e.prototype._setEndOfData=function(){this._endOfData=!0,this._cache.bars.length&&(this._leftDate=this._cache.bars[0].time/1e3)},e.prototype._processFullBarset=function(e,t){var i=e[0].time,n=e[e.length-1].time;this._logMessage("Receiving bars: total {0} bars in [{1} ... {2}] ".format(e.length,o(i),o(n))),null!==this._leftDate&&i<1e3*this._leftDate&&this._logMessage("Returned more data than needed"),this._putToCache(e)?null!==this._leftDate&&this._cache.bars.length&&this._leftDate>this._cache.bars[0].time/1e3&&(this._leftDate=this._cache.bars[0].time/1e3):this._logMessage("Incremental update failed. Starting full update. Returned data should be in the requested range.",!0),t&&t.nextTime?console.warn("nextTime should be set when there is no data in the requested period only"):t&&t.noData&&console.warn("noData should be set when there is no data in the requested period and earlier only")},e.prototype._addGap=function(t){var i,n=this._gaps.find(function(e){return e.from===t});n||(i=(this._cache.bars.length?this._cache.bars[0].time:e._now())/1e3,this._gaps.push({from:t,to:i}))},e.prototype._inGapNextTime=function(e){var t=this._gaps.find(function(t){return t.from<e&&t.to>e});return t?t.from:null},e.prototype._getNextSubscriptionId=function(){return this._nextSubscriptionId++},e.prototype._checkBars=function(e,t){var i,n;if(void 0===t&&(t=!1),l.enabled("charting_library_debug_mode"))for(i=1;i<e.length;i++)e[i].time<=e[i-1].time&&(n="Wrong bars time: time {0} of bar {1} should be more than time {2} of bar {3}".format(e[i].time,i,e[i-1].time,i-1),t&&this._dwmAligner&&(n+="\nCheck that you provide DWM bars without time part, i.e. 00:00 GMT"),console.error(n))},
|
||||
e.prototype._putToCache=function(e){if(0===e.length)return!0;if(this._cache.bars.length===e.length&&this._cache.bars[0].time===e[0].time&&this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time)return this._logMessage("Time range of received data is the same as cached one. Skip the update."),!0;if(0!==this._cache.bars.length&&e[e.length-1].time===this._cache.bars[0].time&&this._cache.bars.splice(0,1),0!==this._cache.bars.length&&e[e.length-1].time>=this._cache.bars[0].time){var t=this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time;if(this._cache.bars=[],!t)return this._leftDate=null,!1;this._logMessage("Received history up to now instead of incremental update. Return exactly what is requested.")}return this._cache.bars=e.concat(this._cache.bars),this._checkBars(this._cache.bars,!0),!0},e.prototype._putToCacheNewBar=function(e){var t=this._cache.bars.length,i=e.time,n=0===t?NaN:this._cache.bars[t-1].time,r=0===t||n<i;r?this._cache.bars.push(e):n===i?this._cache.bars[t-1]=e:console.error("putToCacheNewBar: time violation, previous bar time: "+o(n)+" should be less or equal to new time: "+o(i))},e.prototype._alignBarsTime=function(e){if(this._dwmAligner)for(var t=0;t<e.length;t++)e[t].time=this._dwmAligner.tradingDayToSessionStart(e[t].time)},e._now=function(){return Date.now()+6e4},e}(),u=function(){function e(e,t){this._threads={},this._datafeed=e,this._dwmAlignerCreator=t}return e.prototype.destroy=function(){this._forEachThread(function(e,t){return t.destroy()}),this._threads={},delete this._datafeed},e.prototype.purgeCache=function(){this._forEachThread(function(e,t){return t.destroy()}),this._threads={}},e.prototype.subscribe=function(e,t,i,o,r){var s=n(e,t);return this._threads[s]||(this._threads[s]=this._createThread(e,t)),s+'"'+this._threads[s].addSubscription(i,o,r)},e.prototype.unsubscribe=function(e){var t,i,n=e.split('"');2===n.length?(t=n[0],i=parseInt(n[1]),this._threads.hasOwnProperty(t)?this._threads[t].removeSubscription(i):console.warn("Data thread doesnt exist: "+e)):console.warn("Wrong guid format")},e.prototype._createThread=function(e,t){return new c(this._datafeed,e,t,this._dwmAlignerCreator(t,e.timezone,e.session))},e.prototype._forEachThread=function(e){var t=this;Object.keys(this._threads).forEach(function(i){return e(i,t._threads[i])})},e}()},WPQD:function(e,t,i){"use strict";function n(){var e,t,i;this._registeredSources={},this._sourcesToRow={},this._rowsToSources={},this._currentSymbol="",this._actualCapacity=0,this._actualWidth=0,this._canvas=document.createElement("canvas"),this._cache=this._canvas.getContext("2d"),this._currentWidth=400,this._canvas.width=this._currentWidth,this._canvas.height=1,this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.zIndex="1000",this._canvas.style.left="0",this._ctx=this._canvas.getContext("2d"),this._ctx.font=h.fontSize+"px"+h.font,t=h.fontSize+(e=h.lineSpacing),i=3,this._padding=8,this._rowHeight=t*i-e+2*this._padding+2}function o(e,t){this._constructor="LineToolTrendLine"
|
||||
;var o=t||new a("linetooltrendline");s.call(this,e,o),e._trendLineStatsCache||(e._trendLineStatsCache=new n),i.e("lt-pane-views").then(function(e){var t=i("ocVb").TrendLinePaneView;this._setPaneViews([new t(this,this._model)])}.bind(this).bind(null,i)).catch(i.oe)}var r=i("aO4+").Point,s=i("Ss5c").LineDataSource,a=i("Ocx9").DefaultProperty,l=i("hayr").propertyPages,c=i("uOxu").getLogger("Chart.LineToolTrendLine"),u=i("5/lF").TrendLineStatsRenderer,h=i("8xAY").LabelSettings;n.prototype.canvas=function(){return this._canvas},n.prototype.topByRow=function(e){return e*this._rowHeight},n.prototype.rowHeight=function(e){return this._rowHeight},n.prototype.rowWidth=function(e){var t=this._rowsToSources[e];return this._sourcesToRow[t].width},n.prototype.currentWidth=function(){return this._currentWidth},n.prototype._findEmptyRow=function(e){for(var t=0;this._rowsToSources[t];)t++;return this._rowsToSources[t]=e,t>=this._actualCapacity&&(this._actualCapacity++,TradingView.resizeCanvas(this._canvas,this._currentWidth,this._rowHeight*this._actualCapacity),this._ctx=this._canvas.getContext("2d"),c.logDebug("TrendLineCache. Expanging cache to "+this._actualCapacity+" items")),t},n.prototype._effectiveState=function(e){var t,i={};return i.p1=Object.assign({},e.points()[0]),i.p2=Object.assign({},e.points()[1]),t=e.properties(),i.showBars=t.showBarsRange.value(),i.showTimeRange=t.showDateTimeRange.value(),i.showDistance=t.showDistance.value(),i.showPriceRange=t.showPriceRange.value(),i.showAngle=t.showAngle.value(),i.color=t.textcolor.value(),i.showAngle&&(i.priceRange=e.priceScale().priceRange().state(),i.barSpacing=e._model.timeScale().barSpacing()),i},n.prototype._effectiveStatesEquals=function(e,t){var i=function(e,t){return!(!e&&!t)&&(!(!e||t)||(!(e||!t)||(e.index!==t.index||e.price!==t.price)))};if(e&&!t)return!1;if(!e&&t)return!1;if(i(e.p1,t.p1))return!1;if(i(e.p2,t.p2))return!1;if(e.color!==t.color)return!1;if(e.showBars!==t.showBars)return!1;if(e.showTimeRange!==t.showTimeRange)return!1;if(e.showDistance!==t.showDistance)return!1;if(e.showPriceRange!==t.showPriceRange)return!1;if(e.showAngle!==t.showAngle)return!1;if(e.showAngle){if(e.priceRange.min!==t.priceRange.min)return!1;if(e.priceRange.max!==t.priceRange.max)return!1;if(e.barSpacing!==t.barSpacing)return!1}return!0},n.prototype.removeSource=function(e){if(this._sourcesToRow[e]){var t=this._sourcesToRow[e].row;this._ctx.save(),this._ctx.clearRect(0,this.topByRow(t),this._currentWidth,this.rowHeight(t)),this._ctx.restore(),delete this._sourcesToRow[e],delete this._rowsToSources[t]}},n.prototype._repaintSource=function(e,t,i){var n;this._ctx.save(),this._ctx.translate(0,this.topByRow(t)+.5),i.points[0]=new r(0,0),i.offsetX=0,i.offsetY=0,delete i.horzAlign,delete i.vertAlign,this._ctx.clearRect(0,0,this._currentWidth,this.rowHeight(t)),n=new u(i,{}).draw(this._ctx),this._sourcesToRow[e].width=n.width,this._ctx.restore()},n.prototype.updateSource=function(e,t){var i,n,o,r,s,a=e.properties().symbol.value()
|
||||
;return this._currentSymbol!==a&&(c.logDebug("TrendLineCache. Clearing canvas because of changing symbol from "+this._currentSymbol+" to "+a),this._currentSymbol=a,this._sourcesToRow={},this._rowsToSources={}),i=e.id(),this._sourcesToRow[i]||(n=this._findEmptyRow(i),this._sourcesToRow[i]={effectiveState:null,row:n}),o=this._sourcesToRow[e.id()].effectiveState,r=this._effectiveState(e),this._effectiveStatesEquals(o,r)||(n=this._sourcesToRow[e.id()],s=t(),this._repaintSource(i,n.row,s),this._sourcesToRow[i].effectiveState=r),this._sourcesToRow[i]},inherit(o,s),o.prototype.stop=function(){s.prototype.stop.call(this),this._model._trendLineStatsCache.removeSource(this.id())},o.prototype.pointsCount=function(){return 2},o.prototype.title=function(){return"Trend Line"},o.prototype.name=function(){return"Trend Line"},o.prototype.canHasAlert=function(){return!0},o.prototype._getAlertPlots=function(){return[this._linePointsToAlertPlot(this._points,null,this.properties().extendLeft.value(),this.properties().extendRight.value())]},o.prototype.getStylesPropertyPage=function(){return l.LineToolTrendLineStylesPropertyPage},t.LineToolTrendLine=o},Wc1E:function(e,t,i){"use strict";var n,o,r,s,a,l,c,u,h,d;i.r(t),i.d(t,"DataModeIndicator",function(){return d}),n=i("mrSG"),i("YFKU"),i("HbRj"),o=i("quTg"),r=i("r8Gw"),s={connecting:"tv-data-mode--connecting",delayed:"tv-data-mode--delayed",delayed_streaming:"tv-data-mode--delayed",endofday:"tv-data-mode--endofday",forbidden:"tv-data-mode--forbidden",realtime:"tv-data-mode--realtime",snapshot:"tv-data-mode--snapshot",loading:"tv-data-mode--loading",replay:"tv-data-mode--replay"},a={connecting:window.t("Connecting"),delayed:window.t("Delayed"),delayed_streaming:window.t("Delayed"),endofday:window.t("End of Day"),forbidden:window.t("Instrument is not allowed"),realtime:window.t("Real-time"),snapshot:window.t("Snapshot"),loading:"",replay:window.t("Replay Mode")},l={connecting:window.t("C",{context:"data_mode_connecting_letter"}),delayed:window.t("D",{context:"data_mode_delayed_letter"}),delayed_streaming:window.t("D",{context:"data_mode_delayed_streaming_letter"}),endofday:window.t("E",{context:"data_mode_end_of_day_letter"}),forbidden:window.t("F",{context:"data_mode_forbidden_letter"}),realtime:window.t("R",{context:"data_mode_realtime_letter"}),snapshot:window.t("S",{context:"data_mode_snapshot_letter"}),loading:"",replay:window.t("R",{context:"data_mode_replay_letter"})},u={streaming:"realtime"},h={classMap:s,classSuffix:"",data:{values:{update_mode:"connecting"}},labelMap:a,modeInterval:c=600,short:!1,shortLabelMap:l,showTooltip:!0,tooltipType:"custom"},d=function(e){function t(t){var i=e.call(this,t)||this;return i._quoteSessionPrefix="data-mode-indicator",i._componentClass="tv-data-mode",i._init(t),i}return n.__extends(t,e),t.prototype.getLabel=function(){return!0===this._shortMode?this._shortLabelMap[this._value]||"":e.prototype.getLabel.call(this)},t.prototype.setMode=function(e,t){this.update({values:{update_mode:e,update_mode_seconds:t}})},t.prototype.hide=function(){
|
||||
this._el.classList.add("i-hidden")},t.prototype.show=function(){this._el.classList.remove("i-hidden")},t.prototype.getTooltipText=function(){var e="",t=this.getValue();if(""===t)return e;switch(t){case"delayed":e=window.t("Quotes are delayed by {0} min and updated every 30 seconds");break;case"delayed_streaming":e=window.t("Quotes are delayed by {0} min");break;default:e=this._labelMap[t]||e}return["delayed","delayed_streaming"].includes(t)&&(e=e.format(Math.round(this._modeInterval/60))),e},t.prototype._init=function(t){void 0===t&&(t={});var i=Object.assign({},h,t);this._modeInterval=i.modeInterval||c,this._shortLabelMap=i.shortLabelMap||l,e.prototype._init.call(this,i),this._render()},t.prototype._getValueFromData=function(e){var t;return t=void 0!==e.values&&void 0!==e.values.update_mode?e.values.update_mode:this.getValue(),u[t]||t},t.prototype._updateValue=function(t,i){void 0!==t.values&&void 0!==t.values.update_mode_seconds&&(this._modeInterval=t.values.update_mode_seconds),e.prototype._updateValue.call(this,t,i)},t}(r.a)},"Wh/T":function(e,t,i){"use strict";var n=i("Kxc7");window.onload=function(){location.hostname.indexOf(".")>=0&&!function(){try{return/^(192|172|10)\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]/.test(location.hostname)||/^.*((?:\.local)|localhost)$/.test(location.hostname)}catch(e){return!1}}()&&setTimeout(function(){try{var e=function(){var e=0,t=JSON.parse(urlParams.logo);return t.image&&(e="C",n.enabled("link_to_tradingview")||(e="D")),e}();window.ga&&(0!==e&&window.ga("send","event","s",e),urlParams.utm||window.ga("send","event","l"))}catch(e){}},3e4)}},Wh6B:function(e,t,i){"use strict";function n(e,t){this._constructor="LineToolPrediction";var n=t||new s("linetoolprediction");n.merge({status:l.AlertStatus.Waiting}),r.call(this,e,n),i.e("lt-pane-views").then(function(e){var t=i("Ay2m").PredictionPaneView;this._setPaneViews([new t(this,this._model)])}.bind(this).bind(null,i)).catch(i.oe)}var o=i("Eyy1").ensureNotNull,r=i("Ss5c").LineDataSource,s=i("Ocx9").DefaultProperty,a=i("hayr").propertyPages,l=i("08i5");inherit(n,r),n.prototype.status=function(){return this._properties.status.value()},n.prototype.setStatus=function(e){return this._properties.status.setValue(e)},n.prototype.pointsCount=function(){return 2},n.prototype.title=function(){return"Forecast"},n.prototype.name=function(){return"Forecast"},n.prototype.restorePoints=function(e,t,i){r.prototype.restorePoints.call(this,e,t,i),this.checkAlert()},n.prototype.checkAlert=function(){var e,t,i,n;this._points.length<2||this._model.mainSeries().bars().isEmpty()||(e=this._points[1],this.status()?e.index>this._model.timeScale().baseIndex()&&this.setStatus(l.AlertStatus.Waiting):null!==(t=this._model.mainSeries().bars().valueAt(e.index))&&((i=this.direction())===l.Direction.Up&&t[TradingView.HIGH_PLOT]>=e.price?this.setStatus(l.AlertStatus.Success):i===l.Direction.Down&&t[TradingView.LOW_PLOT]<=e.price?this.setStatus(l.AlertStatus.Success):(n=o(this._model.mainSeries().bars().lastIndex()),
|
||||
e.index!==n&&this.setStatus(l.AlertStatus.Failure))))},n.prototype.addPoint=function(e){var t=r.prototype.addPoint.call(this,e);return t&&this.checkAlert(),t},n.prototype.endChanging=function(){r.prototype.endChanging.call(this),this.setStatus(l.AlertStatus.Waiting),this.checkAlert()},n.prototype.onData=function(e){r.prototype.onData.call(this,e),this.checkAlert()},n.prototype.endMoving=function(){r.prototype.endMoving.call(this),this.setStatus(l.AlertStatus.Waiting),this.checkAlert()},n.prototype.direction=function(){var e;return this.points().length<2?l.Direction.Up:(e=this.points()[0],this.points()[1].price>e.price?l.Direction.Up:l.Direction.Down)},n.prototype.getStylesPropertyPage=function(){return a.LineToolPredictionStylesPropertyPage},t.LineToolPrediction=n},WkOR:function(e,t,i){"use strict";function n(e,t){return void 0===e?void 0===t:void 0!==t&&(s?e.toUpperCase()===t.toUpperCase():e===t)}function o(e,t){return e.some(function(e){return n(t,e)})}var r,s;i.r(t),i.d(t,"areEqualSymbols",function(){return n}),i.d(t,"includesEqualSymbol",function(){return o}),r=i("Kxc7"),s=r.enabled("uppercase_instrument_names")},WkYF:function(e,t,i){"use strict";function n(e,t){this._constructor="LineToolDateRange";var n=t||new r("linetooldaterange");o.call(this,e,n),i.e("lt-pane-views").then(function(e){var t=i("3xLB").DateRangePaneView;this._setPaneViews([new t(this,this._model)])}.bind(this).bind(null,i)).catch(i.oe)}var o=i("Ss5c").LineDataSource,r=i("Ocx9").DefaultProperty,s=i("hayr").propertyPages;inherit(n,o),n.prototype.pointsCount=function(){return 2},n.prototype.title=function(){return"Date Range"},n.prototype.name=function(){return"Date Range"},n.prototype.getStylesPropertyPage=function(){return s.LineToolDateRangeStylesPropertyPage},t.LineToolDateRange=n},WmDe:function(e,t,i){"use strict";TradingView.PublishedChartsTimeline=function(){},TradingView.LinearRegressionPaneView=function(){},TradingView.study_PivotPointsStandard=function(){},TradingView.study_PivotPointsHighLow=function(){},TradingView.study_ZigZag=function(){},TradingView.study_LinearRegression=function(){},TradingView.study_ElliottWave=function(){},TradingView.ESDStudyBase=function(){},TradingView.Pro=function(){this.hasPackage=function(){return!1}},window.user={is_pro:!1,settings:{}},TradingView.Pro.prototype.getStudies=function(){return[]},TradingView.Pro.prototype.getProduct=function(){return{}},TradingView.Pro.prototype.getStudiesOrder=function(){return[]},TradingView.AlertLabel=function(){},TradingView.getDataVendorString=function(){},TradingView.study_VbPVisible=function(){},TradingView.study_VbPSessions=function(){},TradingView.study_ESD$TV_DIVIDENDS=function(){},TradingView.study_ESD$TV_SPLITS=function(){},TradingView.study_ESD$TV_EARNINGS=function(){},TradingView.MockupRequestedCache=function(e){e&&e([])},TradingView.MockupRequestedCache.invalidate=function(){},TradingView.LinetoolTemplatesList=function(){}},Wo0S:function(e,t,i){e.exports={"common-tooltip":"common-tooltip-s2GEoMlT-","common-tooltip--hidden":"common-tooltip--hidden-Z0EAvXgv-",
|
||||
Reference in New Issue
Block a user