Archive for the ‘Engineering’ Category

Solve for Implied Volatility in R

Sunday, March 7th, 2010

I have written a fairly basic “Effective Position & Risk Management System” in R, for managing asset positions with several option legs.
Every morning, it paints me a pie chart of where I’m getting my theta decay, as well as my effective exposure to each of the major asset classes.

One of the requirements, is calculating the Implied Volatility of each option. I found some approximations, interesting, but none seem to be as intelligent as using a brute force method or bi-section method.

I wrote a recursive function and used it for a month, but it took forever, or got lost and produced errors. Obviously, I was faced with playing with step size/factor and accuracy trade-offs.

So, I’m currently using a brute-force method, which seems to work well and faster than the recursive algorithm. It’s not perfect, but it’s working. If anybody out there on the interwebs has a better or more beautiful solution, let me know. Here it is:

FindIV <- function(OptionMarketPrice, AssetPrice, Time, Strike, r, LowRange, HighRange, Right)
{
Range <- seq(LowRange,HighRange,by=((HighRange-LowRange)/100000))
OptionBasedOnGuess <- GBSOption(Right, AssetPrice, Strike, Time, r, 0.000, Range, "wtf", "xx")
Error <- OptionBasedOnGuess@price - OptionMarketPrice
Key <- which.min(abs(Error))
Range[Key]
}

Protected: I Have a Short Message to The Planet, Please Read It All

Sunday, February 8th, 2009

This post is password protected. To view it please enter your password below:


Path of the Planet

Saturday, January 3rd, 2009

This post will come as no surprise to Engineers who have studied controls, or to others like Nate Hagens and Gregor Macdonald.  But, looking at the earth like a multi-variable-non-linear system, with feedback loops designed to keep her in equilibrium, have been struck by the equivalent of a delta function it has never felt before.

Population

See, when engineers go to model a problem, in order to create forecasts they use an impulse, or a step function, then measure the response.  For linear systems, these responses are additive.  That is, to create a forecast for what would happen if there were two impulses, you can simply add the two responses together.  This gets extremly math intensive, and “convoluted” would be the best appropriate pun, but what happens to some systems is – instability.  Unstable systems don’t have the appropriate feedback necessary for the system to find an equilibrium, or they have feedback that overshoots, only to cause overshoot in the other direction.

Applying this to earth, in a crude qualitative way, what you get is things like supply and demand problems, extreme weather and extinction…because natural systems, will attempt to find equilibrium.  Anyway, below is the basic mathematical template that instability often embodies.  My theory is that between the law of large numbers, a growing population, and information continuing to flow faster – this is the path we’re on…I can’t prove it, but there are many signs that oil, water, and other variables will follow a more complicated path, but one like this:

Path

Markets, 3 mile Island & Oil

Friday, June 27th, 2008

What does today’s market have to do with 3 mile Island? Oil.

I sat down with a top manager at Ontario Power Generation (the largest nuclear site in North America) late last night, a mechanical engineer and my girlfriend’s father. It is his opinion that the nuclear industry is a unique one, in the way that competition actually share intelligence and research, rather than attempt to leverage it over the competition. The reason is that, any accident looks bad on the entire industry. It is his opinion that without the problems at 3 mile island, the US would today, have ~70% of their power from nuclear. Instead, American’s have a sever case of NIMBY syndrome, and it stems from lack of education about the sector.

You can see where, uranium prices would be higher, oil would be cheaper, and the markets would not be selling off on oil climbing.

Nuclear is one of the only answers, technologically, because of the requirement for the base load. Sure, wind and solar can offset the need, but a sustainable base load, is a feat of engineering.

The picture show above, is 3 mile island.

Blows my mind, that a major market force, can, in this day and edge be summed up with “People are scared of what they do not understand”.