Jarloo

Menu

Calculate the name of a financial option

Recently the way options were named in the North America was changed to a much better system that supports any option expiry date which allowed for weekly options. Here is a method that will take information on options such as symbol, option expiry date, put/call and strike, and it will return the name of the option in this new option format. You can then use the option name to look up the current price somewhere such as Yahoo.

Please keep in mind this is for North American Options only.

public static string GetOptionName(string symbol, DateTime expiry, decimal strike, char putCall)
{
    if (putCall != 'P' && putCall != 'C') throw new ArgumentException();

    return symbol.ToUpper() +
            expiry.ToString("yyMMdd") +
            putCall +
            Convert.ToInt32(strike*1000).ToString("00000000");
}

Thats it! Much easier then the old format. To call the function just do this:

string optionName = GetOptionName("AAPL", new DateTime(2011, 10, 21), 400, 'C');

Categories:   Code, Finance

Tags:  , , ,

Comments

  • Posted: October 15, 2011 09:42

    ct

    Nice option symbol tip thanks!