Example #1
0
def save_time_series_csv(ts, id):
    utils.serialise_csv(ts, get_csv_filename(id))
Example #2
0
def get_bbg_data():
    t = datetime.datetime.today()
    today_date = datetime.datetime(t.year, t.month, t.day)
    start_date =  datetime.datetime(1990, 1, 1)
    end_date = today_date  - datetime.timedelta(1)
    index_list = ('SPX Index', 'DJI Index', 'RTY Index')
    equity_set = set()
    for index in index_list:
        field = ''
        if index == 'DJI Index':
            field = 'INDX_MWEIGHT'
        else:
            field = 'INDX_MWEIGHT_HIST'

        idx_data = data_retrieval.get_time_series(
            'download_bbg_timeseries', 
            {
                'symbol': index, 
                'start': start_date, 
                'end': end_date,
                'field' : field
            })
        if idx_data is not None:
            utils.serialise_csv(idx_data, data_retrieval.get_csv_filename('_'.join((index, 'COMPOSITION'))))
            for date,equity_list in idx_data:
                equity_set.update(equity_list)

    fields = (
        'PX_LAST', 
        'PX_OFFICIAL_CLOSE', 
        'PX_OPEN', 
        'PX_LAST',
        'PX_OPEN',
        'PX_LOW',
        'TOT_RETURN_INDEX_GROSS_DVDS',
        'DAY_TO_DAY_TOT_RETURN_GROSS_DVDS',
        'EQY_DPS',
        'SECURITY_DES',
        'TRAIL_12M_GROSS_MARGIN',
        'ASSET_TURNOVER',
        'BS_SH_OUT',
        'TRAIL_12M_CASH_FROM_OPER',
        'CF_CASH_FROM_OPER',
        'BS_LT_BORROW',
        'LT_DEBT_TO_TOT_ASSET',
        'LIVE_LT_DEBT_TO_TOTAL_ASSETS',
        'CUR_RATIO',
        'CASH_RATIO',
        'QUICK_RATIO',
        'NET_INCOME',
        'CF_CASH_FROM_OPER',
        'RETURN_ON_ASSET',
        'EBIT',
        'EBITDA',
        'TOT_DEBT_TO_TOT_ASSET',
        'TOT_DEBT_TO_COM_EQY',
        'BS_TOT_ASSET',
        'HISTORICAL_MARKET_CAP')


    for equity in equity_set:
        equity = equity + " Equity"
        for field in fields:
            equ_data = data_retrieval.get_time_series(
                'download_bbg_timeseries', 
                {
                    'symbol': equity, 
                    'start': start_date, 
                    'end': end_date,
                    'field' : field
                })
            if equ_data is not None:
                utils.serialise_csv(equ_data, data_retrieval.get_csv_filename('_'.join((equity, field))))