Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

I've written some code to calculate European option prices using the Black-Scholes analytical method. Can somebody recommend a good way to test that code? I have looked at option pricers online like IVolatility. However, I'm not sure if they use the method I am trying to test.

share|improve this question
1  
you need to provide more information. If you cannot then simply price an option during market open and compare against the bid offer prices of liquid options trading. –  Matt Wolf Apr 4 '13 at 9:22
    
Freddy, what information? –  bytefire Apr 4 '13 at 9:58
2  
which "method" to test? And which "method" are you using? and as edouard mentioned it would greatly help understanding which precise formulae you used before commenting on whether they are right or not. –  Matt Wolf Apr 4 '13 at 11:20
    
Pardon my lack of knowledge, are there more than one analytical Black-Scholes methods? I am using the formula given here en.wikipedia.org/wiki/…;. This is same as the screenshot in edouard's reply below. –  bytefire Apr 4 '13 at 13:33
1  
ok, so then what is problem that you are having? Price the AAPL June 21, 430 Call, it currently trades at 23.10/23.40 with spot at 428.55. I see an implied vol of 31.38%, not sure they pay dividends before this call expires, I do not actively trade AAPL options. –  Matt Wolf Apr 4 '13 at 14:43
show 1 more comment

1 Answer

up vote 3 down vote accepted

An easy and fast way is checking your values against Excel functions. See, the picture below.

Or, maybe you could post your code and people will have a look at it.

enter image description here

share|improve this answer
    
Thanks edouard, I'll test against that. The code is spread among different classes. It may lead to further questions. However I will ultimately post the on github. –  bytefire Apr 4 '13 at 9:57
    
@bytefire, why would you want to post your code on github? There must be more than 100 different BS pricing libraries out there, written in any conceivable language. Why not just picking one of those and using it? –  Matt Wolf Apr 4 '13 at 14:45
    
Two reasons. One is that I'm writing it in C# 5 leveraging TPL. That hopefully will add value. The other is a personal reason, it gives me incentive to learn. The BS pricer is part of a wider project. Most of the code out there is in C++ and written by quants for quants. I plan to target C# programmers, if that makes sense? –  bytefire Apr 4 '13 at 16:02
    
There are c# libraries out there as well. But point taken regarding the learning incentive though the formula is the same across the board. Tpl dataflow will not add much value in regards to that. I am saying that as someone who heavily peruses tpl dataflow in .net 4.5 –  Matt Wolf Apr 4 '13 at 16:10
    
Re TPL it depends what one is trying to achieve. I believe TPL has the potential to beat C++ on speed. A sweeping statement, I know. But TPL specifically exploits multi core processors which is the way forward now that processor speed has plateaued. Admittedly it won't make noticeable difference to BS pricing code, but it will in other areas. Having said that, all this is different debate. Interesting nonetheless! –  bytefire Apr 4 '13 at 16:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.