def load_bbg_stock(sid_or_accessor, start=None, end=None, dvds=True):
    """terminal and datamgr are mutually exclusive.

    :param sid_or_accessor: security identifier or SidAccessor from DataManager
    :param start:
    :param end:
    :param dvds:
    :return:
    """
    end = end and pd.to_datetime(end) or pd.datetime.now()
    start = start and pd.to_datetime(start) or end + pd.datetools.relativedelta(years=-1)

    FLDS = ['PX_OPEN', 'PX_HIGH', 'PX_LOW', 'PX_LAST']
    DVD_FLD = 'DVD_HIST_ALL'
    RENAME = {'PX_OPEN': 'open', 'PX_HIGH': 'high', 'PX_LOW': 'low', 'PX_LAST': 'close'}

    accessor = _resolve_accessor(sid_or_accessor)
    sid = accessor.sid
    pxframe = accessor.get_historical(FLDS, start=start, end=end).rename(columns=RENAME)
    dvdframe = accessor.get_attributes(DVD_FLD, ignore_field_error=1)

    if isinstance(dvdframe, pd.DataFrame):
        dvdframe = dvdframe[['Ex-Date', 'Dividend Amount']].rename(
            columns={'Ex-Date': 'date', 'Dividend Amount': 'dvds'})
        dvdframe = dvdframe.set_index('date').sort_index()
        dvdframe = dvdframe.truncate(start, end)
        # sanity check - not expected currently
        # missing = dvdframe.index.difference(pxframe.index)
        missing = dvdframe.index - pxframe.index
        if len(missing) > 0:
            missing_dates = ','.join([m.strftime('%Y-%m-%d') for m in missing])
            raise Exception('dividends occur on non-business day, not expecting this. %s' % missing_dates)
        # another sanity check to ensure yahoo rolls dividends up, in case a special occurs on same day
        if not dvdframe.index.is_unique:
            dvdframe = dvdframe.groupby(lambda x: x).sum()
        pxframe = pxframe.join(dvdframe)
    pxs = InstrumentPrices(pxframe)
    return Instrument(sid, pxs, multiplier=1.)
def load_bbg_stock ( sid_or_accessor , start = None , end = None , dvds = True ) : end = end and pd . to_datetime ( end ) or pd . datetime . now ( ) start = start and pd . to_datetime ( start ) or end + pd . datetools . relativedelta ( years = - 1 ) FLDS = [ 'PX_OPEN' , 'PX_HIGH' , 'PX_LOW' , 'PX_LAST' ] DVD_FLD = 'DVD_HIST_ALL' RENAME = { 'PX_OPEN' : 'open' , 'PX_HIGH' : 'high' , 'PX_LOW' : 'low' , 'PX_LAST' : 'close' } accessor = _resolve_accessor ( sid_or_accessor ) sid = accessor . sid pxframe = accessor . get_historical ( FLDS , start = start , end = end ) . rename ( columns = RENAME ) dvdframe = accessor . get_attributes ( DVD_FLD , ignore_field_error = 1 ) if isinstance ( dvdframe , pd . DataFrame ) : dvdframe = dvdframe [ [ 'Ex-Date' , 'Dividend Amount' ] ] . rename ( columns = { 'Ex-Date' : 'date' , 'Dividend Amount' : 'dvds' } ) dvdframe = dvdframe . set_index ( 'date' ) . sort_index ( ) dvdframe = dvdframe . truncate ( start , end ) missing = dvdframe . index - pxframe . index if len ( missing ) > 0 : missing_dates = ',' . join ( [ m . strftime ( '%Y-%m-%d' ) for m in missing ] ) raise Exception ( 'dividends occur on non-business day, not expecting this. %s' % missing_dates ) if not dvdframe . index . is_unique : dvdframe = dvdframe . groupby ( lambda x : x ) . sum ( ) pxframe = pxframe . join ( dvdframe ) pxs = InstrumentPrices ( pxframe ) return Instrument ( sid , pxs , multiplier = 1. )
terminal and datamgr are mutually exclusive.

    :param sid_or_accessor: security identifier or SidAccessor from DataManager
    :param start:
    :param end:
    :param dvds:
    :return: