// Usa fids.js // Usa calculadora de warrants de BBVA function CalcWarrants(WarrantApplet) { this.aWarrants = WarrantApplet; this.ratio; this.chg_rate = 1.0; this.fill = function( spot, dividendRate, processDate, strike, interestRate, type, maturity, volatility, ratio, optionPrice, chg_rate) { if(dividendRate==null || dividendRate=="N/A") dividendRate = 0; if(interestRate==null || interestRate=="N/A") interestRate = 0; if(volatility==null || volatility=="N/A") volatility = 0; bcall = (type.charAt(0)=='C' || type.charAt(0)=='c'); this.aWarrants.fill(parseFloat(spot), parseFloat(dividendRate)/100., parseFloat(strike), processDate, maturity, parseFloat(optionPrice)/ratio * chg_rate, parseFloat(volatility)/100., parseFloat(interestRate)/100., bcall); this.ratio = ratio; this.chg_rate = chg_rate; } this.getCalc=function(target){ return (target=="V")?this.getCalcVolatility():this.getcalcOptPrice(); } this.getCalcVolatility =function(){ this.aWarrants.calcVolatility(); if (this.aWarrants.getError()==0){ this.lastVolatility = this.aWarrants.getVolatilityStr(); this.lastVega=this.aWarrants.getVegaStr()* this.ratio; this.lastDelta=this.aWarrants.getDeltaStr()*100.; this.lastTheta=this.aWarrants.getThetaStr()/365.25 * this.ratio; this.lastGamma=this.aWarrants.getGammaStr(); this.lastElasticity=this.aWarrants.getElasticityStr(); this.lastLeverage=this.aWarrants.getLeverageStr()* this.ratio; }else{ this.lastVolatility="N/A"; this.lastVega="N/A"; this.lastDelta="N/A"; this.lastTheta="N/A"; this.lastGamma="N/A"; this.lastElasticity="N/A"; this.lastLeverage="N/A"; } return this.lastVolatility; } this.getcalcOptPrice = function (){ this.aWarrants.calcPremium(); if (this.aWarrants.getError()==0){ //Redondear la prima a 2 decimales var premium = this.aWarrants.getPremiumStr() * this.ratio / this.chg_rate;; premium = Math.round(premium * Math.pow(10, 2)) / Math.pow(10, 2); this.lastOptPrice = premium; this.lastVega=this.aWarrants.getVegaStr() * this.ratio; this.lastDelta=this.aWarrants.getDeltaStr()*100.; this.lastTheta=this.aWarrants.getThetaStr()/365.25 * this.ratio; this.lastGamma=this.aWarrants.getGammaStr(); this.lastElasticity=this.aWarrants.getElasticityStr(); this.lastLeverage=this.aWarrants.getLeverageStr()* this.ratio; }else{ this.lastOptPrice="N/A"; this.lastVega="N/A"; this.lastDelta="N/A"; this.lastTheta="N/A"; this.lastGamma="N/A"; this.lastElasticity="N/A"; this.lastLeverage="N/A"; } return this.lastOptPrice; }; } CalcWarrants.prototype.NeededFids = [__constants.FIDS.DATE, __constants.FIDS.BID, __constants.FIDS.ASK, __constants.FIDS.MATURITY, __constants.FIDS.STRIKE, __constants.FIDS.CALLPUT, __constants.FIDS.RATIO, __constants.FIDS.SPOT, __constants.FIDS.VOLATILITY, __constants.FIDS.DELTA, __constants.FIDS.VEGA, __constants.FIDS.ELASTICITY, __constants.FIDS.GAMMA, __constants.FIDS.THETA, __constants.FIDS.INT_RATE, __constants.FIDS.CHG_RATE, __constants.FIDS.DIVIDEND, __constants.FIDS.STOP_LOSS, __constants.FIDS.LEVERAGE] CalcWarrants.prototype.getFidName = function(f) {return getName(f); } CalcWarrants.prototype.getFidId = function(f){return getFid(f); }