示例#1
0
 def setSpotHist(self, start, end):
     '''
     Get history of daily spot prices
     :param start: start date
     :param end: end date
     :return: Series of spot prices
     '''
     self.spotHist = yf.download([self.undl], start=start,
                                 end=incDate(end))['Close']
     return self.spotHist
示例#2
0
 def setSpot(self, spotDate=''):
     '''
     :param spotDate (string date):
     :return: void, sets self.spot price to spot of self.mydate
     '''
     spotDate = self.mydate if spotDate == '' else spotDate
     self.spot = yf.download([self.undl],
                             start=spotDate,
                             end=incDate(spotDate))['Close'][0]
     return self.spot
示例#3
0
 def setVolHist(self, start, end, name='^VIX'):
     '''
     Get history of daily spot prices and set to self variable
     :param start: start date
     :param end: end date
     :param name: Name of volatility parameter
     :return: Series of vol prices
     '''
     self.volHist = yf.download([name], start=start,
                                end=incDate(end))['Close']
     return self.volHist
示例#4
0
 def setVol(self, volDate='', volIndex='^VIX'):
     '''
     :param volDate: Date to pull (default is self.mydate
     :param volIndex: Name of volatility index in yahoo finance
     :return: vol index (scaler)
     '''
     volDate = self.mydate if volDate == '' else volDate
     self.volPoint = yf.download([volIndex],
                                 start=volDate,
                                 end=incDate(volDate))['Close'][0]
     return self.volPoint
示例#5
0
 def setVolIdx(self,
               volidx,
               scale=0.02,
               voldate='',
               flattener=1,
               spacing=0.05):
     '''
     :param volidx (string): Name of a vol index for which to base the skew
     :param scale (double): Scaling factor for vol skew
     :param voldate (string date): Date to pull volatility
     :param flattener (double): Scaling factor. Amount to flatten (or steepen) skew
     :param spaceing: Determines the courseness the grid of strikes (how far apart strikes are)
     :return: The skew with the volidx being the ATM point
     spaced apart by 1% of the underlying
     '''
     voldate = self.mydate if voldate == '' else voldate
     myvol = yf.download([volidx], start=voldate,
                         end=incDate(voldate))['Close'][0]
     return self.computeSkew(myvol, scale, flattener, spacing=spacing)
示例#6
0
 def getVolIdx(self,
               volidx,
               scale=0.02,
               voldate='',
               flattener=1,
               skip=True,
               spacing=0.05):
     '''
     :param volidx (string): Name of a vol index for which to base the skew
     :param scale (double): Scaling factor for vol skew
     :param voldate (string date): Date to pull volatility
     :param flattener (double): Scaling factor. Amount to flatten (or steepen) skew
     :param skip (bool): If true then just get self.vol
     :param spaceing: Determines the courseness the grid of strikes (how far apart strikes are)
     :return: Returns the current vol index with a different skew and sets it to self.vol
     '''
     if len(self.vol) < 1 or not skip:
         voldate = self.mydate if voldate == '' else voldate
         myvol = yf.download([volidx], start=voldate,
                             end=incDate(voldate))['Close'][0]
         return self.computeSkew(myvol, scale, flattener, spacing=spacing)
     return self.vol