3 lines
7.7 KiB
JavaScript
3 lines
7.7 KiB
JavaScript
"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[8526],{75480:(e,l,t)=>{t.r(l),t.d(l,{exportData:()=>y});var s=t(91599),i=t(85842),n=t(42897),o=t(65366),u=t(62352),d=t(64367),a=t(44850),r=t(37032),c=t(65164),f=t(3774),h=t(85728),p=t(45766);const m={includeTime:!0,includeUserTime:!1,includeSeries:!0,includeDisplayedValues:!1,includedStudies:"all",includeOffsetStudyValues:!1,includeOHLCValuesForSingleValuePlots:!1,includeHiddenStudies:!1};function g(e,l){const t={schema:[],data:[],displayedData:[],indexes:[]},s=e.timeScale().points(),n=e.mainSeries(),o=n.style(),c=!l.includeOHLCValuesForSingleValuePlots&&(0,r.isSingleValueBasedStyle)(o),m=(0,i.ensureNotNull)(n.symbolInfo()),g=(0,p.getChartWidgetApiTimeConverter)(n.interval(),m,e),y=!l.includeOHLCValuesForSingleValuePlots&&(0,r.isCloseBasedSymbol)(m),x=V(e,l.includedStudies,l.includeHiddenStudies),I=[];for(const e of x){const t=(0,u.isOverlayStudy)(e)?P(e,l):T(e);I.push(t)}const O=x.map((e=>e.data()));(l.includeSeries||0===O.length)&&O.push(n.bars());const b=function(e,l,t,s,n){const o=(0,i.ensureNotNull)(e.range().value(),"time scale points range"),u=function(e,l,t,s){const n=s.from,o=s.to,u=e.range().value(),r=(0,i.ensureNotNull)(void 0!==n?e.indexOf(n,!0):(0,i.ensureNotNull)(u).firstIndex),c=(0,i.ensureNotNull)(void 0!==o?e.indexOf(o,!0):(0,i.ensureNotNull)(u).lastIndex);let f=c,p=r;for(let e=0;e<l.length;e++){const i=l[e],n=s.includeOffsetStudyValues?(0,h.max)(t[e]?.fieldPlotOffsets??[0]):0,o=i.search(r,a.PlotRowSearchMode.NearestRight);null!==o&&o.index<f&&(f=o.index);const u=i.search(c,a.PlotRowSearchMode.NearestLeft);null!==u&&u.index+n>p&&(p=u.index+n)}return(0,i.assert)(f<=p,"Range must contain at least 1 time point"),new d.BarsRange(f,p)}(e,l,t,n),r=u.firstBar(),c=u.lastBar(),f=[];for(let e=r;e<=c;e++){const l={index:e,time:(0,i.ensureNotNull)(s.convertTimePointIndexToInternalTime(e)),publicTime:(0,i.ensureNotNull)(s.convertTimePointIndexToPublicTime(e))};if(!(void 0!==n.from&&l.time<n.from)){if(void 0!==n.to&&l.time>n.to)break;if(!n.includeOffsetStudyValues&&e>o.lastIndex)break;f.push(l)}}return f.length>0?new S(f):null}(s,O,I,g,l);if(null===b)return t;const w=b.firstBar(),D=b.lastBar();l.includeTime&&t.schema.push({type:"time"});const F=t.schema.length;l.includeUserTime&&t.schema.push({type:"userTime"});const C=t.schema.length;if(l.includeSeries){const e=n.statusProvider({hideResolution:!0}).getSplitTitle(),l=Object.values(e).filter((e=>""!==e)).join(", ");t.schema.push(...function(e,l,t,s,n){const o=[];t?o.push(N("close",e)):s?o.push(N((0,i.ensureNotNull)(n),e)):12===l?o.push(N("high",e),N("low",e)):16===l||21===l?o.push(N("high",e),N("low",e),N("close",e)):o.push(N("open",e),N("high",e),N("low",e),N("close",e));return o}(l,o,y,c,n.priceSource()))}let _=t.schema.length;for(const e of I)t.schema.push(...e.fields);const B=t.schema.length;if(0===B)return t;for(let e=w;e<=D;++e){const s=new Float64Array(B);s.fill(NaN),t.data.push(s),t.indexes.push(e),l.includeDisplayedValues&&t.displayedData.push(new Array(B).fill(""))}
|
|
if(l.includeTime||l.includeUserTime){const s=e.dateTimeFormatter();for(let e=w;e<=D;++e){const n=b.item(e),o=n.time,u=n.publicTime,d=new Date(1e3*(0,i.ensureNotNull)(u));if(l.includeTime&&(t.data[e-w][0]=(0,i.ensureNotNull)(o)),l.includeUserTime&&(t.data[e-w][F]=d.getTime()/1e3),l.includeDisplayedValues){const i=s.format(d);l.includeTime&&(t.displayedData[e-w][0]=i),l.includeUserTime&&(t.displayedData[e-w][F]=i)}}}if(l.includeSeries){const e=n.bars().range(w,D),s=(0,f.getPriceValueFormatterForSource)(n),i=e=>s(e,{ignoreLocaleNumberFormat:!0}),u=n.barFunction();e.each(((e,s)=>{const n=t.data[e-w],d=v(s[4]);if(y){if(n[C]=d,l.includeDisplayedValues){t.displayedData[e-w][C]=i(d)}}else if(c){const o=u(s);if(n[C]=o,l.includeDisplayedValues){t.displayedData[e-w][C]=i(o)}}else{const u=v(s[1]),a=v(s[2]),r=v(s[3]);if(12===o?(n[C]=a,n[C+1]=r):16===o||21===o?(n[C]=a,n[C+1]=r,n[C+2]=d):(n[C]=u,n[C+1]=a,n[C+2]=r,n[C+3]=d),l.includeDisplayedValues){const l=t.displayedData[e-w];12===o?(l[C]=i(a),l[C+1]=i(r)):16===o||21===o?(l[C]=i(a),l[C+1]=i(r),l[C+2]=i(d)):(l[C]=i(u),l[C+1]=i(a),l[C+2]=i(r),l[C+3]=i(d))}}return!1}))}for(let e=0;e<x.length;++e){const s=x[e],n=I[e];let o,d=!1,a=!1;(0,u.isOverlayStudy)(s)&&(o=s.barFunction(),d=!l.includeOHLCValuesForSingleValuePlots&&(0,r.isCloseBasedSymbol)(s.symbolInfo()),a=!l.includeOHLCValuesForSingleValuePlots&&(0,r.isSingleValueBasedStyle)(s.style()));for(let e=0;e<n.fields.length;++e){const u=(0,f.getPriceValueFormatterForStudy)(s,n.fields[e].plotId),r=e=>u(e,{ignoreLocaleNumberFormat:!0}),c=n.fieldPlotOffsets[e],h=n.fieldToPlotIndex[e],p=w-c,m=D-c,g=_+e;s.data().range(p,m).each(((e,s)=>{const n=t.data[e-p];let u;return u=d?v(s[4]):a?(0,i.ensureDefined)(o)(s):v(s[h]),n[g]=u,l.includeDisplayedValues&&(t.displayedData[e-p][g]=r(u)),!1}))}_+=n.fields.length}return t}function y(e,l={}){const t={...m,...l};if(t.includeHiddenStudies){const l=V(e,t.includedStudies,t.includeHiddenStudies),s=[],i=[];for(const e of l)e.isVisible()||(s.push(e),i.push(e.start(!0,!0)));return(async()=>{i.length>0&&(await Promise.all(i),await new Promise((e=>{setTimeout((()=>e()))})))})().then((()=>g(e,t))).finally((()=>{for(const e of s)e.stop()}))}return g(e,t)}class S{constructor(e){this._items=e,this._firstIndex=this._items[0].index,this._lastIndex=this._items[this._items.length-1].index}firstBar(){return this._firstIndex}lastBar(){return this._lastIndex}item(e){return this._items[e-this._firstIndex]}}function T(e){const l=e.metaInfo(),u={fieldToPlotIndex:[],fieldPlotOffsets:[],fields:[]},d=e.id(),a=e.properties().childs(),r=e.title(o.TitleDisplayTarget.StatusLine,!1,void 0,!1);for(let o=0;o<l.plots.length;++o){const f=l.plots[o];let h,p="";if((0,c.isPlotSupportDisplay)(f)){const e=a.styles.childs()[f.id];if(void 0!==e&&0===e.childs().display.value())continue;h=(0,i.ensureDefined)(l.styles)[f.id]}else if((0,c.isOhlcPlot)(f)){const e=a.ohlcPlots.childs()[f.target];if(void 0!==e&&0===e.childs().display.value())continue;switch(h=l.ohlcPlots&&l.ohlcPlots[f.target],f.type){case"ohlc_open":p=` (${s.t(null,void 0,t(97781))})`
|
|
;break;case"ohlc_high":p=` (${s.t(null,void 0,t(45563))}`;break;case"ohlc_low":p=` (${s.t(null,void 0,t(88678))})`;break;case"ohlc_close":p=` (${s.t(null,void 0,t(20866))})`}}if(void 0===h||void 0===h.title)continue;const m=`${(0,n.decodeHTMLEntities)(h.title)}${p}`;u.fields.push(x(d,r,m,f.id)),u.fieldToPlotIndex.push(o+1),u.fieldPlotOffsets.push(e.offset(f.id))}return u}function P(e,l){const t={fieldToPlotIndex:[],fieldPlotOffsets:[],fields:[]},s=e.id(),n=e.title(o.TitleDisplayTarget.StatusLine,!1,void 0,!1),u=e.style(),d=!l.includeOHLCValuesForSingleValuePlots&&(0,r.isCloseBasedSymbol)(e.symbolInfo()),a=!l.includeOHLCValuesForSingleValuePlots&&(0,r.isSingleValueBasedStyle)(u);if(d)t.fields.push(x(s,n,"close","close")),t.fieldToPlotIndex.push(4),t.fieldPlotOffsets.push(0);else if(a){const l=(0,i.ensureNotNull)(e.priceSource());t.fields.push(x(s,n,l,l)),t.fieldToPlotIndex.push(1),t.fieldPlotOffsets.push(0)}else 12===u?(t.fields.push(x(s,n,"high","high"),x(s,n,"low","low")),t.fieldToPlotIndex.push(3,2),t.fieldPlotOffsets.push(0,0)):16===u||21===u?(t.fields.push(x(s,n,"high","high"),x(s,n,"low","low"),x(s,n,"close","close")),t.fieldToPlotIndex.push(2,3,4),t.fieldPlotOffsets.push(0,0,0)):(t.fields.push(x(s,n,"open","open"),x(s,n,"high","high"),x(s,n,"low","low"),x(s,n,"close","close")),t.fieldToPlotIndex.push(1,2,3,4),t.fieldPlotOffsets.push(0,0,0,0));return t}function x(e,l,t,s){return{type:"value",sourceType:"study",sourceId:e,sourceTitle:l,plotTitle:t,plotId:s}}function N(e,l){return{type:"value",sourceType:"series",plotTitle:e,sourceTitle:l}}function v(e){return null!=e?e:NaN}function V(e,l,t){const s=e.allStudies().filter((e=>e.showInObjectTree()&&(t||e.isVisible())));return"all"===l?s:s.filter((e=>l.includes(e.id())))}}}]); |