def _updateyear(self, y): # docot if y<2011: url = 'http://cftc.gov/files/dea/history/com_disagg_xls_hist_2006_2010.zip' else: url = 'http://cftc.gov/files/dea/history/com_disagg_xls_%d.zip' % (y) df = parsecftc(url) return dropdupe(df, ['date', 'Market_and_Exchange_Names'])
def _loadarchive(self): if self._cache is not None: return session = Session(self.url, True, False, False) root = session.book.get_root_account() book = session.book account = book.get_root_account() commod_table = book.get_table() pdb = book.get_price_db() df = full_price_list(commod_table, pdb) df['value'] = df['num'] * 1.0 / df['denom'] session.end() session.destroy() self._cache = dropdupe(df, ['date', 'namespace', 'commod'])