Skip to content

Instantly share code, notes, and snippets.

@joastbg
Created August 1, 2014 17:06
Show Gist options
  • Select an option

  • Save joastbg/10a2b9cf397000645261 to your computer and use it in GitHub Desktop.

Select an option

Save joastbg/10a2b9cf397000645261 to your computer and use it in GitHub Desktop.
Binomial price step using some x86 tricks
// e^(-r*sqrt(t/n)) using some x86 tricks
float _fexpbin(float vol, float t)
{
float ret;
__asm
{
fld t
fsqrt
fldln2
fdiv
fld vol
fmul
f2xm1
fld1
faddp st(1), st
fstp ret
}
return ret;
}
int main()
{
// +vol = u(p)
std::cout << _fexpbin( 0.2, 1.0 / 365.0) << std::endl;
// -vol = d(own)
std::cout << _fexpbin(-0.2, 1.0 / 365.0) << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment