Exemplo n.º 1
0
def get_bdp_list(sym_list, field):
    '''
    Like the bdp excel function but gets field for a list of securities
    
    Parameters
    ----------
    sym_list:  List of Bloomberg tickers in the form of <sym> <exchg> Equity
    field: The field to get
    
    Returns
    -------
    
    '''
    blp = blp_test.BLPInterface()
    bdp_item = blp.referenceRequest(sym_list, field)
    return bdp_item
Exemplo n.º 2
0
def get_bdp_single(ticker, field):
    '''
    Like the bdp excel function
    
    Parameters
    ----------
    ticker: Bloomberg ticker in the form of <sym> <exchg> Equity
    field: The field to get
    
    Returns
    -------
    Just a single number based on ticker and field.
    '''
    blp = blp_test.BLPInterface()
    bdp_item = blp.referenceRequest(ticker, field)
    return bdp_item
Exemplo n.º 3
0
def get_bdh(ticker, field_list, startdate=None, enddate=None):
    '''
    Like the bdh function
    
    Parameters
    ----------
    ticker: Bloomberg ticker in the form of <sym> <exchg> Equity
    startdate: YYYYMMDD, default is today - 104 weeks
    enddate: YYYYMMDD, default is today
    enddate must be later than startdate
    '''
    blp = blp_test.BLPInterface()
    if startdate == None:
        startdate = (datetime.today() -
                     dt.timedelta(weeks=52)).strftime('%Y%m%d')
    if enddate == None:
        enddate = datetime.today().strftime('%Y%m%d')
    price_hist_bbg = blp.historicalRequest(ticker, field_list, startdate,
                                           enddate)
    price_hist_bbg.rename(columns={'PX_LAST': ticker}, inplace=True)
    return price_hist_bbg
Exemplo n.º 4
0
def get_bbg_prices(ticker, startdate=None, enddate=None):
    '''
    Use the Bloomberg API to get the price history. Normally accessed from 
    the get_prices function
    
    Parameters
    ----------
    ticker: Bloomberg ticker in the form of <sym> <exchg> Equity
    startdate: YYYYMMDD, default is today - 104 weeks
    enddate: YYYYMMDD, default is today
    enddate must be later than startdate
    '''
    blp = blp_test.BLPInterface()
    if startdate == None:
        startdate = (datetime.today() -
                     dt.timedelta(weeks=104)).strftime('%Y%m%d')
    if enddate == None:
        enddate = datetime.today().strftime('%Y%m%d')
    field_list = ['PX_LAST']
    price_hist_bbg = blp.historicalRequest(ticker, field_list, startdate,
                                           enddate)
    price_hist_bbg.rename(columns={'PX_LAST': ticker}, inplace=True)
    return price_hist_bbg