%K and %D should be swapped in Stochastic RSI #1024
Blank chart when tabbing (Mac OSX) #1015 Study Template drop down error #1013 Double volume when loading study template #1012 Remove all studies breaks chart #1008 Rename Donchian Channels plot names #1006 Stochastic %K and %D should be swapped #982 Change brush tool default color #976 Send search requests with a delay #974 Unstable Version - Info indicator top right + event bubble #962 Compress language json #961 Intermittent issue loading complex charts #956 Label "closed" when market should be open #942 Pitchfork plots visibilities are not saved (unstable) #938 Unable to get 'Symbol Info ' option in chart... #936 Add more colors to the bar marks #914 custom_css_url doesn't work #912 Fibonacci retracements' custom levels not being saved #911 Volume added to mutichart layout even if not supported by a symbol #910 Marks are not requested in unstable 1.5 #909 Chart x-axis does not correctly reflect the data when market hours differ from normal #886 Position Line only visible on the top panel #880 Uncaught incorrect identifiers #871 Delete study template confirm message is not available to translate #863 Name escaped incorrectly on templates API call #855 MACD does not show all 3 lines as per the MACD theory #854 unstable: Cannot load chart with Moving Average Convergence/Divergence #853 Chart doesn't load after refreshing if saving with lock scale #852 Problem with left_toolbar disabled feature #851 XSS vulnerability in demo code #847 Delay in firing onAutoSaveNeeded #846 Loading chart with the same symbol leads to request more and more data #841 Display timezones offset #838 Fetching bars with wrong local date #837 Screenshot dialog appearing #836 Source of Moving averages + MACD #828 Unable to set some style options on studies #798 Timescale marks displayed incorrectly when zoom in/out of chart #796 Volume is recreated when scrolling chart #792 Always show the last tick on the axis #780 Snapshot dialog copy button background is not fully filled #769 True Strength Indicator only shows short length #758 Create an event for crosshair moving #735 Loading chart Layout #720 Remove symbol compare #694 Advanced settings for Moving Average #676 Limit number of studies in the chart #649 Disable timezone #647 Critical bug | Drawing Objects in the empty space in front of the chart #562 Make chart do not request external resources #421
This commit is contained in:
57
charting_library/charting_library.min.js
vendored
57
charting_library/charting_library.min.js
vendored
@@ -1,28 +1,29 @@
|
|||||||
(function(f){"function"===typeof define&&define.amd?define(["jquery"],f):f(jQuery)})(function(f){if(!f.support.cors&&f.ajaxTransport&&window.XDomainRequest){var h=/^https?:\/\//i,e=/^get|post$/i,a=new RegExp("^"+location.protocol,"i");f.ajaxTransport("* text html xml json",function(b,c,g){if(b.crossDomain&&b.async&&e.test(b.type)&&h.test(b.url)&&a.test(b.url)){var d=null;return{send:function(a,e){var g="",l=(c.dataType||"").toLowerCase();d=new XDomainRequest;/^\d+$/.test(c.timeout)&&(d.timeout=c.timeout);
|
(function(f){"function"===typeof define&&define.amd?define(["jquery"],f):f(jQuery)})(function(f){if(!f.support.cors&&f.ajaxTransport&&window.XDomainRequest){var h=/^https?:\/\//i,d=/^get|post$/i,a=new RegExp("^"+location.protocol,"i");f.ajaxTransport("* text html xml json",function(b,c,g){if(b.crossDomain&&b.async&&d.test(b.type)&&h.test(b.url)&&a.test(b.url)){var e=null;return{send:function(a,d){var g="",l=(c.dataType||"").toLowerCase();e=new XDomainRequest;/^\d+$/.test(c.timeout)&&(e.timeout=c.timeout);
|
||||||
d.ontimeout=function(){e(500,"timeout")};d.onload=function(){var a="Content-Length: "+d.responseText.length+"\r\nContent-Type: "+d.contentType,b=200,c="success",g={text:d.responseText};try{if("html"===l||/text\/html/i.test(d.contentType))g.html=d.responseText;else if("json"===l||"text"!==l&&/\/json/i.test(d.contentType))try{g.json=f.parseJSON(d.responseText)}catch(h){b=500,c="parseerror"}else if("xml"===l||"text"!==l&&/\/xml/i.test(d.contentType)){var k=new ActiveXObject("Microsoft.XMLDOM");k.async=
|
e.ontimeout=function(){d(500,"timeout")};e.onload=function(){var a="Content-Length: "+e.responseText.length+"\r\nContent-Type: "+e.contentType,b=200,c="success",g={text:e.responseText};try{if("html"===l||/text\/html/i.test(e.contentType))g.html=e.responseText;else if("json"===l||"text"!==l&&/\/json/i.test(e.contentType))try{g.json=f.parseJSON(e.responseText)}catch(h){b=500,c="parseerror"}else if("xml"===l||"text"!==l&&/\/xml/i.test(e.contentType)){var k=new ActiveXObject("Microsoft.XMLDOM");k.async=
|
||||||
!1;try{k.loadXML(d.responseText)}catch(n){k=void 0}if(!k||!k.documentElement||k.getElementsByTagName("parsererror").length)throw b=500,c="parseerror","Invalid XML: "+d.responseText;g.xml=k}}catch(m){throw m;}finally{e(b,c,g,a)}};d.onprogress=function(){};d.onerror=function(){e(500,"error",{text:d.responseText})};c.data&&(g="string"===f.type(c.data)?c.data:f.param(c.data));d.open(b.type,b.url);d.send(g)},abort:function(){d&&d.abort()}}}})}});"use strict";
|
!1;try{k.loadXML(e.responseText)}catch(n){k=void 0}if(!k||!k.documentElement||k.getElementsByTagName("parsererror").length)throw b=500,c="parseerror","Invalid XML: "+e.responseText;g.xml=k}}catch(m){throw m;}finally{d(b,c,g,a)}};e.onprogress=function(){};e.onerror=function(){d(500,"error",{text:e.responseText})};c.data&&(g="string"===f.type(c.data)?c.data:f.param(c.data));e.open(b.type,b.url);e.send(g)},abort:function(){e&&e.abort()}}}})}});"use strict";
|
||||||
function inherit(f,h){var e=function(){};e.prototype=h.prototype;f.prototype=new e;f.prototype.constructor=f;f.prototype.superclass=h}
|
function inherit(f,h){var d=function(){};d.prototype=h.prototype;f.prototype=new d;f.prototype.constructor=f;f.prototype.superclass=h}
|
||||||
(function(){function f(a){"hideSymbolSearch enabledStudies enabledDrawings disabledDrawings disabledStudies disableLogo hideSideToolbar".split(" ").map(function(b){a[b]&&console.warn("Feature `"+b+"` is obsolete. Please see the doc for details.")})}if(!window.TradingView){var h={mobile:{disabledFeatures:"left_toolbar header_widget timeframes_toolbar edit_buttons_in_legend context_menus control_bar border_around_the_chart".split(" "),enabledFeatures:["narrow_chart_enabled"]}},e={BARS:0,CANDLES:1,LINE:2,
|
(function(){function f(a){"hideSymbolSearch enabledStudies enabledDrawings disabledDrawings disabledStudies disableLogo hideSideToolbar".split(" ").map(function(b){a[b]&&console.warn("Feature `"+b+"` is obsolete. Please see the doc for details.")})}if(!window.TradingView){var h={mobile:{disabledFeatures:"left_toolbar header_widget timeframes_toolbar edit_buttons_in_legend context_menus control_bar border_around_the_chart".split(" "),enabledFeatures:["narrow_chart_enabled"]}},d={BARS:0,CANDLES:1,LINE:2,
|
||||||
AREA:3,HEIKEN_ASHI:8,HOLLOW_CANDLES:9,version:function(){return"1.4 (internal id 6adf7f18 @ 2015-12-10 20:59:31.081309)"},gEl:function(a){return document.getElementById(a)},gId:function(){return"tradingview_"+(1048576*(1+Math.random())|0).toString(16).substring(1)},onready:function(a){window.addEventListener?window.addEventListener("DOMContentLoaded",a,!1):window.attachEvent("onload",a)},css:function(a){var b=document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css";
|
AREA:3,HEIKEN_ASHI:8,HOLLOW_CANDLES:9,version:function(){return"1.5 (internal id cc8f8613 @ 2016-04-01 05:32:35.757118)"},gEl:function(a){return document.getElementById(a)},gId:function(){return"tradingview_"+(1048576*(1+Math.random())|0).toString(16).substring(1)},onready:function(a){window.addEventListener?window.addEventListener("DOMContentLoaded",a,!1):window.attachEvent("onload",a)},css:function(a){var b=document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css";
|
||||||
c.styleSheet?c.styleSheet.cssText=a:(a=document.createTextNode(a),c.appendChild(a));b.appendChild(c)},bindEvent:function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},unbindEvent:function(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c)},widget:function(a){this.id=e.gId();if(!a.datafeed)throw"Datafeed is not defined";var b={width:800,height:500,symbol:"AA",interval:"D",timezone:"",container:"",path:"",
|
c.styleSheet?c.styleSheet.cssText=a:(a=document.createTextNode(a),c.appendChild(a));b.appendChild(c)},bindEvent:function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},unbindEvent:function(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c)},widget:function(a){this.id=d.gId();if(!a.datafeed)throw"Datafeed is not defined";var b={width:800,height:500,symbol:"AA",interval:"D",timezone:"",container:"",path:"",
|
||||||
locale:"en",toolbar_bg:void 0,hideSymbolSearch:!1,hideSideToolbar:!1,enabledStudies:[],enabledDrawings:[],disabledDrawings:[],disabledStudies:[],drawingsAccess:void 0,studiesAccess:void 0,widgetbar:{datawindow:!1,details:!1,watchlist:!1,watchlist_settings:{default_symbols:[]}},overrides:{"mainSeriesProperties.showCountdown":!1},studiesOverrides:{},fullscreen:!1,autosize:!1,disabledFeatures:[],enabledFeatures:[],indicators_file_name:null,custom_css_url:null,debug:!1,time_frames:[{text:"5y",resolution:"W"},
|
locale:"en",toolbar_bg:void 0,hideSymbolSearch:!1,hideSideToolbar:!1,enabledStudies:[],enabledDrawings:[],disabledDrawings:[],disabledStudies:[],drawingsAccess:void 0,studiesAccess:void 0,widgetbar:{datawindow:!1,details:!1,watchlist:!1,watchlist_settings:{default_symbols:[]}},overrides:{"mainSeriesProperties.showCountdown":!1},studiesOverrides:{},fullscreen:!1,autosize:!1,disabledFeatures:[],enabledFeatures:[],indicators_file_name:null,custom_css_url:null,auto_save_delay:null,debug:!1,time_frames:[{text:"5y",
|
||||||
{text:"1y",resolution:"W"},{text:"6m",resolution:"120"},{text:"3m",resolution:"60"},{text:"1m",resolution:"30"},{text:"5d",resolution:"5"},{text:"1d",resolution:"1"}],client_id:"0",user_id:"0",charts_storage_url:void 0,charts_storage_api_version:"1.0",logo:{},favorites:{intervals:[],chartTypes:[]}},c={width:a.width,height:a.height,symbol:a.symbol,interval:a.interval,timezone:a.timezone,container:a.container_id,path:a.library_path,locale:a.locale,toolbar_bg:a.toolbar_bg,hideSymbolSearch:a.hide_symbol_search||
|
resolution:"W"},{text:"1y",resolution:"W"},{text:"6m",resolution:"120"},{text:"3m",resolution:"60"},{text:"1m",resolution:"30"},{text:"5d",resolution:"5"},{text:"1d",resolution:"1"}],client_id:"0",user_id:"0",charts_storage_url:void 0,charts_storage_api_version:"1.0",logo:{},favorites:{intervals:[],chartTypes:[]},rss_news_feed:null},c={width:a.width,height:a.height,symbol:a.symbol,interval:a.interval,timezone:a.timezone,container:a.container_id,path:a.library_path,locale:a.locale,toolbar_bg:a.toolbar_bg,
|
||||||
a.hideSymbolSearch,hideSideToolbar:a.hide_side_toolbar,enabledStudies:a.enabled_studies,disabledStudies:a.disabled_studies,enabledDrawings:a.enabled_drawings,disabledDrawings:a.disabled_drawings,drawingsAccess:a.drawings_access,studiesAccess:a.studies_access,widgetbar:a.widgetbar,overrides:a.overrides,studiesOverrides:a.studies_overrides,savedData:a.saved_data||a.savedData,snapshotUrl:a.snapshot_url,uid:this.id,datafeed:a.datafeed,disableLogo:a.disable_logo||a.disableLogo,logo:a.logo,autosize:a.autosize,
|
hideSymbolSearch:a.hide_symbol_search||a.hideSymbolSearch,hideSideToolbar:a.hide_side_toolbar,enabledStudies:a.enabled_studies,disabledStudies:a.disabled_studies,enabledDrawings:a.enabled_drawings,disabledDrawings:a.disabled_drawings,drawingsAccess:a.drawings_access,studiesAccess:a.studies_access,widgetbar:a.widgetbar,overrides:a.overrides,studiesOverrides:a.studies_overrides,savedData:a.saved_data||a.savedData,snapshotUrl:a.snapshot_url,uid:this.id,datafeed:a.datafeed,tradingController:a.trading_controller,
|
||||||
fullscreen:a.fullscreen,disabledFeatures:a.disabled_features,enabledFeatures:a.enabled_features,indicators_file_name:a.indicators_file_name,custom_css_url:a.custom_css_url,debug:a.debug,client_id:a.client_id,user_id:a.user_id,charts_storage_url:a.charts_storage_url,charts_storage_api_version:a.charts_storage_api_version,favorites:a.favorites,numeric_formatting:a.numeric_formatting};f(c);this.options=$.extend(!0,b,c);this.options.time_frames=a.time_frames||b.time_frames;a.preset&&(a=a.preset,h[a]?
|
disableLogo:a.disable_logo||a.disableLogo,logo:a.logo,autosize:a.autosize,fullscreen:a.fullscreen,disabledFeatures:a.disabled_features,enabledFeatures:a.enabled_features,indicators_file_name:a.indicators_file_name,custom_css_url:a.custom_css_url,auto_save_delay:a.auto_save_delay,debug:a.debug,client_id:a.client_id,user_id:a.user_id,charts_storage_url:a.charts_storage_url,charts_storage_api_version:a.charts_storage_api_version,favorites:a.favorites,numeric_formatting:a.numeric_formatting,rss_news_feed:a.rss_news_feed,
|
||||||
(a=h[a],this.options.disabledFeatures=0<this.options.disabledFeatures.length?this.options.disabledFeatures.concat(a.disabledFeatures):a.disabledFeatures,this.options.enabledFeatures=0<this.options.enabledFeatures.length?this.options.enabledFeatures.concat(a.enabledFeatures):a.enabledFeatures):console.warn("Unknown preset: `"+a+"`"));this._ready_handlers=[];this.create()}};e.widget.prototype={_innerWindow:function(){return e.gEl(this.id).contentWindow},_autoResizeChart:function(){this.options.fullscreen&&
|
studyCountLimit:a.study_count_limit,symbolSearchRequestDelay:a.symbol_search_request_delay};f(c);this.options=$.extend(!0,b,c);this.options.time_frames=a.time_frames||b.time_frames;a.preset&&(a=a.preset,h[a]?(a=h[a],this.options.disabledFeatures=0<this.options.disabledFeatures.length?this.options.disabledFeatures.concat(a.disabledFeatures):a.disabledFeatures,this.options.enabledFeatures=0<this.options.enabledFeatures.length?this.options.enabledFeatures.concat(a.enabledFeatures):a.enabledFeatures):
|
||||||
$(e.gEl(this.id)).css("height",$(window).height()+"px")},create:function(){function a(a){g.load(JSON.parse(a.content),a)}function b(){e.gEl(g.id).contentWindow.Q16.subscribe("chart_load_requested",a)}var c=this.render(),g=this,d;if(this.options.container){var f=e.gEl(this.options.container);f.innerHTML=c}else document.write(c);if(this.options.autosize||this.options.fullscreen)f=$(e.gEl(this.id)),f.css("width","100%"),this.options.fullscreen||f.css("height","100%");this._autoResizeChart();
|
console.warn("Unknown preset: `"+a+"`"));this._ready_handlers=[];this.create()}};d.widget.prototype={_innerWindow:function(){return d.gEl(this.id).contentWindow},_autoResizeChart:function(){this.options.fullscreen&&$(d.gEl(this.id)).css("height",$(window).height()+"px")},create:function(){function a(a){g.load(JSON.parse(a.content),a)}function b(){d.gEl(g.id).contentWindow.Q15.subscribe("chart_load_requested",a)}var c=this.render(),g=this,e;if(this.options.container){var f=
|
||||||
this._onWindowResize=function(a){g._autoResizeChart()};window.addEventListener("resize",this._onWindowResize);this.unsubscribeFromLoadRequestEvent=function(){e.gEl(g.id).contentWindow.Q16.unsubscribe("chart_load_requested",a)};d=e.gEl(this.id);var h=null,h=function(){e.unbindEvent(d,"load",h);d.contentWindow.widgetReady(function(){var a;g._ready=!0;for(a=g._ready_handlers.length;a--;)g._ready_handlers[a].call(g);d.contentWindow._initializationFinished();var c=e.gEl(g.id).contentWindow;
|
d.gEl(this.options.container);f.innerHTML=c}else document.write(c);if(this.options.autosize||this.options.fullscreen)f=$(d.gEl(this.id)),f.css("width","100%"),this.options.fullscreen||f.css("height","100%");this._autoResizeChart();this._onWindowResize=function(a){g._autoResizeChart()};window.addEventListener("resize",this._onWindowResize);this.unsubscribeFromLoadRequestEvent=function(){d.gEl(g.id).contentWindow.Q15.unsubscribe("chart_load_requested",a)};e=d.gEl(this.id);
|
||||||
if(c.Q16)b();else{var f=null,f=function(){b();e.unbindEvent(c,"load",f)};e.bindEvent(c,"load",f)}})};e.bindEvent(d,"load",h)},render:function(){window[this.options.uid]={datafeed:this.options.datafeed,overrides:this.options.overrides,studiesOverrides:this.options.studiesOverrides,disabledFeatures:this.options.disabledFeatures,enabledFeatures:this.options.enabledFeatures,enabledDrawings:this.options.enabledDrawings,disabledDrawings:this.options.disabledDrawings,favorites:this.options.favorites,
|
var h=null,h=function(){d.unbindEvent(e,"load",h);e.contentWindow.widgetReady(function(){var a;g._ready=!0;for(a=g._ready_handlers.length;a--;)g._ready_handlers[a].call(g);e.contentWindow._initializationFinished();var c=d.gEl(g.id).contentWindow;if(c.Q15)b();else{var f=null,f=function(){b();d.unbindEvent(c,"load",f)};d.bindEvent(c,"load",f)}})};d.bindEvent(e,"load",h)},render:function(){window[this.options.uid]={datafeed:this.options.datafeed,tradingController:this.options.tradingController,
|
||||||
logo:this.options.logo,numeric_formatting:this.options.numeric_formatting};this.options.savedData&&(window[this.options.uid].chartContent={json:this.options.savedData});var a=(this.options.path||"")+"static/tv-chart.html#localserver=1&symbol="+encodeURIComponent(this.options.symbol)+"&interval="+encodeURIComponent(this.options.interval)+(this.options.toolbar_bg?"&toolbarbg="+this.options.toolbar_bg.replace("#",""):"")+"&hideSymbolSearch="+this.options.hideSymbolSearch+"&hideSideToolbar="+this.options.hideSideToolbar+
|
overrides:this.options.overrides,studiesOverrides:this.options.studiesOverrides,disabledFeatures:this.options.disabledFeatures,enabledFeatures:this.options.enabledFeatures,enabledDrawings:this.options.enabledDrawings,disabledDrawings:this.options.disabledDrawings,favorites:this.options.favorites,logo:this.options.logo,numeric_formatting:this.options.numeric_formatting,rss_news_feed:this.options.rss_news_feed};this.options.savedData&&(window[this.options.uid].chartContent={json:this.options.savedData});
|
||||||
"&enabledStudies="+encodeURIComponent(JSON.stringify(this.options.enabledStudies))+"&disabledStudies="+encodeURIComponent(JSON.stringify(this.options.disabledStudies))+(this.options.studiesAccess?"&studiesAccess="+encodeURIComponent(JSON.stringify(this.options.studiesAccess)):"")+"&widgetbar="+encodeURIComponent(JSON.stringify(this.options.widgetbar))+(this.options.drawingsAccess?"&drawingsAccess="+encodeURIComponent(JSON.stringify(this.options.drawingsAccess)):"")+"&timeFrames="+encodeURIComponent(JSON.stringify(this.options.time_frames))+
|
var a=(this.options.path||"")+"static/tv-chart.html#localserver=1&symbol="+encodeURIComponent(this.options.symbol)+"&interval="+encodeURIComponent(this.options.interval)+(this.options.toolbar_bg?"&toolbarbg="+this.options.toolbar_bg.replace("#",""):"")+"&hideSymbolSearch="+this.options.hideSymbolSearch+"&hideSideToolbar="+this.options.hideSideToolbar+"&enabledStudies="+encodeURIComponent(JSON.stringify(this.options.enabledStudies))+"&disabledStudies="+encodeURIComponent(JSON.stringify(this.options.disabledStudies))+
|
||||||
(this.options.hasOwnProperty("disableLogo")?"&disableLogo="+encodeURIComponent(this.options.disableLogo):"")+"&locale="+encodeURIComponent(this.options.locale)+"&uid="+encodeURIComponent(this.options.uid)+"&clientId="+encodeURIComponent(this.options.client_id)+"&userId="+encodeURIComponent(this.options.user_id)+(this.options.charts_storage_url?"&chartsStorageUrl="+encodeURIComponent(this.options.charts_storage_url):"")+(this.options.charts_storage_api_version?"&chartsStorageVer="+encodeURIComponent(this.options.charts_storage_api_version):
|
(this.options.studiesAccess?"&studiesAccess="+encodeURIComponent(JSON.stringify(this.options.studiesAccess)):"")+"&widgetbar="+encodeURIComponent(JSON.stringify(this.options.widgetbar))+(this.options.drawingsAccess?"&drawingsAccess="+encodeURIComponent(JSON.stringify(this.options.drawingsAccess)):"")+"&timeFrames="+encodeURIComponent(JSON.stringify(this.options.time_frames))+(this.options.hasOwnProperty("disableLogo")?"&disableLogo="+encodeURIComponent(this.options.disableLogo):"")+"&locale="+encodeURIComponent(this.options.locale)+
|
||||||
"")+(this.options.indicators_file_name?"&indicatorsFile="+encodeURIComponent(this.options.indicators_file_name):"")+(this.options.custom_css_url?"&customCSS="+encodeURIComponent(this.options.custom_css_url):"")+"&debug="+this.options.debug+(this.options.snapshotUrl?"&snapshotUrl="+encodeURIComponent(this.options.snapshotUrl):"")+(this.options.timezone?"&timezone="+encodeURIComponent(this.options.timezone):"");return'<iframe id="'+this.id+'" name="'+this.id+'" src="'+a+'"'+(this.options.autosize||
|
"&uid="+encodeURIComponent(this.options.uid)+"&clientId="+encodeURIComponent(this.options.client_id)+"&userId="+encodeURIComponent(this.options.user_id)+(this.options.charts_storage_url?"&chartsStorageUrl="+encodeURIComponent(this.options.charts_storage_url):"")+(this.options.charts_storage_api_version?"&chartsStorageVer="+encodeURIComponent(this.options.charts_storage_api_version):"")+(this.options.indicators_file_name?"&indicatorsFile="+encodeURIComponent(this.options.indicators_file_name):"")+
|
||||||
this.options.fullscreen?"":' width="'+this.options.width+'" height="'+this.options.height+'"')+' frameborder="0" allowTransparency="true" scrolling="no" allowfullscreen style="display:block;"></iframe>'},onChartReady:function(a){this._ready?a.call(this):this._ready_handlers.push(a)},setSymbol:function(a,b,c){this._innerWindow().changeSymbol(a,b+"",c)},executeAction:function(a){this._innerWindow().executeAction(a)},executeActionById:function(a){this._innerWindow().executeActionById(a)},removeAllStudies:function(){this._innerWindow().removeAllStudies()},
|
(this.options.custom_css_url?"&customCSS="+encodeURIComponent(this.options.custom_css_url):"")+(this.options.auto_save_delay?"&autoSaveDelay="+encodeURIComponent(this.options.auto_save_delay):"")+"&debug="+this.options.debug+(this.options.snapshotUrl?"&snapshotUrl="+encodeURIComponent(this.options.snapshotUrl):"")+(this.options.timezone?"&timezone="+encodeURIComponent(this.options.timezone):"")+(this.options.studyCountLimit?"&studyCountLimit="+encodeURIComponent(this.options.studyCountLimit):"")+
|
||||||
removeAllShapes:function(){this._innerWindow().removeAllShapes()},createStudy:function(a,b,c,e,d,f){this._innerWindow().createStudy({name:a,lock:c,forceOverlay:b,inputs:e,callback:d,overrides:f})},removeEntity:function(a){this._innerWindow().removeEntity(a)},createShape:function(a,b,c){return this._innerWindow().createShape({point:a,options:b,callback:c})},createMultipointShape:function(a,b,c){return this._innerWindow().createMultipointShape({points:a,options:b,callback:c})},createVerticalLine:function(a,
|
(this.options.symbolSearchRequestDelay?"&ssreqdelay="+encodeURIComponent(this.options.symbolSearchRequestDelay):"");return'<iframe id="'+this.id+'" name="'+this.id+'" src="'+a+'"'+(this.options.autosize||this.options.fullscreen?"":' width="'+this.options.width+'" height="'+this.options.height+'"')+' frameborder="0" allowTransparency="true" scrolling="no" allowfullscreen style="display:block;"></iframe>'},onChartReady:function(a){this._ready?a.call(this):this._ready_handlers.push(a)},setSymbol:function(a,
|
||||||
b){this.createShape(a,$.extend(b,{shape:"vertical_line"}))},createOrderLine:function(a){a=a||{};return this._innerWindow().createTradingPrimitive("LineToolOrder",a.disableUndo)},createPositionLine:function(a){a=a||{};return this._innerWindow().createTradingPrimitive("LineToolPosition",a.disableUndo)},createExecutionShape:function(a){a=a||{};return this._innerWindow().createTradingPrimitive("LineToolExecution",a.disableUndo)},_widgetResizeTimer:null,createButton:function(a){var b=this;a=a||{};var c=
|
b,c){this._innerWindow().changeSymbol(a,b+"",c)},layout:function(){return this._innerWindow().layout()},setLayout:function(a){return this._innerWindow().setLayout(a)},chartsCount:function(a){return this._innerWindow().chartsCount(a)},chart:function(a){return this._innerWindow().chart(a)},activeChart:function(){return this._innerWindow().activeChart()},_widgetResizeTimer:null,createButton:function(a){var b=this;a=a||{};var c=a.align||"left";a=this._innerWindow().headerWidget;c="left"==c?a._$left:a._$right;
|
||||||
a.align||"left";a=this._innerWindow().headerWidget;c="left"==c?a._$left:a._$right;a=a.createGroup({single:!0}).appendTo(c);a=$('<div class="button"></div>').appendTo(a);this._widgetResizeTimer&&clearTimeout(this._widgetResizeTimer);this._widgetResizeTimer=setTimeout(function(){b._innerWindow().resizeWindow();clearTimeout(b._widgetResizeTimer)},5);return a},symbolInterval:function(a){var b=this._innerWindow().getSymbolInterval();a&&a(b);return b},onSymbolChange:function(a){this._innerWindow().setCallback("onSymbolChange",
|
a=a.createGroup({single:!0}).appendTo(c);a=$('<div class="button"></div>').appendTo(a);this._widgetResizeTimer&&clearTimeout(this._widgetResizeTimer);this._widgetResizeTimer=setTimeout(function(){b._innerWindow().resizeWindow();clearTimeout(b._widgetResizeTimer)},5);return a},symbolInterval:function(a){var b=this._innerWindow().getSymbolInterval();a&&a(b);return b},onSymbolChange:function(a){this._innerWindow().setCallback("onSymbolChange",a)},onIntervalChange:function(a){this._innerWindow().setCallback("onIntervalChange",
|
||||||
a)},onIntervalChange:function(a){this._innerWindow().setCallback("onIntervalChange",a)},onTick:function(a){this._innerWindow().setCallback("onTick",a)},remove:function(){window.removeEventListener("resize",this._onWindowResize);delete window[this.options.uid];var a=e.gEl(this.id);a.contentWindow.destroyChart();this.unsubscribeFromLoadRequestEvent();a.parentNode.removeChild(a)},getVisibleRange:function(a){var b=this._innerWindow().getVisibleRange();a&&a(b);return b},setVisibleRange:function(a,b){this._innerWindow().setVisibleRange(a,
|
a)},onTick:function(a){this._innerWindow().setCallback("onTick",a)},remove:function(){window.removeEventListener("resize",this._onWindowResize);delete window[this.options.uid];var a=d.gEl(this.id);a.contentWindow.destroyChart();this.unsubscribeFromLoadRequestEvent();a.parentNode.removeChild(a)},getVisibleRange:function(a){var b=this.activeChart().getVisibleRange();a&&a(b);return b},onAutoSaveNeeded:function(a){this._innerWindow().setCallback("onAutoSaveNeeded",a)},onMarkClick:function(a){this._innerWindow().setCallback("onMarkClick",
|
||||||
b)},onAutoSaveNeeded:function(a){this._innerWindow().setCallback("onAutoSaveNeeded",a)},onMarkClick:function(a){this._innerWindow().setCallback("onMarkClick",a)},onBarMarkClicked:function(a){this._innerWindow().setCallback("onMarkClick",a)},onTimescaleMarkClicked:function(a){this._innerWindow().setCallback("onTimescaleMarkClick",a)},subscribe:function(a,b){this._innerWindow().setCallback(a,b)},onScreenshotReady:function(a){this._innerWindow().setCallback("onScreenshotReady",a)},onContextMenu:function(a){this._innerWindow().Q16.subscribe("onContextMenu",
|
a)},onBarMarkClicked:function(a){this._innerWindow().setCallback("onMarkClick",a)},onTimescaleMarkClicked:function(a){this._innerWindow().setCallback("onTimescaleMarkClick",a)},subscribe:function(a,b){this._innerWindow().setCallback(a,b)},onScreenshotReady:function(a){this._innerWindow().setCallback("onScreenshotReady",a)},onContextMenu:function(a){this._innerWindow().Q15.subscribe("onContextMenu",function(b){b.callback(a(b.unixtime,b.price))})},onShortcut:function(a,b){this._innerWindow().createShortcutAction(a,
|
||||||
function(b){b.callback(a(b.unixtime,b.price))})},onShortcut:function(a,b){this._innerWindow().createShortcutAction(a,b)},onGrayedObjectClicked:function(a){this._innerWindow().Q16.subscribe("onGrayedObjectClicked",a)},refreshMarks:function(){this._innerWindow().refreshMarks()},closePopupsAndDialogs:function(){this._innerWindow().closePopupsAndDialogs()},clearMarks:function(){this._innerWindow().clearMarks()},setChartType:function(a){this._innerWindow().setChartType(a)},
|
b)},onGrayedObjectClicked:function(a){this._innerWindow().Q15.subscribe("onGrayedObjectClicked",a)},closePopupsAndDialogs:function(){this._innerWindow().closePopupsAndDialogs()},applyOverrides:function(a){this.options=$.extend(!0,this.options,{overrides:a});this._innerWindow().applyOverrides(a)},createStudyTemplate:function(a,b){var c=this.activeChart().createStudyTemplate(a);b&&b(c);return c},addCustomCSSFile:function(a){this._innerWindow().addCustomCSSFile(a)},save:function(a){this._innerWindow().saveChart(a)},
|
||||||
createStudyTemplate:function(a,b){var c=this._innerWindow().createStudyTemplate(a);b&&b(c);return c},applyStudyTemplate:function(a){this._innerWindow().applyStudyTemplate(a)},addCustomCSSFile:function(a){this._innerWindow().addCustomCSSFile(a)},save:function(a){this._innerWindow().saveChart(a)},load:function(a,b){this._innerWindow().loadChart({json:a,extendedData:b})},setLanguage:function(a){this.remove();this.options.locale=a;this.create()}};window.TradingView&&jQuery?jQuery.extend(window.TradingView,
|
load:function(a,b){this._innerWindow().loadChart({json:a,extendedData:b})},setLanguage:function(a){this.remove();this.options.locale=a;this.create()},isFloatingTradingPanelVisible:function(){return this._innerWindow().isFloatingTradingPanelVisible()},toggleFloatingTradingPanel:function(){this._innerWindow().toggleFloatingTradingPanel()},isBottomTradingPanelVisible:function(){return this._innerWindow().isBottomTradingPanelVisible()},toggleBottomTradingPanel:function(){this._innerWindow().toggleBottomTradingPanel()},
|
||||||
e):window.TradingView=e}})();
|
showSampleOrderDialog:function(a){return this._innerWindow().showSampleOrderDialog(a)},showSamplePositionDialog:function(a){return this._innerWindow().showSamplePositionDialog(a)},showSampleClosePositionDialog:function(a){return this._innerWindow().showSampleClosePositionDialog(a)},showSampleReversePositionDialog:function(a){return this._innerWindow().showSampleReversePositionDialog(a)},mainSeriesPriceFormatter:function(){return this._innerWindow().mainSeriesPriceFormatter()}};"applyStudyTemplate setChartType clearMarks refreshMarks setVisibleRange createOrderLine createPositionLine createExecutionShape createVerticalLine createMultipointShape createShape removeEntity createStudy removeAllShapes removeAllStudies executeActionById executeAction".split(" ").forEach(function(a){d.widget.prototype[a]=
|
||||||
|
function(){console.warn("Method `"+a+"` is obsolete. Please use `chart()."+a+"` instead.");return this.activeChart()[a].apply(this.activeChart(),arguments)}});window.TradingView&&jQuery?jQuery.extend(window.TradingView,d):window.TradingView=d}})();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"use strict";
|
'use strict';
|
||||||
/*
|
/*
|
||||||
This class implements interaction with UDF-compatible datafeed.
|
This class implements interaction with UDF-compatible datafeed.
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype.defaultConfiguration = function() {
|
|||||||
return {
|
return {
|
||||||
supports_search: false,
|
supports_search: false,
|
||||||
supports_group_request: true,
|
supports_group_request: true,
|
||||||
supported_resolutions: ["1", "5", "15", "30", "60", "1D", "1W", "1M"],
|
supported_resolutions: ['1', '5', '15', '30', '60', '1D', '1W', '1M'],
|
||||||
supports_marks: false,
|
supports_marks: false,
|
||||||
supports_timescale_marks: false
|
supports_timescale_marks: false
|
||||||
};
|
};
|
||||||
@@ -38,7 +38,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype.defaultConfiguration = function() {
|
|||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.getServerTime = function(callback) {
|
Datafeeds.UDFCompatibleDatafeed.prototype.getServerTime = function(callback) {
|
||||||
if (this._configuration.supports_time) {
|
if (this._configuration.supports_time) {
|
||||||
this._send(this._datafeedURL + "/time", {})
|
this._send(this._datafeedURL + '/time', {})
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
callback(+response);
|
callback(+response);
|
||||||
})
|
})
|
||||||
@@ -58,43 +58,40 @@ Datafeeds.UDFCompatibleDatafeed.prototype.on = function (event, callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype._fireEvent = function(event, argument) {
|
Datafeeds.UDFCompatibleDatafeed.prototype._fireEvent = function(event, argument) {
|
||||||
if (this._callbacks.hasOwnProperty(event)) {
|
if (this._callbacks.hasOwnProperty(event)) {
|
||||||
var callbacksChain = this._callbacks[event];
|
var callbacksChain = this._callbacks[event];
|
||||||
for (var i = 0; i < callbacksChain.length; ++i) {
|
for (var i = 0; i < callbacksChain.length; ++i) {
|
||||||
callbacksChain[i](argument);
|
callbacksChain[i](argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._callbacks[event] = [];
|
this._callbacks[event] = [];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.onInitialized = function() {
|
Datafeeds.UDFCompatibleDatafeed.prototype.onInitialized = function() {
|
||||||
this._initializationFinished = true;
|
this._initializationFinished = true;
|
||||||
this._fireEvent("initialized");
|
this._fireEvent('initialized');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype._logMessage = function(message) {
|
Datafeeds.UDFCompatibleDatafeed.prototype._logMessage = function(message) {
|
||||||
if (this._enableLogging) {
|
if (this._enableLogging) {
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
console.log(now.toLocaleTimeString() + "." + now.getMilliseconds() + "> " + message);
|
console.log(now.toLocaleTimeString() + '.' + now.getMilliseconds() + '> ' + message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype._send = function(url, params) {
|
Datafeeds.UDFCompatibleDatafeed.prototype._send = function(url, params) {
|
||||||
var request = url;
|
var request = url;
|
||||||
if (params) {
|
if (params) {
|
||||||
for (var i = 0; i < Object.keys(params).length; ++i) {
|
for (var i = 0; i < Object.keys(params).length; ++i) {
|
||||||
var key = Object.keys(params)[i];
|
var key = Object.keys(params)[i];
|
||||||
var value = encodeURIComponent(params[key]);
|
var value = encodeURIComponent(params[key]);
|
||||||
request += (i === 0 ? "?" : "&") + key + "=" + value;
|
request += (i === 0 ? '?' : '&') + key + '=' + value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._logMessage("New request: " + request);
|
this._logMessage('New request: ' + request);
|
||||||
|
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
@@ -107,7 +104,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype._initialize = function() {
|
|||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
this._send(this._datafeedURL + "/config")
|
this._send(this._datafeedURL + '/config')
|
||||||
.done(function(response) {
|
.done(function(response) {
|
||||||
var configurationData = JSON.parse(response);
|
var configurationData = JSON.parse(response);
|
||||||
that._setupWithConfiguration(configurationData);
|
that._setupWithConfiguration(configurationData);
|
||||||
@@ -117,15 +114,14 @@ Datafeeds.UDFCompatibleDatafeed.prototype._initialize = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.onReady = function(callback) {
|
Datafeeds.UDFCompatibleDatafeed.prototype.onReady = function(callback) {
|
||||||
|
var that = this;
|
||||||
if (this._configuration) {
|
if (this._configuration) {
|
||||||
callback(this._configuration);
|
setTimeout(function() {
|
||||||
}
|
callback(that._configuration);
|
||||||
else {
|
}, 0);
|
||||||
var that = this;
|
} else {
|
||||||
this.on("configuration_ready", function() {
|
this.on('configuration_ready', function() {
|
||||||
callback(that._configuration);
|
callback(that._configuration);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -147,7 +143,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype._setupWithConfiguration = function(con
|
|||||||
configurationData.symbols_types = symbolsTypes;
|
configurationData.symbols_types = symbolsTypes;
|
||||||
|
|
||||||
if (!configurationData.supports_search && !configurationData.supports_group_request) {
|
if (!configurationData.supports_search && !configurationData.supports_group_request) {
|
||||||
throw "Unsupported datafeed configuration. Must either support search, or support group request";
|
throw 'Unsupported datafeed configuration. Must either support search, or support group request';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!configurationData.supports_search) {
|
if (!configurationData.supports_search) {
|
||||||
@@ -157,24 +153,22 @@ Datafeeds.UDFCompatibleDatafeed.prototype._setupWithConfiguration = function(con
|
|||||||
if (configurationData.supports_group_request) {
|
if (configurationData.supports_group_request) {
|
||||||
// this component will call onInitialized() by itself
|
// this component will call onInitialized() by itself
|
||||||
this._symbolsStorage = new Datafeeds.SymbolsStorage(this);
|
this._symbolsStorage = new Datafeeds.SymbolsStorage(this);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.onInitialized();
|
this.onInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._fireEvent("configuration_ready");
|
this._fireEvent('configuration_ready');
|
||||||
this._logMessage("Initialized with " + JSON.stringify(configurationData));
|
this._logMessage('Initialized with ' + JSON.stringify(configurationData));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ===============================================================================================================================
|
// ===============================================================================================================================
|
||||||
// The functions set below is the implementation of JavaScript API.
|
// The functions set below is the implementation of JavaScript API.
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.getMarks = function (symbolInfo, rangeStart, rangeEnd, onDataCallback, resolution) {
|
Datafeeds.UDFCompatibleDatafeed.prototype.getMarks = function (symbolInfo, rangeStart, rangeEnd, onDataCallback, resolution) {
|
||||||
if (this._configuration.supports_marks) {
|
if (this._configuration.supports_marks) {
|
||||||
this._send(this._datafeedURL + "/marks", {
|
this._send(this._datafeedURL + '/marks', {
|
||||||
symbol: symbolInfo.ticker.toUpperCase(),
|
symbol: symbolInfo.ticker.toUpperCase(),
|
||||||
from : rangeStart,
|
from: rangeStart,
|
||||||
to: rangeEnd,
|
to: rangeEnd,
|
||||||
resolution: resolution
|
resolution: resolution
|
||||||
})
|
})
|
||||||
@@ -189,9 +183,9 @@ Datafeeds.UDFCompatibleDatafeed.prototype.getMarks = function (symbolInfo, range
|
|||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.getTimescaleMarks = function (symbolInfo, rangeStart, rangeEnd, onDataCallback, resolution) {
|
Datafeeds.UDFCompatibleDatafeed.prototype.getTimescaleMarks = function (symbolInfo, rangeStart, rangeEnd, onDataCallback, resolution) {
|
||||||
if (this._configuration.supports_timescale_marks) {
|
if (this._configuration.supports_timescale_marks) {
|
||||||
this._send(this._datafeedURL + "/timescale_marks", {
|
this._send(this._datafeedURL + '/timescale_marks', {
|
||||||
symbol: symbolInfo.ticker.toUpperCase(),
|
symbol: symbolInfo.ticker.toUpperCase(),
|
||||||
from : rangeStart,
|
from: rangeStart,
|
||||||
to: rangeEnd,
|
to: rangeEnd,
|
||||||
resolution: resolution
|
resolution: resolution
|
||||||
})
|
})
|
||||||
@@ -204,7 +198,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype.getTimescaleMarks = function (symbolIn
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.searchSymbolsByName = function(ticker, exchange, type, onResultReadyCallback) {
|
Datafeeds.UDFCompatibleDatafeed.prototype.searchSymbols = function(searchString, exchange, type, onResultReadyCallback) {
|
||||||
var MAX_SEARCH_RESULTS = 30;
|
var MAX_SEARCH_RESULTS = 30;
|
||||||
|
|
||||||
if (!this._configuration) {
|
if (!this._configuration) {
|
||||||
@@ -214,9 +208,9 @@ Datafeeds.UDFCompatibleDatafeed.prototype.searchSymbolsByName = function(ticker,
|
|||||||
|
|
||||||
if (this._configuration.supports_search) {
|
if (this._configuration.supports_search) {
|
||||||
|
|
||||||
this._send(this._datafeedURL + "/search", {
|
this._send(this._datafeedURL + '/search', {
|
||||||
limit: MAX_SEARCH_RESULTS,
|
limit: MAX_SEARCH_RESULTS,
|
||||||
query: ticker.toUpperCase(),
|
query: searchString.toUpperCase(),
|
||||||
type: type,
|
type: type,
|
||||||
exchange: exchange
|
exchange: exchange
|
||||||
})
|
})
|
||||||
@@ -229,10 +223,9 @@ Datafeeds.UDFCompatibleDatafeed.prototype.searchSymbolsByName = function(ticker,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof data.s == "undefined" || data.s != "error") {
|
if (typeof data.s == 'undefined' || data.s != 'error') {
|
||||||
onResultReadyCallback(data);
|
onResultReadyCallback(data);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
onResultReadyCallback([]);
|
onResultReadyCallback([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,37 +233,33 @@ Datafeeds.UDFCompatibleDatafeed.prototype.searchSymbolsByName = function(ticker,
|
|||||||
.fail(function(reason) {
|
.fail(function(reason) {
|
||||||
onResultReadyCallback([]);
|
onResultReadyCallback([]);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
if (!this._symbolSearch) {
|
if (!this._symbolSearch) {
|
||||||
throw "Datafeed error: inconsistent configuration (symbol search)";
|
throw 'Datafeed error: inconsistent configuration (symbol search)';
|
||||||
}
|
}
|
||||||
|
|
||||||
var searchArgument = {
|
var searchArgument = {
|
||||||
ticker: ticker,
|
searchString: searchString,
|
||||||
exchange: exchange,
|
exchange: exchange,
|
||||||
type: type,
|
type: type,
|
||||||
onResultReadyCallback: onResultReadyCallback
|
onResultReadyCallback: onResultReadyCallback
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this._initializationFinished) {
|
if (this._initializationFinished) {
|
||||||
this._symbolSearch.searchSymbolsByName(searchArgument, MAX_SEARCH_RESULTS);
|
this._symbolSearch.searchSymbols(searchArgument, MAX_SEARCH_RESULTS);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
this.on("initialized", function() {
|
this.on('initialized', function() {
|
||||||
that._symbolSearch.searchSymbolsByName(searchArgument, MAX_SEARCH_RESULTS);
|
that._symbolSearch.searchSymbols(searchArgument, MAX_SEARCH_RESULTS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Datafeeds.UDFCompatibleDatafeed.prototype._symbolResolveURL = '/symbols';
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype._symbolResolveURL = "/symbols";
|
|
||||||
|
|
||||||
|
|
||||||
// BEWARE: this function does not consider symbol's exchange
|
// BEWARE: this function does not consider symbol's exchange
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.resolveSymbol = function(symbolName, onSymbolResolvedCallback, onResolveErrorCallback) {
|
Datafeeds.UDFCompatibleDatafeed.prototype.resolveSymbol = function(symbolName, onSymbolResolvedCallback, onResolveErrorCallback) {
|
||||||
@@ -278,7 +267,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype.resolveSymbol = function(symbolName, o
|
|||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
if (!this._initializationFinished) {
|
if (!this._initializationFinished) {
|
||||||
this.on("initialized", function() {
|
this.on('initialized', function() {
|
||||||
that.resolveSymbol(symbolName, onSymbolResolvedCallback, onResolveErrorCallback);
|
that.resolveSymbol(symbolName, onSymbolResolvedCallback, onResolveErrorCallback);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -286,7 +275,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype.resolveSymbol = function(symbolName, o
|
|||||||
}
|
}
|
||||||
|
|
||||||
var resolveRequestStartTime = Date.now();
|
var resolveRequestStartTime = Date.now();
|
||||||
that._logMessage("Resolve requested");
|
that._logMessage('Resolve requested');
|
||||||
|
|
||||||
function onResultReady(data) {
|
function onResultReady(data) {
|
||||||
var postProcessedData = data;
|
var postProcessedData = data;
|
||||||
@@ -294,50 +283,46 @@ Datafeeds.UDFCompatibleDatafeed.prototype.resolveSymbol = function(symbolName, o
|
|||||||
postProcessedData = that.postProcessSymbolInfo(postProcessedData);
|
postProcessedData = that.postProcessSymbolInfo(postProcessedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
that._logMessage("Symbol resolved: " + (Date.now() - resolveRequestStartTime));
|
that._logMessage('Symbol resolved: ' + (Date.now() - resolveRequestStartTime));
|
||||||
|
|
||||||
onSymbolResolvedCallback(postProcessedData);
|
onSymbolResolvedCallback(postProcessedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._configuration.supports_group_request) {
|
if (!this._configuration.supports_group_request) {
|
||||||
this._send(this._datafeedURL + this._symbolResolveURL, {
|
this._send(this._datafeedURL + this._symbolResolveURL, {
|
||||||
symbol: symbolName ? symbolName.toUpperCase() : ""
|
symbol: symbolName ? symbolName.toUpperCase() : ''
|
||||||
})
|
})
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
var data = JSON.parse(response);
|
var data = JSON.parse(response);
|
||||||
|
|
||||||
if (data.s && data.s != "ok") {
|
if (data.s && data.s != 'ok') {
|
||||||
onResolveErrorCallback("unknown_symbol");
|
onResolveErrorCallback('unknown_symbol');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
onResultReady(data);
|
onResultReady(data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(reason) {
|
.fail(function(reason) {
|
||||||
that._logMessage("Error resolving symbol: " + JSON.stringify([reason]));
|
that._logMessage('Error resolving symbol: ' + JSON.stringify([reason]));
|
||||||
onResolveErrorCallback("unknown_symbol");
|
onResolveErrorCallback('unknown_symbol');
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (this._initializationFinished) {
|
if (this._initializationFinished) {
|
||||||
this._symbolsStorage.resolveSymbol(symbolName, onResultReady, onResolveErrorCallback);
|
this._symbolsStorage.resolveSymbol(symbolName, onResultReady, onResolveErrorCallback);
|
||||||
}
|
} else {
|
||||||
else {
|
this.on('initialized', function() {
|
||||||
this.on("initialized", function() {
|
|
||||||
that._symbolsStorage.resolveSymbol(symbolName, onResultReady, onResolveErrorCallback);
|
that._symbolsStorage.resolveSymbol(symbolName, onResultReady, onResolveErrorCallback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Datafeeds.UDFCompatibleDatafeed.prototype._historyURL = '/history';
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype._historyURL = "/history";
|
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.getBars = function(symbolInfo, resolution, rangeStartDate, rangeEndDate, onDataCallback, onErrorCallback) {
|
Datafeeds.UDFCompatibleDatafeed.prototype.getBars = function(symbolInfo, resolution, rangeStartDate, rangeEndDate, onDataCallback, onErrorCallback) {
|
||||||
|
|
||||||
// timestamp sample: 1399939200
|
// timestamp sample: 1399939200
|
||||||
if (rangeStartDate > 0 && (rangeStartDate + "").length > 10) {
|
if (rangeStartDate > 0 && (rangeStartDate + '').length > 10) {
|
||||||
throw ["Got a JS time instead of Unix one.", rangeStartDate, rangeEndDate];
|
throw ['Got a JS time instead of Unix one.', rangeStartDate, rangeEndDate];
|
||||||
}
|
}
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
@@ -345,21 +330,22 @@ Datafeeds.UDFCompatibleDatafeed.prototype.getBars = function(symbolInfo, resolut
|
|||||||
var requestStartTime = Date.now();
|
var requestStartTime = Date.now();
|
||||||
|
|
||||||
this._send(this._datafeedURL + this._historyURL, {
|
this._send(this._datafeedURL + this._historyURL, {
|
||||||
symbol: symbolInfo.ticker.toUpperCase(),
|
symbol: symbolInfo.ticker.toUpperCase(),
|
||||||
resolution: resolution,
|
resolution: resolution,
|
||||||
from: rangeStartDate,
|
from: rangeStartDate,
|
||||||
to: rangeEndDate
|
to: rangeEndDate
|
||||||
})
|
})
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
|
|
||||||
var data = JSON.parse(response);
|
var data = JSON.parse(response);
|
||||||
|
|
||||||
var nodata = data.s == "no_data";
|
var nodata = data.s == 'no_data';
|
||||||
|
|
||||||
if (data.s != "ok" && !nodata) {
|
if (data.s != 'ok' && !nodata) {
|
||||||
if (!!onErrorCallback) {
|
if (!!onErrorCallback) {
|
||||||
onErrorCallback(data.s);
|
onErrorCallback(data.s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,8 +355,8 @@ Datafeeds.UDFCompatibleDatafeed.prototype.getBars = function(symbolInfo, resolut
|
|||||||
// v: [volumes], t: [times], o: [opens], h: [highs], l: [lows], c:[closes], nb: "optional_unixtime_if_no_data"}
|
// v: [volumes], t: [times], o: [opens], h: [highs], l: [lows], c:[closes], nb: "optional_unixtime_if_no_data"}
|
||||||
var barsCount = nodata ? 0 : data.t.length;
|
var barsCount = nodata ? 0 : data.t.length;
|
||||||
|
|
||||||
var volumePresent = typeof data.v != "undefined";
|
var volumePresent = typeof data.v != 'undefined';
|
||||||
var ohlPresent = typeof data.o != "undefined";
|
var ohlPresent = typeof data.o != 'undefined';
|
||||||
|
|
||||||
for (var i = 0; i < barsCount; ++i) {
|
for (var i = 0; i < barsCount; ++i) {
|
||||||
|
|
||||||
@@ -383,8 +369,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype.getBars = function(symbolInfo, resolut
|
|||||||
barValue.open = data.o[i];
|
barValue.open = data.o[i];
|
||||||
barValue.high = data.h[i];
|
barValue.high = data.h[i];
|
||||||
barValue.low = data.l[i];
|
barValue.low = data.l[i];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
barValue.open = barValue.high = barValue.low = barValue.close;
|
barValue.open = barValue.high = barValue.low = barValue.close;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,15 +383,14 @@ Datafeeds.UDFCompatibleDatafeed.prototype.getBars = function(symbolInfo, resolut
|
|||||||
onDataCallback(bars, {version: that._protocolVersion, noData: nodata, nextTime: data.nb || data.nextTime});
|
onDataCallback(bars, {version: that._protocolVersion, noData: nodata, nextTime: data.nb || data.nextTime});
|
||||||
})
|
})
|
||||||
.fail(function (arg) {
|
.fail(function (arg) {
|
||||||
console.warn(["getBars(): HTTP error", arg]);
|
console.warn(['getBars(): HTTP error', arg]);
|
||||||
|
|
||||||
if (!!onErrorCallback) {
|
if (!!onErrorCallback) {
|
||||||
onErrorCallback("network error: " + JSON.stringify(arg));
|
onErrorCallback('network error: ' + JSON.stringify(arg));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.subscribeBars = function(symbolInfo, resolution, onRealtimeCallback, listenerGUID) {
|
Datafeeds.UDFCompatibleDatafeed.prototype.subscribeBars = function(symbolInfo, resolution, onRealtimeCallback, listenerGUID) {
|
||||||
this._barsPulseUpdater.subscribeDataListener(symbolInfo, resolution, onRealtimeCallback, listenerGUID);
|
this._barsPulseUpdater.subscribeDataListener(symbolInfo, resolution, onRealtimeCallback, listenerGUID);
|
||||||
};
|
};
|
||||||
@@ -419,10 +403,10 @@ Datafeeds.UDFCompatibleDatafeed.prototype.calculateHistoryDepth = function(perio
|
|||||||
};
|
};
|
||||||
|
|
||||||
Datafeeds.UDFCompatibleDatafeed.prototype.getQuotes = function(symbols, onDataCallback, onErrorCallback) {
|
Datafeeds.UDFCompatibleDatafeed.prototype.getQuotes = function(symbols, onDataCallback, onErrorCallback) {
|
||||||
this._send(this._datafeedURL + "/quotes", { symbols: symbols })
|
this._send(this._datafeedURL + '/quotes', { symbols: symbols })
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
var data = JSON.parse(response);
|
var data = JSON.parse(response);
|
||||||
if (data.s == "ok") {
|
if (data.s == 'ok') {
|
||||||
// JSON format is {s: "status", [{s: "symbol_status", n: "symbol_name", v: {"field1": "value1", "field2": "value2", ..., "fieldN": "valueN"}}]}
|
// JSON format is {s: "status", [{s: "symbol_status", n: "symbol_name", v: {"field1": "value1", "field2": "value2", ..., "fieldN": "valueN"}}]}
|
||||||
if (onDataCallback) {
|
if (onDataCallback) {
|
||||||
onDataCallback(data.d);
|
onDataCallback(data.d);
|
||||||
@@ -435,7 +419,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype.getQuotes = function(symbols, onDataCa
|
|||||||
})
|
})
|
||||||
.fail(function (arg) {
|
.fail(function (arg) {
|
||||||
if (onErrorCallback) {
|
if (onErrorCallback) {
|
||||||
onErrorCallback("network error: " + arg);
|
onErrorCallback('network error: ' + arg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -460,7 +444,7 @@ Datafeeds.UDFCompatibleDatafeed.prototype.unsubscribeQuotes = function(listenerG
|
|||||||
Datafeeds.SymbolsStorage = function(datafeed) {
|
Datafeeds.SymbolsStorage = function(datafeed) {
|
||||||
this._datafeed = datafeed;
|
this._datafeed = datafeed;
|
||||||
|
|
||||||
this._exchangesList = ["NYSE", "FOREX", "AMEX"];
|
this._exchangesList = ['NYSE', 'FOREX', 'AMEX'];
|
||||||
this._exchangesWaitingForData = {};
|
this._exchangesWaitingForData = {};
|
||||||
this._exchangesDataCache = {};
|
this._exchangesDataCache = {};
|
||||||
|
|
||||||
@@ -470,8 +454,6 @@ Datafeeds.SymbolsStorage = function(datafeed) {
|
|||||||
this._requestFullSymbolsList();
|
this._requestFullSymbolsList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.SymbolsStorage.prototype._requestFullSymbolsList = function() {
|
Datafeeds.SymbolsStorage.prototype._requestFullSymbolsList = function() {
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
@@ -487,9 +469,9 @@ Datafeeds.SymbolsStorage.prototype._requestFullSymbolsList = function() {
|
|||||||
|
|
||||||
this._exchangesDataCache[exchange] = true;
|
this._exchangesDataCache[exchange] = true;
|
||||||
|
|
||||||
this._exchangesWaitingForData[exchange] = "waiting_for_data";
|
this._exchangesWaitingForData[exchange] = 'waiting_for_data';
|
||||||
|
|
||||||
this._datafeed._send(this._datafeed._datafeedURL + "/symbol_info", {
|
this._datafeed._send(this._datafeed._datafeedURL + '/symbol_info', {
|
||||||
group: exchange
|
group: exchange
|
||||||
})
|
})
|
||||||
.done(function(exchange) {
|
.done(function(exchange) {
|
||||||
@@ -506,8 +488,6 @@ Datafeeds.SymbolsStorage.prototype._requestFullSymbolsList = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.SymbolsStorage.prototype._onExchangeDataReceived = function(exchangeName, data) {
|
Datafeeds.SymbolsStorage.prototype._onExchangeDataReceived = function(exchangeName, data) {
|
||||||
|
|
||||||
function tableField(data, name, index) {
|
function tableField(data, name, index) {
|
||||||
@@ -521,44 +501,44 @@ Datafeeds.SymbolsStorage.prototype._onExchangeDataReceived = function(exchangeNa
|
|||||||
for (var symbolIndex = 0; symbolIndex < data.symbol.length; ++symbolIndex) {
|
for (var symbolIndex = 0; symbolIndex < data.symbol.length; ++symbolIndex) {
|
||||||
|
|
||||||
var symbolName = data.symbol[symbolIndex];
|
var symbolName = data.symbol[symbolIndex];
|
||||||
var listedExchange = tableField(data, "exchange-listed", symbolIndex);
|
var listedExchange = tableField(data, 'exchange-listed', symbolIndex);
|
||||||
var tradedExchange = tableField(data, "exchange-traded", symbolIndex);
|
var tradedExchange = tableField(data, 'exchange-traded', symbolIndex);
|
||||||
var fullName = tradedExchange + ":" + symbolName;
|
var fullName = tradedExchange + ':' + symbolName;
|
||||||
|
|
||||||
// This feature support is not implemented yet
|
// This feature support is not implemented yet
|
||||||
// var hasDWM = tableField(data, "has-dwm", symbolIndex);
|
// var hasDWM = tableField(data, "has-dwm", symbolIndex);
|
||||||
|
|
||||||
var hasIntraday = tableField(data, "has-intraday", symbolIndex);
|
var hasIntraday = tableField(data, 'has-intraday', symbolIndex);
|
||||||
|
|
||||||
var tickerPresent = typeof data.ticker != "undefined";
|
var tickerPresent = typeof data.ticker != 'undefined';
|
||||||
|
|
||||||
var symbolInfo = {
|
var symbolInfo = {
|
||||||
name: symbolName,
|
name: symbolName,
|
||||||
base_name: [listedExchange + ":" + symbolName],
|
base_name: [listedExchange + ':' + symbolName],
|
||||||
description: tableField(data, "description", symbolIndex),
|
description: tableField(data, 'description', symbolIndex),
|
||||||
full_name: fullName,
|
full_name: fullName,
|
||||||
legs: [fullName],
|
legs: [fullName],
|
||||||
has_intraday: hasIntraday,
|
has_intraday: hasIntraday,
|
||||||
has_no_volume: tableField(data, "has-no-volume", symbolIndex),
|
has_no_volume: tableField(data, 'has-no-volume', symbolIndex),
|
||||||
listed_exchange: listedExchange,
|
listed_exchange: listedExchange,
|
||||||
exchange: tradedExchange,
|
exchange: tradedExchange,
|
||||||
minmov: tableField(data, "minmovement", symbolIndex) || tableField(data, "minmov", symbolIndex) ,
|
minmov: tableField(data, 'minmovement', symbolIndex) || tableField(data, 'minmov', symbolIndex),
|
||||||
minmove2: tableField(data, "minmove2", symbolIndex) || tableField(data, "minmov2", symbolIndex) ,
|
minmove2: tableField(data, 'minmove2', symbolIndex) || tableField(data, 'minmov2', symbolIndex),
|
||||||
fractional: tableField(data, "fractional", symbolIndex),
|
fractional: tableField(data, 'fractional', symbolIndex),
|
||||||
pointvalue: tableField(data, "pointvalue", symbolIndex),
|
pointvalue: tableField(data, 'pointvalue', symbolIndex),
|
||||||
pricescale: tableField(data, "pricescale", symbolIndex),
|
pricescale: tableField(data, 'pricescale', symbolIndex),
|
||||||
type: tableField(data, "type", symbolIndex),
|
type: tableField(data, 'type', symbolIndex),
|
||||||
session: tableField(data, "session-regular", symbolIndex),
|
session: tableField(data, 'session-regular', symbolIndex),
|
||||||
ticker: tickerPresent ? tableField(data, "ticker", symbolIndex) : symbolName,
|
ticker: tickerPresent ? tableField(data, 'ticker', symbolIndex) : symbolName,
|
||||||
timezone: tableField(data, "timezone", symbolIndex),
|
timezone: tableField(data, 'timezone', symbolIndex),
|
||||||
supported_resolutions: tableField(data, "supported-resolutions", symbolIndex) || this._datafeed.defaultConfiguration().supported_resolutions,
|
supported_resolutions: tableField(data, 'supported-resolutions', symbolIndex) || this._datafeed.defaultConfiguration().supported_resolutions,
|
||||||
force_session_rebuild: tableField(data, "force-session-rebuild", symbolIndex) || false,
|
force_session_rebuild: tableField(data, 'force-session-rebuild', symbolIndex) || false,
|
||||||
has_daily: tableField(data, "has-daily", symbolIndex) || true,
|
has_daily: tableField(data, 'has-daily', symbolIndex) || true,
|
||||||
intraday_multipliers: tableField(data, "intraday-multipliers", symbolIndex) || ["1", "5", "15", "30", "60"],
|
intraday_multipliers: tableField(data, 'intraday-multipliers', symbolIndex) || ['1', '5', '15', '30', '60'],
|
||||||
has_fractional_volume: tableField(data, "has-fractional-volume", symbolIndex) || false,
|
has_fractional_volume: tableField(data, 'has-fractional-volume', symbolIndex) || false,
|
||||||
has_weekly_and_monthly: tableField(data, "has-weekly-and-monthly", symbolIndex) || false,
|
has_weekly_and_monthly: tableField(data, 'has-weekly-and-monthly', symbolIndex) || false,
|
||||||
has_empty_bars: tableField(data, "has-empty-bars", symbolIndex) || false,
|
has_empty_bars: tableField(data, 'has-empty-bars', symbolIndex) || false,
|
||||||
volume_precision: tableField(data, "volume-precision", symbolIndex) || 0
|
volume_precision: tableField(data, 'volume-precision', symbolIndex) || 0
|
||||||
};
|
};
|
||||||
|
|
||||||
this._symbolsInfo[symbolInfo.ticker] = this._symbolsInfo[symbolName] = this._symbolsInfo[fullName] = symbolInfo;
|
this._symbolsInfo[symbolInfo.ticker] = this._symbolsInfo[symbolName] = this._symbolsInfo[fullName] = symbolInfo;
|
||||||
@@ -566,11 +546,10 @@ Datafeeds.SymbolsStorage.prototype._onExchangeDataReceived = function(exchangeNa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw "API error when processing exchange `" + exchangeName + "` symbol #" + symbolIndex + ": " + error;
|
throw 'API error when processing exchange `' + exchangeName + '` symbol #' + symbolIndex + ': ' + error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.SymbolsStorage.prototype._onAnyExchangeResponseReceived = function(exchangeName) {
|
Datafeeds.SymbolsStorage.prototype._onAnyExchangeResponseReceived = function(exchangeName) {
|
||||||
|
|
||||||
delete this._exchangesWaitingForData[exchangeName];
|
delete this._exchangesWaitingForData[exchangeName];
|
||||||
@@ -579,25 +558,24 @@ Datafeeds.SymbolsStorage.prototype._onAnyExchangeResponseReceived = function(exc
|
|||||||
|
|
||||||
if (allDataReady) {
|
if (allDataReady) {
|
||||||
this._symbolsList.sort();
|
this._symbolsList.sort();
|
||||||
this._datafeed._logMessage("All exchanges data ready");
|
this._datafeed._logMessage('All exchanges data ready');
|
||||||
this._datafeed.onInitialized();
|
this._datafeed.onInitialized();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// BEWARE: this function does not consider symbol's exchange
|
// BEWARE: this function does not consider symbol's exchange
|
||||||
Datafeeds.SymbolsStorage.prototype.resolveSymbol = function(symbolName, onSymbolResolvedCallback, onResolveErrorCallback) {
|
Datafeeds.SymbolsStorage.prototype.resolveSymbol = function(symbolName, onSymbolResolvedCallback, onResolveErrorCallback) {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
if (!this._symbolsInfo.hasOwnProperty(symbolName)) {
|
setTimeout(function() {
|
||||||
onResolveErrorCallback("invalid symbol");
|
if (!that._symbolsInfo.hasOwnProperty(symbolName)) {
|
||||||
}
|
onResolveErrorCallback('invalid symbol');
|
||||||
else {
|
} else {
|
||||||
onSymbolResolvedCallback(this._symbolsInfo[symbolName]);
|
onSymbolResolvedCallback(that._symbolsInfo[symbolName]);
|
||||||
}
|
}
|
||||||
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ==================================================================================================================================================
|
// ==================================================================================================================================================
|
||||||
// ==================================================================================================================================================
|
// ==================================================================================================================================================
|
||||||
// ==================================================================================================================================================
|
// ==================================================================================================================================================
|
||||||
@@ -612,19 +590,18 @@ Datafeeds.SymbolSearchComponent = function(datafeed) {
|
|||||||
this._datafeed = datafeed;
|
this._datafeed = datafeed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// searchArgument = { searchString, onResultReadyCallback}
|
||||||
|
Datafeeds.SymbolSearchComponent.prototype.searchSymbols = function(searchArgument, maxSearchResults) {
|
||||||
// searchArgument = { ticker, onResultReadyCallback}
|
|
||||||
Datafeeds.SymbolSearchComponent.prototype.searchSymbolsByName = function(searchArgument, maxSearchResults) {
|
|
||||||
|
|
||||||
if (!this._datafeed._symbolsStorage) {
|
if (!this._datafeed._symbolsStorage) {
|
||||||
throw "Cannot use local symbol search when no groups information is available";
|
throw 'Cannot use local symbol search when no groups information is available';
|
||||||
}
|
}
|
||||||
|
|
||||||
var symbolsStorage = this._datafeed._symbolsStorage;
|
var symbolsStorage = this._datafeed._symbolsStorage;
|
||||||
|
|
||||||
var results = [];
|
var results = []; // array of WeightedItem { item, weight }
|
||||||
var queryIsEmpty = !searchArgument.ticker || searchArgument.ticker.length === 0;
|
var queryIsEmpty = !searchArgument.searchString || searchArgument.searchString.length === 0;
|
||||||
|
var searchStringUpperCase = searchArgument.searchString.toUpperCase();
|
||||||
|
|
||||||
for (var i = 0; i < symbolsStorage._symbolsList.length; ++i) {
|
for (var i = 0; i < symbolsStorage._symbolsList.length; ++i) {
|
||||||
var symbolName = symbolsStorage._symbolsList[i];
|
var symbolName = symbolsStorage._symbolsList[i];
|
||||||
@@ -633,31 +610,51 @@ Datafeeds.SymbolSearchComponent.prototype.searchSymbolsByName = function(searchA
|
|||||||
if (searchArgument.type && searchArgument.type.length > 0 && item.type != searchArgument.type) {
|
if (searchArgument.type && searchArgument.type.length > 0 && item.type != searchArgument.type) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchArgument.exchange && searchArgument.exchange.length > 0 && item.exchange != searchArgument.exchange) {
|
if (searchArgument.exchange && searchArgument.exchange.length > 0 && item.exchange != searchArgument.exchange) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (queryIsEmpty || item.name.indexOf(searchArgument.ticker) === 0) {
|
|
||||||
results.push({
|
|
||||||
symbol: item.name,
|
|
||||||
full_name: item.full_name,
|
|
||||||
description: item.description,
|
|
||||||
exchange: item.exchange,
|
|
||||||
params: [],
|
|
||||||
type: item.type,
|
|
||||||
ticker: item.name
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.length >= maxSearchResults) {
|
var positionInName = item.name.toUpperCase().indexOf(searchStringUpperCase);
|
||||||
break;
|
var positionInDescription = item.description.toUpperCase().indexOf(searchStringUpperCase);
|
||||||
|
|
||||||
|
if (queryIsEmpty || positionInName >= 0 || positionInDescription >= 0) {
|
||||||
|
var found = false;
|
||||||
|
for (var resultIndex = 0; resultIndex < results.length; resultIndex++) {
|
||||||
|
if (results[resultIndex].item == item) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
var weight = positionInName >= 0 ? positionInName : 8000 + positionInDescription;
|
||||||
|
results.push({ item: item, weight: weight });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchArgument.onResultReadyCallback(results);
|
searchArgument.onResultReadyCallback(
|
||||||
|
results
|
||||||
|
.sort(function (weightedItem1, weightedItem2) {
|
||||||
|
return weightedItem1.weight - weightedItem2.weight;
|
||||||
|
})
|
||||||
|
.map(function (weightedItem) {
|
||||||
|
var item = weightedItem.item;
|
||||||
|
return {
|
||||||
|
symbol: item.name,
|
||||||
|
full_name: item.full_name,
|
||||||
|
description: item.description,
|
||||||
|
exchange: item.exchange,
|
||||||
|
params: [],
|
||||||
|
type: item.type,
|
||||||
|
ticker: item.name
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.slice(0, Math.min(results.length, maxSearchResults))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ==================================================================================================================================================
|
// ==================================================================================================================================================
|
||||||
// ==================================================================================================================================================
|
// ==================================================================================================================================================
|
||||||
// ==================================================================================================================================================
|
// ==================================================================================================================================================
|
||||||
@@ -720,18 +717,18 @@ Datafeeds.DataPulseUpdater = function(datafeed, updateFrequency) {
|
|||||||
if (isNewBar) {
|
if (isNewBar) {
|
||||||
|
|
||||||
if (bars.length < 2) {
|
if (bars.length < 2) {
|
||||||
throw "Not enough bars in history for proper pulse update. Need at least 2.";
|
throw 'Not enough bars in history for proper pulse update. Need at least 2.';
|
||||||
}
|
}
|
||||||
|
|
||||||
var previousBar = bars[bars.length - 2];
|
var previousBar = bars[bars.length - 2];
|
||||||
for (var i =0; i < subscribers.length; ++i) {
|
for (var i = 0; i < subscribers.length; ++i) {
|
||||||
subscribers[i](previousBar);
|
subscribers[i](previousBar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_subscriptionRecord.lastBarTime = lastBar.time;
|
_subscriptionRecord.lastBarTime = lastBar.time;
|
||||||
|
|
||||||
for (var i =0; i < subscribers.length; ++i) {
|
for (var i = 0; i < subscribers.length; ++i) {
|
||||||
subscribers[i](lastBar);
|
subscribers[i](lastBar);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -745,23 +742,21 @@ Datafeeds.DataPulseUpdater = function(datafeed, updateFrequency) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof updateFrequency != "undefined" && updateFrequency > 0) {
|
if (typeof updateFrequency != 'undefined' && updateFrequency > 0) {
|
||||||
setInterval(update, updateFrequency);
|
setInterval(update, updateFrequency);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.DataPulseUpdater.prototype.unsubscribeDataListener = function(listenerGUID) {
|
Datafeeds.DataPulseUpdater.prototype.unsubscribeDataListener = function(listenerGUID) {
|
||||||
this._datafeed._logMessage("Unsubscribing " + listenerGUID);
|
this._datafeed._logMessage('Unsubscribing ' + listenerGUID);
|
||||||
delete this._subscribers[listenerGUID];
|
delete this._subscribers[listenerGUID];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.DataPulseUpdater.prototype.subscribeDataListener = function(symbolInfo, resolution, newDataCallback, listenerGUID) {
|
Datafeeds.DataPulseUpdater.prototype.subscribeDataListener = function(symbolInfo, resolution, newDataCallback, listenerGUID) {
|
||||||
|
|
||||||
this._datafeed._logMessage("Subscribing " + listenerGUID);
|
this._datafeed._logMessage('Subscribing ' + listenerGUID);
|
||||||
|
|
||||||
var key = symbolInfo.name + ", " + resolution;
|
var key = symbolInfo.name + ', ' + resolution;
|
||||||
|
|
||||||
if (!this._subscribers.hasOwnProperty(listenerGUID)) {
|
if (!this._subscribers.hasOwnProperty(listenerGUID)) {
|
||||||
|
|
||||||
@@ -776,27 +771,22 @@ Datafeeds.DataPulseUpdater.prototype.subscribeDataListener = function(symbolInfo
|
|||||||
this._subscribers[listenerGUID].listeners.push(newDataCallback);
|
this._subscribers[listenerGUID].listeners.push(newDataCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.DataPulseUpdater.prototype.periodLengthSeconds = function(resolution, requiredPeriodsCount) {
|
Datafeeds.DataPulseUpdater.prototype.periodLengthSeconds = function(resolution, requiredPeriodsCount) {
|
||||||
var daysCount = 0;
|
var daysCount = 0;
|
||||||
|
|
||||||
if (resolution == "D") {
|
if (resolution == 'D') {
|
||||||
daysCount = requiredPeriodsCount;
|
daysCount = requiredPeriodsCount;
|
||||||
}
|
} else if (resolution == 'M') {
|
||||||
else if (resolution == "M") {
|
|
||||||
daysCount = 31 * requiredPeriodsCount;
|
daysCount = 31 * requiredPeriodsCount;
|
||||||
}
|
} else if (resolution == 'W') {
|
||||||
else if (resolution == "W") {
|
|
||||||
daysCount = 7 * requiredPeriodsCount;
|
daysCount = 7 * requiredPeriodsCount;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
daysCount = requiredPeriodsCount * resolution / (24 * 60);
|
daysCount = requiredPeriodsCount * resolution / (24 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
return daysCount * 24 * 60 * 60;
|
return daysCount * 24 * 60 * 60;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Datafeeds.QuotesPulseUpdater = function(datafeed) {
|
Datafeeds.QuotesPulseUpdater = function(datafeed) {
|
||||||
this._datafeed = datafeed;
|
this._datafeed = datafeed;
|
||||||
this._subscribers = {};
|
this._subscribers = {};
|
||||||
@@ -823,6 +813,7 @@ Datafeeds.QuotesPulseUpdater.prototype.subscribeDataListener = function(symbols,
|
|||||||
listeners: []
|
listeners: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
this._subscribers[listenerGUID].listeners.push(newDataCallback);
|
this._subscribers[listenerGUID].listeners.push(newDataCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -841,8 +832,9 @@ Datafeeds.QuotesPulseUpdater.prototype._updateQuotes = function(symbolsGetter) {
|
|||||||
|
|
||||||
var subscriptionRecord = this._subscribers[listenerGUID];
|
var subscriptionRecord = this._subscribers[listenerGUID];
|
||||||
this._datafeed.getQuotes(symbolsGetter(subscriptionRecord),
|
this._datafeed.getQuotes(symbolsGetter(subscriptionRecord),
|
||||||
|
|
||||||
// onDataCallback
|
// onDataCallback
|
||||||
function(subscribers, guid) {
|
(function(subscribers, guid) {
|
||||||
return function(data) {
|
return function(data) {
|
||||||
that._requestsPending--;
|
that._requestsPending--;
|
||||||
|
|
||||||
@@ -851,11 +843,11 @@ Datafeeds.QuotesPulseUpdater.prototype._updateQuotes = function(symbolsGetter) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i =0; i < subscribers.length; ++i) {
|
for (var i = 0; i < subscribers.length; ++i) {
|
||||||
subscribers[i](data);
|
subscribers[i](data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}(subscriptionRecord.listeners, listenerGUID), //jshint ignore:line
|
}(subscriptionRecord.listeners, listenerGUID)), //jshint ignore:line
|
||||||
// onErrorCallback
|
// onErrorCallback
|
||||||
function (error) {
|
function (error) {
|
||||||
that._requestsPending--;
|
that._requestsPending--;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
|||||||
|
!function(e){function t(a){if(n[a])return n[a].exports;var c=n[a]={exports:{},id:a,loaded:!1};return e[a].call(c.exports,c,c.exports,t),c.loaded=!0,c.exports}var a=window.webpackJsonp;window.webpackJsonp=function(r,o){for(var i,s,l=0,p=[];l<r.length;l++)s=r[l],c[s]&&p.push.apply(p,c[s]),c[s]=0;for(i in o){var f=o[i];switch(typeof f){case"object":e[i]=function(t){var a=t.slice(1),n=t[0];return function(t,c,r){e[n].apply(this,[t,c,r].concat(a))}}(f);break;case"function":e[i]=f;break;default:e[i]=e[f]}}for(a&&a(r,o);p.length;)p.shift().call(null,t);return o[0]?(n[0]=0,t(0)):void 0};var n={},c={4:0};t.e=function(e,a){if(0===c[e])return a.call(null,t);if(void 0!==c[e])c[e].push(a);else{c[e]=[a];var n=document.getElementsByTagName("head")[0],r=document.createElement("script");r.type="text/javascript",r.charset="utf-8",r.async=!0,r.src=t.p+""+({0:"library",3:"vendors"}[e]||e)+"."+{0:"17acb93c64b76e7a15ec",1:"582da139b296ac74d66e",2:"351f06db7c9bd8e2a0f1",3:"0ecbebb1e373a92bb4fa"}[e]+".js",n.appendChild(r)}},t.m=e,t.c=n,t.p="bundles/"}(function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(typeof e[t]){case"function":break;case"object":e[t]=function(t){var a=t.slice(1),n=e[t[0]];return function(e,t,c){n.apply(this,[e,t,c].concat(a))}}(e[t]);break;default:e[t]=e[e[t]]}return e}([]));
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 27 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,3 +1 @@
|
|||||||
{
|
{"test string": "test string1"}
|
||||||
"test string" : "test string1"
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
18
test.html
18
test.html
@@ -263,7 +263,7 @@
|
|||||||
})
|
})
|
||||||
.append($('<span>get range</span>'));
|
.append($('<span>get range</span>'));
|
||||||
|
|
||||||
var position = widget.createPositionLine()
|
var position = widget.chart().createPositionLine()
|
||||||
.onReverse(function(text) {
|
.onReverse(function(text) {
|
||||||
console.log("Position reverse event");
|
console.log("Position reverse event");
|
||||||
})
|
})
|
||||||
@@ -275,7 +275,7 @@
|
|||||||
.setLineLength(3);
|
.setLineLength(3);
|
||||||
position.setPrice(position.getPrice() - 2);
|
position.setPrice(position.getPrice() - 2);
|
||||||
|
|
||||||
var order = widget.createOrderLine()
|
var order = widget.chart().createOrderLine()
|
||||||
.onMove(function() {
|
.onMove(function() {
|
||||||
console.log("Order moved event");
|
console.log("Order moved event");
|
||||||
})
|
})
|
||||||
@@ -287,7 +287,7 @@
|
|||||||
.setQuantity("2");
|
.setQuantity("2");
|
||||||
order.setPrice(order.getPrice() - 2.5);
|
order.setPrice(order.getPrice() - 2.5);
|
||||||
|
|
||||||
widget.createExecutionShape()
|
widget.chart().createExecutionShape()
|
||||||
.setText("@1,320.75 Limit Buy 1")
|
.setText("@1,320.75 Limit Buy 1")
|
||||||
.setTextColor("rgba(255,0,0,0.5)")
|
.setTextColor("rgba(255,0,0,0.5)")
|
||||||
.setArrowSpacing(25)
|
.setArrowSpacing(25)
|
||||||
@@ -302,7 +302,7 @@
|
|||||||
// draw some simple technical analysis figures using drawings to show how it works
|
// draw some simple technical analysis figures using drawings to show how it works
|
||||||
getMinAndMaxPrice(udf_datafeed, fourMonthAgo, today,
|
getMinAndMaxPrice(udf_datafeed, fourMonthAgo, today,
|
||||||
function(minPrice, maxPrice, minPriceTime, maxPriceTime) {
|
function(minPrice, maxPrice, minPriceTime, maxPriceTime) {
|
||||||
widget.createMultipointShape(
|
widget.chart().createMultipointShape(
|
||||||
[{time:fourMonthAgo, price: minPrice}, {time:today, price: minPrice}],
|
[{time:fourMonthAgo, price: minPrice}, {time:today, price: minPrice}],
|
||||||
{
|
{
|
||||||
shape: "trend_line",
|
shape: "trend_line",
|
||||||
@@ -318,7 +318,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
widget.createShape({time: Math.floor((fourMonthAgo + today) / 2), price: minPrice},
|
widget.chart().createShape({time: Math.floor((fourMonthAgo + today) / 2), price: minPrice},
|
||||||
{
|
{
|
||||||
shape: "text",
|
shape: "text",
|
||||||
lock: true,
|
lock: true,
|
||||||
@@ -328,7 +328,7 @@
|
|||||||
text: "3 month low at " + minPrice,
|
text: "3 month low at " + minPrice,
|
||||||
overrides: { color: "#00FF00" }
|
overrides: { color: "#00FF00" }
|
||||||
});
|
});
|
||||||
widget.createMultipointShape(
|
widget.chart().createMultipointShape(
|
||||||
[{time:fourMonthAgo, price: maxPrice}, {time:today, price: maxPrice}],
|
[{time:fourMonthAgo, price: maxPrice}, {time:today, price: maxPrice}],
|
||||||
{
|
{
|
||||||
shape: "trend_line",
|
shape: "trend_line",
|
||||||
@@ -344,7 +344,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
widget.createShape({time: Math.floor((fourMonthAgo + today) / 2), price: maxPrice},
|
widget.chart().createShape({time: Math.floor((fourMonthAgo + today) / 2), price: maxPrice},
|
||||||
{
|
{
|
||||||
shape: "text",
|
shape: "text",
|
||||||
lock: true,
|
lock: true,
|
||||||
@@ -354,7 +354,7 @@
|
|||||||
text: "3 month high at " + maxPrice,
|
text: "3 month high at " + maxPrice,
|
||||||
overrides: { color: "#FF0000" }
|
overrides: { color: "#FF0000" }
|
||||||
});
|
});
|
||||||
widget.createMultipointShape(
|
widget.chart().createMultipointShape(
|
||||||
[{time:maxPriceTime, price: maxPrice}, {time:minPriceTime, price: minPrice}],
|
[{time:maxPriceTime, price: maxPrice}, {time:minPriceTime, price: minPrice}],
|
||||||
{
|
{
|
||||||
shape: "trend_line",
|
shape: "trend_line",
|
||||||
@@ -369,7 +369,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
widget.createMultipointShape(
|
widget.chart().createMultipointShape(
|
||||||
[{time: Math.floor((maxPriceTime + minPriceTime) / 2), price: (maxPrice + minPrice) / 2},
|
[{time: Math.floor((maxPriceTime + minPriceTime) / 2), price: (maxPrice + minPrice) / 2},
|
||||||
{time: Math.floor((maxPriceTime + minPriceTime) / 2) + 5 * 24 * 60 * 60, price: (maxPrice + minPrice) / 2 * 1.1}],
|
{time: Math.floor((maxPriceTime + minPriceTime) / 2) + 5 * 24 * 60 * 60, price: (maxPrice + minPrice) / 2 * 1.1}],
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user