def num_tkrs_in_bundle(bundle_name): return len(get_ticker_sid_dict_from_bundle(bundle_name)) if __name__ == '__main__': fields = ['member'] dimensions = ['SP500'] from zipline.data.bundles.core import register from alphacompiler.data.loaders.sep_quandl import from_sep_dump BUNDLE_NAME = 'sep' register( BUNDLE_NAME, from_sep_dump('.'), ) num_tickers = num_tkrs_in_bundle(BUNDLE_NAME) print('number of tickers: ', num_tickers) all_tickers_for_bundle(fields, dimensions, 'sep') # downloads the data to /raw pack_sparse_data( num_tickers + 1, # number of tickers in buldle + 1 os.path.join(BASE, RAW_FLDR), fields, ZIPLINE_DATA_DIR + FN) # write directly to the zipline data dir print("this worked master")
def demo(): # demo works on free data tickers = {"WMT": 3173, "HD": 2912, "DOGGY": 69, "CSCO": 2809} fields = ["GP", "CAPEX", "EBIT", "ASSETS"] populate_raw_data(tickers, fields) def all_tickers_for_bundle(fields, bundle_name, raw_path=os.path.join(BASE, RAW_FLDR)): tickers = get_ticker_sid_dict_from_bundle(bundle_name) #populate_raw_data({"WMT":3173, "HD":2912, "DOGGY":69, "CSCO":2809}, fields, raw_path) populate_raw_data(tickers, fields, raw_path) return len(tickers) if __name__ == '__main__': #demo() #fields = ["ROE_ART", "BVPS_ARQ", "SPS_ART", "FCFPS_ARQ", "PRICE"] fields = ["marketcap", "pb"] num_tickers = all_tickers_for_bundle(fields, 'quantopian-quandl') pack_sparse_data( num_tickers + 1, # number of tickers in buldle + 1 os.path.join(BASE, RAW_FLDR), fields, os.path.join(BASE, FN)) print("this worked boss")
else: all_fields = all_fields.join(df) # join data of all fields # write to file: raw/ all_fields.to_csv("{}/{}.csv".format(RAW_FLDR, sid)) except quandl.errors.quandl_error.NotFoundError: print("error with ticker: {}".format(ticker)) def demo(): # demo works on free data tickers = {"WMT": 3173, "HD": 2912, "DOGGY": 69, "CSCO": 2809} fields = ["GP", "CAPEX", "EBIT", "ASSETS"] populate_raw_data(tickers, fields) def all_tickers_for_bundle(fields): tickers = get_ticker_sid_dict_from_bundle('quantopian-quandl') populate_raw_data(tickers, fields) if __name__ == '__main__': #demo() fields = ["ROE_ART", "BVPS_ARQ", "SPS_ART", "FCFPS_ARQ", "PRICE"] #all_tickers_for_bundle() pack_sparse_data(3193, BASE + RAW_FLDR, fields, BASE + FN) print("this worked boss")