webpackJsonp([1,4],{322:function(e,t,i){"use strict";var r=i(323),n=i(324),o=i(325),s=i(328),a=i(339),l=i(340),u=i(341),d=i(342),c=i(343),p=i(338),f=function(e){this.activeAccount=new WatchedValue,this._trading=e,this._chartWidgetControllers=[],this._resolver=new n(this)};f.prototype.id=function(){return"CQG"},f.prototype.trading=function(){return this._trading},f.prototype.createAccountManager=function(e){return new o(e,this)},f.prototype.connect=function(){var e=this;this._connection=new s(this),this._connection.onMustChangePassword.subscribe(null,function(){d.get(e).open({title:$.t("Your Password Has Expired"),allowCancel:!1,message:$.t("Your password has expired, please enter new password")})})},f.prototype.disconnect=function(){this._connection.disconnect(),this._chartWidgetControllers.forEach(function(e){e.controller&&e.controller.reset()}),this._chartWidgetControllers=[]},f.prototype.connection=function(){return this._connection||this.connect(),this._connection},f.prototype.buttonDropdownOptions=function(e){var t=this.connection().connectStatus()==r.CONNECTED,i=this;if(t){var n=[{title:$.t("Show Buy/Sell Panel"),icon:{image:"url('"+TradingView.wrapUrl("images/dialogs/checkbox.png")+"')",offset:i.trading().hideFloatingPanel.value()?"":"0 -16px"},action:function(){i.trading().hideFloatingPanel.setValue(!i.trading().hideFloatingPanel.value())}},{title:$.t("Show Active Orders Only"),icon:{image:"url('"+TradingView.wrapUrl("images/dialogs/checkbox.png")+"')",offset:i.trading().hideCompletedOrders.value()?"0 -16px":""},action:function(){i.trading().hideCompletedOrders.setValue(!i.trading().hideCompletedOrders.value())}},{separator:!0},{title:$.t("Trading Properties"),action:function(){i.trading().showTradingProperties()}},{separator:!0},{title:$.t("Disconnect"),action:function(){i.disconnect()}},{title:$.t("Change Password"),disabled:!t,action:function(){d.get(i).open({title:$.t("Change Password"),allowCancel:!0})}}];return Z75.enabled("charting_library_base")||(n.push({separator:!0}),n.push({title:$.t("Select Broker"),action:function(){i.trading().selectBroker()}})),n}return[{title:$.t("Select Broker"),action:function(){i.trading().selectBroker()}}]},f.prototype.formatter=function(e){return new p(e)},f.prototype.createProfitLossEmitter=function(e){return{}},f.prototype.registerChartWidget=function(e){var t={widget:e};this._chartWidgetControllers.push(t);var i=this;e.model().model().mainSeries().onSymbolResolved().subscribe(null,function(){r()}),i.activeAccount.subscribe(function(){r()});var r=function(){var r=e.model().model().mainSeries().symbolInfo();if(r){var n=r.pro_name;i._resolver.tv2cqg(n).done(function(r){i.activeAccount.when(function(){if(i.trading().getActiveBroker()==i){var n=i.activeAccount.value().id;t.controller?t.controller.setCQGSymbol(r,n):t.controller=new a(e,r,n,i)}})}).fail(function(){t.controller&&i.activeAccount.when(function(){t.controller.setCQGSymbol("",i.activeAccount.value().id)})})}};t.controllerCreator=r,r()},f.prototype.unregisterChartWidget=function(e){for(var t=this._chartWidgetControllers.length-1;t>=0;--t){var i=this._chartWidgetControllers[t];if(i.widget==e){i.controller&&i.controller.reset(),this._chartWidgetControllers.splice(t,1),e.model().model().mainSeries().onSymbolResolved().unsubscribe(null,i.controllerCreator),e.model().model().mainSeries().onCompleted().unsubscribe(null,i.controllerCreator);break}}},f.prototype.supportFloatingPanel=function(){return!0},f.prototype.closePosition=function(e){var t=this,i={account_id:e.account_id,qty:e.qty,side:"Buy"==e.side?"Sell":"Buy",symbol:e.symbol,type:"Market",duration:{type:"DAY"},executionOptions:{}};this.trading().noConfirmEnabled.value()?this.connection().resolveSymbol(i.symbol).done(function(e){i.contract_id=e.contract_metadata.contract_id,t.connection().placeOrder(i)}):l.get(t).open(i)},f.prototype.cancelOrder=function(e){var t=this;this.trading().noConfirmEnabled.value()?t.connection().cancelOrder(e):c.get().open(e).done(function(){t.connection().cancelOrder(e)})},f.prototype.getOrderDialog=function(){var e=this;return{open:function(t,i){if(e.connection().connectStatus()!=r.CONNECTED)return e.trading().onOpenBottomWidgetBar.fire(),e.trading().onNeedAttention.fire(),$.Deferred().reject().promise();var n=$.Deferred();if(i){var o=t&&t.symbol;e._connection.isTradable(o).done(function(i){i?(t.account_id=t.account_id?t.account_id:e.activeAccount.value().id,l.get(e).open(t).done(function(){n.resolve()}).fail(function(){n.reject()})):(e.getUntradableDialog().open(s),n.reject())})}else{var s=t&&t.symbol;e._resolver.tv2cqg(s).done(function(i){e._connection.isTradable(i).done(function(r){if(r){var o=TradingView.clone(t);o.symbol=i,o.tvSymbol=s,o.account_id=o.account_id?o.account_id:e.activeAccount.value().id,l.get(e).open(o).done(function(){n.resolve()}).fail(function(){n.reject()})}else e.getUntradableDialog().open(s),n.reject()})}).fail(function(){e.getUntradableDialog().open(s),n.reject()})}return n.promise()}}},f.prototype.getUntradableDialog=function(){return u.get()},f.prototype.resolver=function(){return this._resolver},f.prototype.chartContextMenuActions=function(e,t){var i=NaN,r=this,n=NaN,o=1,s="",a="",l="";if(e){a=e.proSymbol(),l=(e.symbolInfo()||{}).name||a;var u=e.priceScale();if(t){if(i=u.coordinateToPrice(t.localY),u.isPercentage()){var d=e.firstValue();i=void 0!==d?u.priceRange().convertFromPercent(i,d):null}s=e.formatter().format(i)}var c=e.bars().last();c&&(n=c.value[TradingView.CLOSE_PLOT]);var p=this.connection();p&&(o=+p.suggestedQty().value(a),(0>o||!isFinite(o))&&(o=1))}var f=[],h=r.activeAccount.value()&&r.activeAccount.value().id;if(n>i){var m=new TradingView.Action({text:"Buy "+l+" Limit "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_limit_price:s,side:"Buy",type:"Limit",qty:o,noConfirm:!0})}),f.push(m);var m=new TradingView.Action({text:"Sell "+l+" Stop "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_stop_price:s,side:"Sell",type:"Stop",qty:o,noConfirm:!0})}),f.push(m)}else if(i>n){var m=new TradingView.Action({text:"Sell "+l+" Limit "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_limit_price:s,side:"Sell",type:"Limit",qty:o,noConfirm:!0})}),f.push(m);var m=new TradingView.Action({text:"Buy "+l+" Stop "+TradingView.abbreviatedNumber(o)+" @ "+s});m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,symbol:a,formatted_stop_price:s,side:"Buy",type:"Stop",qty:o,noConfirm:!0})}),f.push(m)}var m=new TradingView.Action({text:"Create New Order..."});return m.callbacks().subscribe(null,function(){r.getOrderDialog().open({account_id:h,qty:o,symbol:a})}),f.push(m),f},f.prototype.getSymbolInfo=function(e){var t=this,i=$.Deferred();return t._resolver.tv2cqg(e).done(function(e){t.connection().resolveSymbol(e).done(function(e){i.resolve({realtimeContractId:e.contract_metadata.contract_id,formatter:t.formatter(e.contract_metadata)})}).fail(function(e){i.reject(e)})}).fail(function(e){i.reject(e)}),i},e.exports=f},324:function(e,t){"use strict";var i=function(e){this._cache2tv={},this._cache2cqg={},this._broker=e};i.prototype.tv2cqg=function(e){var t=this,i=$.Deferred();if(this._cache2cqg[e]){var r=this._cache2cqg[e];setTimeout(function(){"SYMBOL_NOT_FOUND"==r?i.reject():i.resolve(r)},0)}else $.get("/cqg_mapping/2cqg/"+e+"/").done(function(r){var n=r.symbol;r.error?(t._cache2cqg[e]="SYMBOL_NOT_FOUND",i.reject()):(t._cache2cqg[e]=n,i.resolve(n))});return i.promise()},i.prototype.cqg2tv=function(e){var t=$.Deferred(),i=this._cache2tv[e];if(i)setTimeout(function(){"SYMBOL_NOT_FOUND"==i?t.reject():t.resolve(i)},0);else{var r=this;$.get("/cqg_mapping/2tv/"+e+"/").done(function(i){var n=i.symbol;i.error?(r._cache2tv[e]="SYMBOL_NOT_FOUND",t.reject()):(r._cache2tv[e]=n,t.resolve(n))})}return t.promise()},e.exports=i},325:function(e,t,i){(function(t){"use strict";var r=i(323),n=i(326),o=i(327),s=function(e,t){this._broker=t,this._connection=t.connection(),this._resolver=t.resolver(),this.$container=$(document.createElement("div")),this.$container.appendTo(e.$body).addClass("cqg-trading"),this.height=e.height,this.minimized=e.minimized,this.properties=e.properties,this.body=e.$body,this._connection.onStatusChanged.subscribe(this,s.prototype._updateContentPanel),this._contextMenuHandler=this._onContextMenu.bind(this),this._changeacc=s.prototype._changeAccount.bind(this),this._changesymbol=s.prototype._updateSymbol.bind(this),this._updateContentPanel({status:this._connection.connectStatus()}),this._broker.trading().onNeedAttention.subscribe(this,this.drawAttention)};s.prototype.selectActiveSymbol=function(e){this._tables.orders.getRows().forEach(function(t){t.row.toggleClass("tv-data-table__stroke--active",t.symbol==e)}),this._tables.positions.getRows().forEach(function(t){t.row.toggleClass("tv-data-table__stroke--active",t.symbol==e)})},s.prototype.connect=function(){this._connection.onBalance.subscribe(this,s.prototype._updateBalance),this._connection.onCollateral.subscribe(this,s.prototype._updateCollaterals),this._connection.onOrderUpdate.subscribe(this,s.prototype._updateOrder),this._connection.onPositionUpdate.subscribe(this,s.prototype._updatePosition)},s.prototype.disconnect=function(){this._broker.activeAccount.unsubscribe(this._changeacc),this._ordersHandler&&this._broker.trading().hideCompletedOrders.unsubscribe(this._ordersHandler),this.body.off("contextmenu",this._contextMenuHandler),$44.proSymbol.unsubscribe(this._changesymbol),this._connection.onBalance.unsubscribe(this,s.prototype._updateBalance),this._connection.onCollateral.unsubscribe(this,s.prototype._updateCollaterals),this._connection.onOrderUpdate.unsubscribe(this,s.prototype._updateOrder),this._connection.onPositionUpdate.unsubscribe(this,s.prototype._updatePosition)},s.prototype.remove=function(){this._tables&&this._tables.positions.getRows().forEach(function(e){e.plCalculator&&e.plCalculator.stop()}),delete this._tables,this.$container.remove(),this.disconnect(),this._connection.onStatusChanged.unsubscribe(this,s.prototype._updateContentPanel)},s.prototype._updateContentPanel=function(e){if(this._tables&&this._tables.positions.getRows().forEach(function(e){e.plCalculator&&(e.plCalculator.stop(),delete e.plCalculator)}),this._flatAccounts=[],this.$container.empty(),this._spinner&&(this._spinner.stop(),delete this._spinner),this._spinnerContainer&&(this._spinnerContainer.remove(),delete this._spinnerContainer),e.status==r.ERROR||e.status==r.DISCONNECT){this.disconnect(),e.message&&$("