rate card

Download Rate Card

If you can't read please download the document

Upload: kamlesh-agrawal

Post on 20-Dec-2015

215 views

Category:

Documents


2 download

DESCRIPTION

dd

TRANSCRIPT

Ext.define('fmconnect.fxcash.component.RateCard', {extend:'Ext.panel.Panel',alias: 'widget.rateCard',width:350,height:110,layout : 'hbox',defaults:{margin:1},getRateParts:function(rate,pointsDigit){var rateObj = new Object();var rateStr = padWithZeros(rate, 10);var decLoc = decimalLocation(rate);var beforeDecimal=rateStr.substring(0,decLoc+1);rateObj.rate = beforeDecimal + rateStr.substr(decLoc+1,pointsDigit-2);//rateObj.rate = rateStr.substring(0,3); //decimal point includedvar bigfigureloc= decLoc+1+pointsDigit-2;rateObj.bigfigure = rateStr.substr(bigfigureloc,2);rateObj.smallfigure = rateStr.substr(bigfigureloc+2,1);//rateObj.smallfigure = 0;return rateObj;},clearDisplay : function(){this.getBidCard().setText(null);this.getAskCard().setText(null);this.getBidCard().setIcon(null);this.getAskCard().setIcon(null);},setTickDirection:function(card, direction){switch(direction){case 0 : card.setIcon (null); break;case 1 : card.setIcon('images/arrow_green.png'); break;case -1 : card.setIcon('images/arrow_red.png'); break;default : card.setIcon (null); break;}},setRfqText : function(card){card.setText('RFQ');},round: function(rate, pointsDigit){var tens = Math.pow(10,pointsDigit+1);return Math.round(rate*tens)/tens;},updateForwardRate : function(fxRateFeedAppObj){this.fxRateFeedAppObj = fxRateFeedAppObj;//var htmlStringFwd = ' SELL USD SP: {SPOT_REF} SW: {SWAP_POINTS}{RATE} {BIGFIGURE}{SMALLFIGURE}';var htmlStringFwd = ' {DIRECTION} {CCY1} {RATE} {BIGFIGURE}{SMALLFIGURE}';htmlStringFwd = htmlStringFwd.replace("{CCY1}",this.fxRateFeedAppObj.ccy1);var titleccy=fxRateFeedAppObj.ccyPair;var titlebidRate=fxRateFeedAppObj.bidRate+"/";var titleaskRate=fxRateFeedAppObj.askRate;if(fxRateFeedAppObj.bidTradingMode=="RFQ"){this.setRfqText(this.getBidCard());titlebidRate="";}else {var bidRateParts = this.getRateParts(fxRateFeedAppObj.bidRate,fxRateFeedAppObj.pointsDigit);var bidHtml = htmlStringFwd.replace("{DIRECTION}", "SELL").replace("{RATE}", bidRateParts.rate).replace("{BIGFIGURE}", bidRateParts.bigfigure).replace("{SMALLFIGURE}", bidRateParts.smallfigure).replace("{SPOT_REF}", this.round(fxRateFeedAppObj.bidSpotRef,fxRateFeedAppObj.pointsDigit)).replace("{SWAP_POINTS}", this.round(fxRateFeedAppObj.bidPoints, fxRateFeedAppObj.pointsDigit));this.setTickDirection(this.getBidCard(), fxRateFeedAppObj.bidTickDirection);this.getBidCard().setText(bidHtml);};if(fxRateFeedAppObj.askTradingMode=="RFQ"){this.setRfqText(this.getAskCard());titleaskRate="";}else{var askRateParts = this.getRateParts(fxRateFeedAppObj.askRate,fxRateFeedAppObj.pointsDigit);var askHtml = htmlStringFwd.replace("{DIRECTION}", "BUY").replace("{RATE}", askRateParts.rate).replace("{BIGFIGURE}", askRateParts.bigfigure).replace("{SMALLFIGURE}", askRateParts.smallfigure).replace("{SPOT_REF}", this.round(fxRateFeedAppObj.askSpotRef,fxRateFeedAppObj.pointsDigit)).replace("{SWAP_POINTS}", this.round(fxRateFeedAppObj.askPoints,fxRateFeedAppObj.pointsDigit));this.setTickDirection(this.getAskCard(), fxRateFeedAppObj.askTickDirection);this.getAskCard().setText(askHtml);if(this.up('streamingCard').collapsed){var title=titleccy+" "+titlebidRate+titleaskRate;this.up('streamingCard').setTitle(title);}};}, updateSpotRate : function (fxRateFeedAppObj){this.fxRateFeedAppObj = fxRateFeedAppObj;var htmlStringSpot = ' {DIRECTION} {CCY1} {RATE} {BIGFIGURE}{SMALLFIGURE}';var titleccy=fxRateFeedAppObj.ccyPair;var titlebidRate=fxRateFeedAppObj.bidRate+"/";var titleaskRate=fxRateFeedAppObj.askRate;htmlStringSpot = htmlStringSpot.replace("{CCY1}",this.fxRateFeedAppObj.ccy1);if(fxRateFeedAppObj.bidTradingMode=="RFQ"){this.setRfqText(this.getBidCard());titlebidRate="";}else{var bidRateParts = this.getRateParts(fxRateFeedAppObj.bidRate,fxRateFeedAppObj.pointsDigit);var bidHtml = htmlStringSpot.replace("{DIRECTION}", "SELL").replace("{RATE}", bidRateParts.rate).replace("{BIGFIGURE}", bidRateParts.bigfigure).replace("{SMALLFIGURE}", bidRateParts.smallfigure);this.setTickDirection(this.getBidCard(), fxRateFeedAppObj.bidTickDirection);this.getBidCard().setText(bidHtml);};if(fxRateFeedAppObj.askTradingMode=="RFQ"){this.setRfqText(this.getAskCard());titleaskRate="";}else{var askRateParts = this.getRateParts(fxRateFeedAppObj.askRate,fxRateFeedAppObj.pointsDigit);var askHtml = htmlStringSpot.replace("{DIRECTION}", "BUY").replace("{RATE}", askRateParts.rate).replace("{BIGFIGURE}", askRateParts.bigfigure).replace("{SMALLFIGURE}", askRateParts.smallfigure);this.setTickDirection(this.getAskCard(), fxRateFeedAppObj.askTickDirection);this.getAskCard().setText(askHtml);};if(this.up('streamingCard').collapsed){var title=titleccy+" "+titlebidRate+titleaskRate;this.up('streamingCard').setTitle(title);}},updateSwapRate: function (fxRateFeedAppObj){console.log("widget yet to be made");},setCcyPair : function(ccyPair){this.ccyPair= ccyPair;},disableTrading: false,sendBidRfq :function(){if(this.disableTrading){Ext.Msg.alert("Trade booking feature has been disabled for this release");return;}else if(this.up('streamingCard')){if(this.up('streamingCard').down('coretogglebutton').getValue()==="Y"){console.log("Send Bid Rfq");var rfqObject = this.populateRfqObjectBid();var win = Ext.widget('customerRfqRequesterPanel',{rfqObject: rfqObject});win.show();}else{Ext.Msg.alert('Error', 'You have disabled trading for this Currency Pair');}}},sendAskRfq: function(){if(this.disableTrading){Ext.Msg.alert("Trade booking feature has been disabled for this release");return;}else if(this.up('streamingCard')){if(this.up('streamingCard').down('coretogglebutton').getValue()==="Y"){console.log("Send Ask Rfq");var rfqObject = this.populateRfqObjectAsk();var win = Ext.widget('customerRfqRequesterPanel',{rfqObject: rfqObject});win.show();}else{Ext.Msg.alert('Error', 'You have disabled trading for this Currency Pair');}}},getBidCard: function(){return this.down("[fmId='bidRateCard']");},getAskCard: function(){return this.down("[fmId='askRateCard']");},items:[{xtype : 'panel',layout : 'vbox',flex:1,height:'100%',defaults:{margin:3},bodyCls: 'sell-siderate',items:[{xtype:'button',fmId:'bidRateCard',iconAlign : 'left',flex : 3,width: '100%',listeners:{click:function(){var streamingCard = this.up('streamingCard');streamingCard.fireEvent("bidClick", streamingCard);}}}]},{xtype : 'panel',layout : 'vbox',flex:1,height:'100%',defaults:{margin:3},bodyCls: 'buy-siderate',items:[{xtype:'button',fmId:'askRateCard',flex : 3,width: '100%',iconAlign : 'right',listeners:{click:function(){var streamingCard = this.up('streamingCard');streamingCard.fireEvent("askClick", streamingCard);}}}]}],});//for ratesfunction padWithZeros(number,n){var strn = number.toString();for(i=strn.length;i