Monday, June 27, 2011

Option Volatility Part 3

Now we are ready to look at the source code. I will once again post it to the usual place making it accessible to all. However, you will notice that this is the LITE version posted. If you are interested in a more efficient and user friendly version, then you can email me and I will send the PRO version to you for $3. The main difference in the PRO version is the more user-friendly graphical user interface. It is also more dynamic than the LITE version in the sense that will handle more of the work for you. I will point out the differences as we go through the source code. Also, one major advantage and distinction between the PRO and LITE version is that the PRO version will use the Black_Scholes model to calculate a "fair" option premium. Whereas, the lite version renders a buy or sell decision purely based on volatility. Lastly, the PRO version takes Gamma and Theta into account, while the Lite version does not. This means that the Lite version produces a very theoretical option premium and represents a snapshot in time.

Firstly, here it is: optionVolatilityLite.py .

We are going to do this analysis on an August 2011 340 Call .

When the program is first run, it produces the following GUI:
Notice that the entry fields are white, while the output fields are not able to be edited (grayed out).
Step 1: Select the file containing the closing price data for the stock you wish to analyze. (Similar to the pair trading program)
Step 2: Enter in the current price of the stock. (Pro version does this for you.)
Step 3: Enter in the strike price, days to expiration, call or put, option premium, implied volatility, delta, and vega values for the option you want to analyze. All of these values will be provided to you by your brokerage.

Now we will look at how that information is entered, using an August 2011 340 Call. The GUI will now look like this after you have entered in the appropriate information:
Notice that the Implied Volatility is entered in in decimal format. It will be given to you in a format such as 26.4%, but you will enter it in as .264. Also, you must type in, exactly, "Call" or "Put". After the information is entered, we are ready to press the "Compute Results" button.




After pressing the button, the GUI will now look like this:
The program will then calculate the Historical Volatility based on the text file full of closing prices for the most recent 30 days. If that calculated value is greater than the Implied Volatility you listed, then it will render a "Buy" decision. (If less than implied volatility, a "Sell" decision) It will then calculate a one standard deviation range of stock prices based on the current implied volatility and the number of days to expiration. Next, it will calculate the necessary volatility change to hit the upper or lower bound of the standard deviation range (depending on whether you are Buying/Selling a Call/Put.) Lastly, it will calculate a new theoretical premium for hitting the optimal bound (again, lower or upper bound depending on whether you are Buying or Selling, and whether it is a Call or Put) and the profit associated with that new premium.

Please look through the source code that I linked to and email me your questions. Also, if you would like to inquire about purchasing the PRO version email me, and it will be available through pay-pal.

Thursday, June 23, 2011

Option Volatility Part 2

Today we will discuss the methodology behind a Python program to calculate historic volatility, in order to generate a decision on whether to buy or short a particular option.

We need to keep a few things in mind before we move on. REMEMBER this: We want to buy when implied volatility is low and sell when implied volatility is high. Moreover, we want to buy when implied volatility is less than historical volatility and sell when implied volatility is greater than historical volatility.

Lets go over the inputs for our model:
  1. Historical Stock Prices (a text file full of closing prices, similar to the Pair Trading Program)
  2. Current Stock Price
  3. Strike Price
  4. Days to Expiration
  5. Call or Put
  6. Listed Option Premium
  7. Listed Implied Volatility
  8. Delta Value
  9. Vega Value
What we would like as outputs:
  1. Historical/Statistical Volatility (annualized)
  2. Indicator as to whether HV/SV is greater than, less than, or equal to IV
  3. One Standard Deviation Range of Stock Prices based on IV (at expiration with standard normal curve)
  4. Volatility change needed to hit upper and lower bound of Standard Dev. Range based on Vega
  5. Corresponding new THEORETICAL option premium price after the hitting upper or lower bound of the range
  6. Profit Per Contract based on theoretical new option premium
Methods for calculating outputs:
  1. To calculate HV/SV, we will read in the last 30 data points for closing prices of a given security, we will make a list of the day to day price changes, then we will calculate the standard deviation of the list and annualize it by multiplying by the square root of 254.
  2. Now that we have a number for HV/SV, we will compare it to the IV number that was an input. If HV > IV, then we will output a  BUY decision. If HV < IV, then we will output a SELL decision.
  3. We will take the Current Stock price that was given as an input, and we will multiply it by the Implied Volatility input and the square root of the days to expiration. Lastly, we will divide this number by the square root of 254, and add and subtract this number from the current price to get our range.
  4. After we have calculated an upper bound from step three, we will take the upper bound number and subtract the current stock price from it. Once we have this difference, we will multiply it by the delta value, then divide by the Vega value to come up with the necessary change in % of volatility.
  5. This was already calculated in the last step, but the new THEORETICAL option premium is equal to the current premium plus the difference in the current stock price and upper bound of the range calculated in step 3 multiplied by Delta.
  6. Simply, the theoretical option price minus the current option premium multiplied by 100.
Note that the calculations will vary based on whether we are BUYING a put/call, or SELLING a put/call. This will be detailed in the code. I will be making a LITE and PRO version of the tool, I will provide a link to the LITE version of the code. However, the PRO version of the tool, which will contain many enhancements, will be for sale. If you are experienced option trader, then you will note that I left out Gamma which is critical for determining the "acceleration" of an option premium. The PRO version will incorporate this input into its pricing model, but for simplicities sake, the LITE version will assume more linear/basic movement.

I know this is a lot to digest...So again, if you have any question please email me at programtotrade@gmail.com

Part 3 will consist of links to the actual source code, as well as a demonstration of the tool using a current option.

Wednesday, June 22, 2011

Option Volatility Part 1

Unfortunately, for the sake of brevity, I will not be able to explain every single concept or term that I invoke within this blog. But... any questions you may have can surely be answered here: Option Volatility . In fact, I would HIGHLY recommend that anyone interested in Options read the link above.

Or... I have built a google search tool at the top right corner of the blog page that I have linked only to credible sources of information. You can type any financial term into that search bar and be confident that you will get a trustworthy answer to your question.

Continuing on, by the end of Part 3 of this series we will have a Python Program that takes in certain option inputs and calculates a fair value for the premium, which is very useful in terms of evaluating an option position. Today, I will go over some of the basic factors and inputs behind option pricing.

Before we begin, it is important to understand that the fair value of an option is using calculated using the Black-Scholes Model . Essentially, there are 5 inputs for option price calculation:
  1. Stock Price
  2. Strike Price
  3. Historical Volatility
  4. Days to Expiration
  5. Risk-free Rate of Interest
The output is the FAIR value of an option, which conveniently is not always equal to the market value.

Lets start with Volatility. There are two aspects:

Historical/Statistical Volatility - this is a value we can physically calculate based on past price movements. It basically tells us how much a security might move in the present or near future based on the price changes it experienced in the past. Note that HV/SV does not tell us anything about the direction of movement.

How HV/SV is calculated? It is calculated by taking looking at the closing prices for a given period (usually 10, 20, or 30 day period), calculating the percentage change from day to day (close to close), and finally we calculate a standard deviation of the percentage price changes and annualize it by multiplying the standard deviation by the square root of 254 (number of trading days in a year). For a detailed example calculation, reference the link at the top of the page. This method is the most basic and popular method for calculating HV/SV.

Implied Volatility - this metric is very important in determining whether an option is currently over-valued or under-valued. It is very often ignored by traders, but IV is often the reason that option traders are baffled when the underlying increases and their option premium does not. The link at the top of the post gives a great example using a tech stock in which a trader speculated a big move, however, when the big move occurred his option did not gain in value. This is because the move was already priced into the Option, which the trader would have seen if they had looked at how high the IV was.

How do we get the value for IV? Almost all online brokerages provide you with an IV number. Essentially, if you refer to the five inputs listed earlier, IV is calculated by changing the Fair Value output to a "market price" input, and then solving for volatility. It is a very math-y calculation, so I will spare you from it for now.


Actionable Result: Ultimately, we need HV/SV and IV to be different from each other. In this sense we can figure out if an option is under-valued or over-valued.

When IV > HV/SV -- Options are thought to be Over-Valued
When IV < HV/SV -- Options are thought to be Under-Valued

It is useful to define a few more Option relevant terms:

Delta - Measure of the sensitivity of an option price to the changes in the underlying's price (stock price).

Vega - Measure of the sensitivity of an option price to changes in Volatility.

It is important to have a firm grasp on both of these concepts because they can move together or against each other.

The delta value is one of the more straight-forward metrics of an Option, if the delta value is +0.5 for an Option, then for every $1 dollar that the Stock (Underlying) price increases, the option premium will increase by $0.5 dollars or 50 cents. It is simply a ratio of option price movement divided by underlying price movement.

For the Vega value, you can think of it as either betting on rising volatility ("long" volatility) or falling volatility ("short" volatility). This is very similar to being long or short on a stock, if you are "long" volatility and volatility increases then you are profiting. Conversely, if you are "short" volatility and volatility declines then you are profiting. Technically, Vega is defined as the amount that an option price changes for a 1% change in Volatility. For instance, if the Vega value for an option is -96, then if volatility increases by 1% the option price will decrease by $96 dollars.

We now have a basic understanding of all the inputs in option pricing. In Part 2, we will start to set up the methodology for our program, and how all the inputs come together to form a "decision." In Part 3, we will look at the actual source code and an execution of a decision on a particular option.

Tuesday, June 21, 2011

Greece....And Other European Countries that Don't Make Enough and Spend Too Much

Today will be the last post before I start the next series regarding Option Volatility. For the subject of Option Volatility, we will again be utilizing Python computer programming to write some programs.

Now on to the topic of why countries like Spain, Portugal, Ireland, and Greece are in the mess that they are.

1. Slow Growth Rates


 Note that Spain, Ireland, Greece, and Portugal are all sitting well below average in growth rates. This is an alarming statistic, unless they can control their spending by an equal or greater percentage as their declining growth rate. (UNLIKELY!)

2. High Unemployment Percentages
Notice again the higher than average unemployment rates present in Spain, Portugal, Ireland, and Greece. Spain for example is hovering around 20 percent unemployment; if they continue to sustain that high of an unemployment level while also maintaining slow growth rates, then the country will implode in a similar fashion as Greece.

3. Living Beyond Their Means

Here we look at debt as a percentage of overall GDP. The countries that are in trouble, as you can see, are looking at elevated percentages of debt as compared to GDP.

These countries continue to take on more and more debt, while their growth rates stagnate and unemployment increases.

It doesn't take much more than looking at these three charts to see that, maybe -- just maybe, Greece is really just the tip of the iceberg. Hold on Europe, you are in for a rough ride.