Example #1
0
 def opt_vol(self, type, symbol, option, underlying, day, month, year, strike):
     if type == "Equity":
         vol = 1
     elif option == "CALL":
         call = Call(underlying, day, month, year, strike)
         vol = float(call.implied_volatility())
     elif option == "PUT":
         put = Put(underlying, day, month, year, strike)
         vol = float(put.implied_volatility())
     else:
         vol = 0
     return vol
Example #2
0
    def opt_vol_r_T(self, type, symbol, option, underlying, day, month, year, strike):
        if type == "Equity":
            time = 1
            rate = 1
            vol = 1
        elif option == "CALL":
            call = Call(underlying, day, month, year, strike)
            time = call.BandS.T
            rate = float(call.BandS.r)
            vol = float(call.implied_volatility())
        elif option == "PUT":
            put = Put(underlying, day, month, year, strike)
            time = put.BandS.T
            rate = float(put.BandS.r)
            vol = float(put.implied_volatility())
        else:
            time = 0;
            rate = 0;
            vol = 0

        return time, rate, vol