def main():
    # -------------------------[Set-up]-------------------------
    ticker = Ticker('MSFT')
    optionManager = OptionManager(ticker, now=None)

    i = 0  # <- Time To Maturity curve
    exp = optionManager.getExpirations()[i]

    optionChain = optionManager.getOptionChain(exp=exp)
    # ----------------------------------------------------------

    start_time = time.time()
    impliedVolatility = ImpliedVolatility(optionChain)
    curve = impliedVolatility.getImpliedVolatility()
    print('chrono: {}'.format(time.time() - start_time))

    fig, ax = plt.subplots(figsize=(8, 5))
    ax.set(xlabel='Strike',
           ylabel='Volatility',
           title='Option implied volatility ({})'.format(
               ticker.getInfo().ticker))

    ax.plot(curve.calls.strike,
            curve.calls.IV,
            label='Calls',
            color='green',
            alpha=.5)
    ax.plot(curve.puts.strike,
            curve.puts.IV,
            label='Puts',
            color='red',
            alpha=.5)

    ax.plot(curve.calls.strike,
            curve.calls.naturalIV,
            linestyle='dotted',
            label='Original Calls',
            color='green')
    ax.plot(curve.puts.strike,
            curve.puts.naturalIV,
            linestyle='dotted',
            label='Original Puts',
            color='red')

    plt.legend()
    plt.show()
"""

import matplotlib.pyplot as plt
import numpy as np

from EcoFin.dataDownload.optionsManager import OptionManager
from EcoFin.dataDownload.ticker import Ticker
from EcoFin.options.blackScholesModel import BSM
from EcoFin.stat.equityVolatility import EquityVolatility

# -------------------------[Set-up]-------------------------
ticker = Ticker('MSFT')
optionManager = OptionManager(ticker, now=None)

i = 0  # <- Time To Maturity curve
exp = optionManager.getExpirations()[i]

optionChain = optionManager.getOptionChain(exp=exp)
# ----------------------------------------------------------

strikeList = optionChain.getStrikeList()

volatility_back = 260
series = ticker.getHistory(
    end=optionChain.getChainDate()).tail(volatility_back)
price = optionChain.getSpotPrice()

r = optionChain.getRiskFreeRate()
sigma = EquityVolatility(series).meanSigma()
maturity = optionChain.getTimeToMaturity().days