Black-Scholes formula
Author: Sammy_G
Creation Date: 9/10/2010 9:39 AM
profile picture

Sammy_G

#1
There was a wonderful study by the name BlackScholes in WL4; I have been unable to find it in WL6. Hope it will be translated and added to WL6 soon.

Even better, is there a C# version somewhere that can be easily integrated into WL6? I found some references on the web, such as http://www.espenhaug.com/black_scholes.html and http://www.codeproject.com/KB/aspnet/blackscholesship.aspx, etc. but on trying to assimilate the code I got numerous errors (which is probably a reflection of my ignorance).
profile picture

Cone

#2
Black-Scholes? You mean those golf-playing quant characters whose model that ignores fat tails (black swans) lost a few billion dollars for Long Term Capital Management in the wake of Russian default? Will the bail outs ever stop!? :)
profile picture

Eugene

#3
Disregard the 2nd link, because it's "web ready" i.e. catered to ASP.NET users. The first one seems like it would do the job but there's something wrong with your copy/paste. Here's it (untested, but with a few tweaks):
CODE:
Please log in to see this code.
profile picture

Sammy_G

#4
QUOTE:
Black-Scholes? You mean those golf-playing quant characters whose model that ignores fat tails (black swans) lost a few billion dollars for Long Term Capital Management in the wake of Russian default? Will the bail outs ever stop!? :)

He, he, he, he! That's really funny!! :D :D
Lets not forget they got Nobel Prize for their work!
================

Thanks for the quick response, Eugene!
It is my hope some day its included in WL6 Community Components (or Indicators). BUT... before you do that one would need to verify if the values are reasonably accurate. It will take me quite a bit of time to do that; hopefully, some other user will beat me to it.
profile picture

Cone

#5
Right, and let's also not forget they gave our President, in charge of 2 wars, the Nobel Peace Prize.
profile picture

Eugene

#6
Well said.
profile picture

Sammy_G

#7
The formula doesn't work. Test code:
CODE:
Please log in to see this code.


For Calls, it just returns the value of the stock price (the first variable) even if you keep changing other variables.
For Puts also, returns silly values.

Can you identify where the formula is broken?
profile picture

Eugene

#8
In your parameters. 60 years to maturity? That's some long-term investment horizon.
profile picture

Sammy_G

#9
Most formulas convert the time input, usually in days, into years internally. Perhaps this one doesn't. Regardless, you can test these parameters:
CODE:
Please log in to see this code.

where the strike price and stock price are same, T is 0.06....and you still get silly results.
Or choose any parameters that you fancy.
profile picture

Eugene

#10
OK I agree and suggest contacting its author(s) at espenhaug.com.
profile picture

Sammy_G

#11
Uh, all right. All I was trying to do was see if you could quickly spot where the formula was failing, because at a quick glance I sure couldn't.
*/

Different question: Can you point me to source code of an indicator that returns a value, not a series? I have studied the code for most indicators but they all create series.
profile picture

Eugene

#12
If you're looking for an example of the Value method implementation in an indicator, consider digging in TASCIndicators (you won't find one in Community Indicators yet).
profile picture

Sammy_G

#13
I went through all the TASC indicators' source code, they are all creating series. Can you point me to a specific indicator? Even better, how would you implement the Value method on the BS formula above? (faulty though the indicator is, I could learn from the example - which is all I need).
profile picture

Cone

#14
All indicators have a Series method. That's required. A Value method only makes sense for indicators that are "stable", unlike EMA, ATR, etc.

So, in TASCIndicators you'll find Value methods, for example, in Alpha, BearPowerVG, BullPowerVG, CG, FIRSmoother, TTF, ...
profile picture

Sammy_G

#15
Those Value methods are a subset of the Dataseries method, so extrapolation is a bit difficult for me. Can you point to an indicator/function that only uses the Value method? (Or, if you are not going out to play golf with Black & Scholes ;) ;) can you convert the formula above into an indicator using the Value method?)
*/

Oh, and thinking about the fact the code doesn't convert rates and times, etc. into decimal and year(s) internally made me realize that it actually wants the input in that format. So the original test code needs to be modified thus:
CODE:
Please log in to see this code.


and that yields the values one would expect! So the formula is right after all.
profile picture

Sammy_G

#16
I quickly checked some values generated by this formula against a couple of option calculators on the internet - www.cboe.com and http://www.margrabe.com/OptionPricing.html; while all three generate slightly different values, they are all reasonably close. So the formula may be included as a community indicator/study, if you wish.
profile picture

Eugene

#17
Good catch. I'll add it to Community Components in the upcoming update.
profile picture

Sammy_G

#18
May I make a suggestion? It might be better to modify the formula so that its more user-friendly - one that accepts time in days, percentages as whole numbers (thus 60 days will be input as 60, not as 0.1643835, 1% as 1, not as 0.01, etc); just a couple of lines of code will need to be added so that the formula can internally convert the input numbers into the required format.
profile picture

Eugene

#19
Feel free to modify it. I'll appreciate if you could submit your changes to me.
profile picture

Sammy_G

#20
Here you are, Eugene.
CODE:
Please log in to see this code.
profile picture

Eugene

#21
Thank you.
profile picture

Sammy_G

#22
Thank you, too. It was a collaborative effort.
profile picture

Eugene

#23
Added to Community Components 2010.10.
profile picture

sourkraut

#24
Very interesting.

Has anyone actually used BS to track options in Wealth-Lab, or is it being used strictly as an indicator to track potential option prices on the main symbbol?

I would dearly like to see some examples of how to code the changes of the days remaining, perhaps based on the "IsOptionExpiryDate" method, and cycling to the next option expiration monthe, after the current option expires.

Thanks,


Eb
profile picture

Eugene

#25
QUOTE:
I would dearly like to see some examples of how to code the changes of the days remaining, perhaps based on the "IsOptionExpiryDate" method, and cycling to the next option expiration monthe, after the current option expires.


Hope this helps:
TradingDaysBetweenDates
DaysBetweenDates
profile picture

sourkraut

#26
Yes indeed,

Thanks very much.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).