Created
August 1, 2014 17:06
-
-
Save joastbg/10a2b9cf397000645261 to your computer and use it in GitHub Desktop.
Binomial price step using some x86 tricks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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