Professional Documents
Culture Documents
Rate Card
Rate Card
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,pointsDig
it-2);
//rateObj.rate = rateStr.substring(0,3); //decimal point include
d
var 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'); br
default :
eak;
}
},
setRfqText : function(card){
card.setText('<font style="font-color:white;font-size:50px;fontweight:bold;vertical-align:middle">RFQ</font>');
},
round: function(rate, pointsDigit){
var tens = Math.pow(10,pointsDigit+1);
return Math.round(rate*tens)/tens;
},
updateForwardRate : function(fxRateFeedAppObj){
this.fxRateFeedAppObj = fxRateFeedAppObj;
askRateParts.smallfigure).
replace("{SPOT_REF}", th
is.round(fxRateFeedAppObj.askSpotRef,fxRateFeedAppObj.pointsDigit)).
replace("{SWAP_POINTS}",
this.round(fxRateFeedAppObj.askPoints,fxRateFeedAppObj.pointsDigit));
this.setTickDirection(this.getAskCard(), fxRateFeedAppOb
j.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 = '<span><table align="center"><tr><td align=
"center"> <font style="font-size:15px;font-weight:normal;vertical-align:top">{DI
RECTION} {CCY1}</font> </td></tr><tr></tr><tr><td align="center"><font style="fo
nt-size:20px;font-weight:normal;vertical-align:bottom">{RATE} </font><font style
="font-size:50px;font-weight:bold;vertical-align:top">{BIGFIGURE} </font><f
ont style="font-size:20px;font-weight:normal;vertical-align:bottom">{SMALLFIGURE
}</font></td></tr></span>';
var titleccy=fxRateFeedAppObj.ccyPair;
var titlebidRate=fxRateFeedAppObj.bidRate+"/";
var titleaskRate=fxRateFeedAppObj.askRate;
htmlStringSpot = htmlStringSpot.replace("{CCY1}",this.fxRateFeed
AppObj.ccy1);
if(fxRateFeedAppObj.bidTradingMode=="RFQ"){
this.setRfqText(this.getBidCard());
titlebidRate="";
}else{
var bidRateParts = this.getRateParts(fxRateFeedAppObj.bi
dRate,fxRateFeedAppObj.pointsDigit);
var bidHtml = htmlStringSpot.replace("{DIRECTION}", "SEL
L").replace("{RATE}", bidRateParts.rate).replace("{BIGFIGURE}", bidRateParts.big
figure).replace("{SMALLFIGURE}", bidRateParts.smallfigure);
this.setTickDirection(this.getBidCard(), fxRateFeedAppOb
j.bidTickDirection);
this.getBidCard().setText(bidHtml);
};
if(fxRateFeedAppObj.askTradingMode=="RFQ"){
this.setRfqText(this.getAskCard());
titleaskRate="";
}else{
var askRateParts = this.getRateParts(fxRateFeedAppObj.as
kRate,fxRateFeedAppObj.pointsDigit);
var askHtml = htmlStringSpot.replace("{DIRECTION}", "BUY
").replace("{RATE}", askRateParts.rate).replace("{BIGFIGURE}", askRateParts.bigf
igure).replace("{SMALLFIGURE}", askRateParts.smallfigure);
this.setTickDirection(this.getAskCard(), fxRateFeedAppOb
j.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 f
or this release");
return;
}
else if(this.up('streamingCard')){
if(this.up('streamingCard').down('coretogglebutton').get
Value()==="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 tradin
g for this Currency Pair');
}
}
},
sendAskRfq: function(){
if(this.disableTrading){
Ext.Msg.alert("Trade booking feature has been disabled f
or this release");
return;
}
else if(this.up('streamingCard')){
if(this.up('streamingCard').down('coretogglebutton').get
Value()==="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 tradin
g 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('streamingC
ard');
streamingCard.fireEvent("bidClick", stre
amingCard);
}
}
}]
},{
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(){