def bookValue(firm, date, pdatabase, printWarnings=True, bookUnit=1000000):
    """
    Firm's book value as of latest quarterly earnings report preceding date
    Relies on naming of pdatabase (compustat) and chronological data for each firm
    Returns -1 if no data available
    Returns FLOAT
    """
    bookQuery = pdatabase.data.query('(tic == "' + firm + '") & (datadate < ' + date + ')')
    # print(bookQuery)
    if bookQuery.empty:
        if printWarnings:
            print("NO BOOK DATA: " + firm + ", " + date)
        return -1
    bookSeries = bookQuery["ceqq"]
    return float(bookSeries.iat[bookSeries.size - 1] * bookUnit)