Skip to content

Instantly share code, notes, and snippets.

@romikoops
Created June 12, 2013 20:52
Show Gist options
  • Save romikoops/5769007 to your computer and use it in GitHub Desktop.
Save romikoops/5769007 to your computer and use it in GitHub Desktop.
temp conversion from vbscript to Ruby
#VBScript
#For J = 1 To N
#term1 = J * (1 - (-1) ^ J * Exp(-Alpha * L)) / (J ^ 2 * 9.869604401 + Alpha ^ 2 * L ^ 2)
#term2 = Exp((-0.5 * implied_volatility ^ 2 * (3.141592654 * J / L) ^ 2 - Beta) * T)
#term3 = Sin((3.141592654 * J / L) * Log(Asset_Price / Lower_Strike))
#Value(J) = term1 * term2 * term3
#Agg = Agg + Value(J)
#Next J
require 'bigdecimal'
1.upto(n) do |j|
term1 = j * (1 - (-1) ** j * BigMath.exp(-alpha * l, 15) / (j ** 2 * Math::PI ** 2 + alpha ** 2 * l **2)
term2 = BigMath.exp(-0.5 * implied_volatility ** 2 * (Math::PI * j / l)) ** 2 - beta) * t, 15)
term3 = Math.sin((Math::PI * j / l) * Math.log10(asset_price / lower_strike))
value[j] = term1 * term2 * term3
agg += value[j]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment