Solve for Implied Volatility in R

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]
}

Posted in Engineering | Leave a comment

Don’t Take My Word For It

In John Mauldin’s most recent letter, he had these wise words (among others) to offer…

I queried several venture capitalists, who see literally thousands and thousands of business proposals. While lots of people are working on it, they are aware of nothing on the near horizon. Water may be my #1 concern about the future. It is an intractable problem and one that must be solved. There is Microsoft- or Google-type wealth awaiting the team that creates an inexpensive way to purify water. Water management will be a major issue in the future. There are those who think we will go to war over oil or energy in the future. I rather doubt it. Water rights are going to be the issue that will divide nations and peoples unless we can find new technologies to create cheap supplies of fresh water and move it to where it is needed.

Posted in Desalination, Economics, Future, Water | Leave a comment

Bloom, there it is.

This is just a note, to Jeff in the Future, to check this out, later when more details are available.

Posted in Uncategorized | Leave a comment

Do I Make it look Easy?

Here we are, a greek crisis, a rate hike surprise and 4.33 Weeks Later

March Oil is above $77 USD, March 30 year is below 118, and March Gold is above $1100 / oz…

For this week…April Oil (Currently at $80.13) sees $79 before it sees $81…as models are adjusted against higher short term rates, and traders take profits. On a strong enough move to $79, we could see $77.50, by end of the week.

Posted in Uncategorized | Leave a comment

HOME

I encourage all those who can breathe, to watch this documentary called “HOME”. It’s available on youtube, in 720p. Beautiful footage, with an uncanny soundtrack, married to an essay on the current state of our planet’s macro energy and water issues. The director creates a chronologically building dormant climaxing experience, accented with appropriate deer-in-headlight facts.

Documentary

5 million youtube hits and climbing

Posted in Uncategorized | Leave a comment

End of Global Petrol Subsidies

While Washington moves towards action, New Delhi is talking about it

Governments know, they won’t be able to afford it, forever. Now is a good time to slip the legislation by the voters under the guise of reducing deficits.

Citizens in countries that don’t have similar subsidies in place, will end up feeling a little breathing room and end up consuming more oil sooner.

Countries that force their citizens to start and shoulder the volatility and global prices for energy, will end up struggling out of the recovery even more, and reduce consumption patterns immediately.

Net impact? Bearish for price in the short-term, but it could mean higher consumption rates in the interim. Leading to that inevitable price climb sooner.

Posted in Uncategorized | Leave a comment

Obama, are you taking notes? I know it’s all Greek to you.

To help, i’ve translated an article from a greek news paper, Ethnos. With the help of Yahoo!’s Babel Fish.

It sounds like, the administration in Greece, is going to try to basically do everything possible to correct their fiscal situation.

I’m slightly in awe, and almost disbelief, in the following:

…most Greeks back the government’s economic policy and consider the fiscal measures announced as necessary and fair, according two polls published in the weekend.
In a survey conducted by pollster Kapa Research and published on newspaper To Vima on Sunday, some 64 percent of participants said the measures were essential.
But 30.4 percent said the steps were not enough to help curb Greece’s borrowing costs and avert a further rating downgrade of the country.

That quote is from this piece, from reuters, “Greece sticks to austerity plan“.

Posted in Uncategorized | Leave a comment

Top 20

…reasons to short the world. Summarized nicely, by Market Watch writer, Paul Farrell. None of these, likely come as a suprise. I just, appreciated them, being so well organized. Here is a link, to the original piece.

1. Federal Budget Deficit Bomb. The Bush/Cheney wars pushed America deep into a debt hole. Federal debt limit was just raised almost 100% with Obama’s 2010 budget, to $14.3 trillion vs. $7.8 trillion in 2005. The Congressional Budget Office predicts future deficits around 4% through 2020. Get it? America’s debt at 84% of GDP will soon pass that toxic 90% trigger point.

2. U.S. Foreign Trade Bomb. Monthly deficits actually dropped from $50 billion per month to roughly $35 billion. But the total continues climbing as $400 billion is added each year. Foreigners now own $2.5 trillion of America, with China holding over $1.3 trillion in Treasury debt.

3. Weakening U.S. Dollar as Foreign Reserve Currency Bomb. Fear China and other currencies will replace dollar as main foreign reserves. The dollar’s fallen: The main index measuring dollar strength has gone from 120 at the Clinton-to-Bush handoff to below 80 today.

4. Cheap Money Bomb: Credit Ratings Down, Rates Up. Economists at S&P, Fitch and Moody’s were totally co-conspirators of Fat Cat Bankers, misleading investors before meltdown: Soon, debt up, ratings down, interest rates soar.

5. Global Real Estate Bomb. Dubai Tower, new “world’s tallest building” is empty. BusinessWeek warns that China’s housing collapse could be worse than America’s. Plus the U.S. commercial real estate bubble is now $1.7 trillion, a “ticking time bomb” bloating 25% of bank balance sheets.

6. Peak Oil and the Population Bomb. China and India each need 500 new cities. The United Nations estimates world population exploding 50% from 6 billion to 9 billion by 2050: Three billion more humans demanding more automobiles, exhausting more resources to feed their version of the gas-guzzling “America Dream.”

7. Social Security Bomb. We have no choice; eventually we must either cut benefits or raise taxes. Politicians hate both, so they’ll do nothing. Delays worsen solutions. Without action, by 2035 Social Security and Medicare benefits will eat up the entire federal budget other than defense.

8. Medicare: A Nuclear Bomb. Going broke faster than Social Security. Prescription drug benefit added an unfunded $8.1 trillion. In 5 years estimates rose from about $35 trillion to over $60 trillion now.

9. Health-care Insurance Bomb. Burden increasingly shifted to employees. Costs rising faster than inflation. Recent Obamacare plan would have cost $90 billion annually, paid to Big Pharma and insurers.

10. State and Local Government Budget Bombs. Deficits of $110 billion in 2010, $178 billion in 2011on top of more that $450 billion in underfunded state and municipal employee pension funds.

11. Underfunded Corporate Pensions Bomb. From $60 billion surplus in 2007 to $409 billion deficit in 2009. And a whopping 92% of the pension plans of companies are now underfunded. Defaults are guaranteed by taxpayers.

12. Consumer Debt Bomb. Americans are still living beyond their means. Even with a downturn, consumer debt rose from about $2.3 to $2.5 trillion. Fat Cat Bankers love it — yes love making matters worse by gouging cardholders and mortgagees, blocking help in foreclosures and bankruptcies.

13. Personal Savings Bomb. Before the 2008 meltdown savings rate dropped from about 10% in the early 1980s to below zero. Now it’s increasing, slowing retail recovery. Today, government’s the big “unsaver.”

14. War and Military Defense Deficits. Costs of Iraq and Afghanistan wars — $200+ billion annually, $3 trillion minimum, with massive long-term costs for veteran medical care, equipment renewal, recruitment.

15. Homeland Insecurity Bomb. Security at airports, seaports, borders, vulnerable chemical plants all increase budgets.

16. Fed/Treasury Bailout Bombs. Tax credits, loans, cash and purchase of toxic assets from Wall Street banks estimated at $23.7 trillion as new debt was shifted from too-big-to-fail Fat-Cat banks to taxpayers.

17. Insatiable Washington Lobbyists Bombs. Paulson, Goldman, Geithner, Morgan and Wall Street banks, through their lobbyists and former employees working inside now have absolute power over government spending. Democracy and voters are now irrelevant in America’s new corporate-socialism.

18. Shadow Banking: The Derivatives Bomb. Wall Street wants no regulation of this $670 trillion, high-risk, out-of-control casino that’s highly leveraged versus the $50 trillion total GDP of all nations. We forget that derivatives almost destroyed global economies in 2008-09, finally will by 2012.

19. Dysfunctional Two-Party Political Bomb. Polarized partisanship increasing: Every day both parties show zero interest in cooperating for the public good. Instead they fight viciously, resisting everything and anything proposed by opponents. Only goal: Score political points, make the other side look bad.

20. The Coming Populous Rebellion Bombs. Nobody trusts anyone in authority. For good reason. So immediate gratification, short-term betting and a lack of long-term perspective wins for individual investors, consumers and taxpayers as well as Washington, Wall Street and Corporate America CEOs. Today: “Doing what’s right for the common good and country” is just empty political rhetoric

Posted in Uncategorized | Leave a comment

DailyFX

…has a pretty good economic calendar.

Posted in Uncategorized | Leave a comment

If a Stock Falls in the Woods…

…people panic and buy government debt.

If government debt falls in the woods…

Does it make a sound?

Sooner or later, on worse than expected jobs data, yields on government debt will rise.

Posted in Uncategorized | Leave a comment

Promises of Entitlement

“I don’t see how our governments can pay these liabilities. EU and US net liabilities add up to around $135 trillion alone. That is four times the capitalization of Datastream’s World equity index of about $36 trillion, and forty times the cost of the 2008 financial crisis.”

- Dylan Grice
‘Popular Delusions’, Societe Generale, 12th November, 2009

H.T. John Mauldin

We are going to wake up one day, and the implied volatility on anything denominated in USD, will be 50x it’s historic average.

Posted in Uncategorized | Leave a comment

Saudis say…

Forget about it. Don’t worry. Be happy. Take another drag.

Posted in Uncategorized | Leave a comment

How will the Next 54 Years Play Out?

I can only imagine, the models built, to forecast the growth rate in the consumption of oil. Considering the multi-variable model, exhausts my cognitive ability.

I’m sure more resourceful men than I, have studied the problem deeper.

However, every now and again, I like crunching some numbers. You know, ball park, back of the number type stuff.

If the entire world, consumed oil at the rate the US does per capita, we would consume 411 M bbl/day. 4.8x, the current rate of consumption.

If the people who reported income in Canada, all shouldered the cost of the country’s oil consumption, at $73, 9% of the median income in Canada was spent on oil.

If the cost of consuming oil on the planet was shouldered by every person equally, and if the average income per person on the planet is in fact $10,500 then 3.08% of income is spent on oil.

Without population growth, and assuming constant growth in consumption (equal to the growth from 2004 to 2009, which is approximately equal to the growth rate of liquid production between 1958 to 2008), it would take 37 years for China and India to be consuming just as much as the world does now. Right now, they account for 1/8th of the total consumption.

Wikipedia, estimates 54 years remain before the current reserves of the 17 countries with the highest reserves, run dry. They calculate that, with today’s production data. Of course, this will be true, if production levels stay flat and new reserves are not found.

If China and India’s consumption, grow at the rate used above, for 33 years and the rest of the world continues consuming oil at the rate it does today, then world will be consuming about 118 bbl/day in the 33rd year. Integrate that data, and the total barrels consumed would be ~1.27 T barrels. There are 1.24 T barrels in reserves. So, not only does technology have to start extracting oil quicker, than it can today, but it also has to find more, otherwise – we’re 33 years from a very very dry well.

This back of the napkin goes out the window, if a country or two gets blown up.

The next time oil moves up $25, it will never look back.

Posted in Uncategorized | Leave a comment