示例#1
0
def getExpectedPriceRangeTillNextExpiryDays(underlyingPrice, impVol):
    """
    Get the expected price range of an underlying at the next
    monthly expiry.

    Parameters
    ----------
    underlyingPrice : price of the underlying stock
    impVol : implied volatility of the underlying

    Returns
    -------

    """
    print('underlyingPrice: ', type(underlyingPrice))
    print('impVol: ', type(impVol))

    try:
        priceTimesImpvol = underlyingPrice * impVol
        sqrtOfDaysDiv = math.sqrt(
            dateUtils.daysToExpiry(dateUtils.getNextExpiryDate()) / 365)
    except ValueError:
        print("****   in getExpectedPriceRangeTillNextExpiryDays")
        print("          ValueError: ", ValueError)
        print('          underlyingPrice: ', underlyingPrice)
        print('          impVol: ', impVol)
        return 0

    return round((priceTimesImpvol * sqrtOfDaysDiv), 2)
示例#2
0
def displayUnderlyingDetails(aTableWidget, expiryDate):

    aTableWidget.stockLast.setText('{:>7.2f}'.format(aTableWidget.an_option_spread.theUnderlyingReqTickerData.last))

    aTableWidget.stockClose.setText('{:>7.2f}'.format(aTableWidget.an_option_spread.theUnderlyingReqTickerData.close))

    aTableWidget.putOpenInterest.setText('{:>7.0f}'.format(aTableWidget.an_option_spread.theUnderlyingReqTickerData.putOpenInterest))

    aTableWidget.callOpenInterest.setText('{:>7.0f}'.format(aTableWidget.an_option_spread.theUnderlyingReqTickerData.callOpenInterest))

    totalOpenInterest = aTableWidget.an_option_spread.theUnderlyingReqTickerData.callOpenInterest + \
                        aTableWidget.an_option_spread.theUnderlyingReqTickerData.putOpenInterest
    aTableWidget.totalOpenInterest.setText('{:>7.0f}'.format(totalOpenInterest))

    aTableWidget.callVolume.setText('{:>7.0f}'.format(aTableWidget.an_option_spread.theUnderlyingReqTickerData.callVolume))

    aTableWidget.putVolume.setText('{:>7.0f}'.format(aTableWidget.an_option_spread.theUnderlyingReqTickerData.putVolume))

    theTotalVolume = aTableWidget.an_option_spread.theUnderlyingReqTickerData.putVolume + \
               aTableWidget.an_option_spread.theUnderlyingReqTickerData.callVolume
    aTableWidget.totalVolume.setText('{:>7.0f}'.format(theTotalVolume))

    aTableWidget.daysToExpiry.setText('{:>7.0f}'.format(dateUtils.daysToExpiry(expiryDate)))

    aTableWidget.impliedVol.setText('{:.2%}'.format(aTableWidget.an_option_spread.impliedVolatility))
def getExpectedPriceRangeTillNextExpiryDays(underlyingPrice, impVol):
    """
    Get the expected price range of an underlying at the next
    monthly expiry.

    using:
    (Stock Price * IV)/SQRT(Days to Expiry/#Days in a Year)

    suggest using: # todo -- update to this Expected Price Range - do not think this is correct
                   # todo -- continue to include Days to Expiry. 6/10/2020
    (Stock Price * IV)/SQRT(#Days in a Year)


    Parameters
    ----------
    underlyingPrice : price of the underlying stock
    impVol : implied volatility of the underlying

    Returns
    -------

    """
    # print('underlyingPrice: ', type(underlyingPrice))
    # print('impVol: ', type(impVol))

    try:
        priceTimesImpvol = underlyingPrice * impVol
        sqrtOfDaysDiv = math.sqrt(
            dateUtils.daysToExpiry(dateUtils.getNextExpiryDate()) / 365)

    except ValueError:
        print("****   in getExpectedPriceRangeTillNextExpiryDays")
        print("          ValueError: ", ValueError)
        print('          underlyingPrice: ', underlyingPrice)
        print('          impVol: ', impVol)
        return 0

    return round((priceTimesImpvol * sqrtOfDaysDiv), 2)