def savePregaoAjustes(): path1 = globalM.dataRoot + '/b3/ContratosPregaoAjuste/' dfs = [] for i, f in enumerate(genFile(2000, path1, 'ex_', 'extract_exe', 'txt')): dfs.append(_mongoImportB3BD_Ajustes_csv(f, path1)) # if i==10: # break uu.save_obj(dfs, 'b3_pregaoAjustes')
def savePremioEq(): #premio ref equities path1 = globalM.dataRoot + '/b3/_new/premioAcoes/' dfs = [] for i, f in enumerate(genFile(2000, path1, 'zip', 'extract_zip_exe', 'txt')): dfs.append(_mongoImportB3_premio_acoes_csv(f, path1)) # if i == 10: # break uu.save_obj(dfs, 'b3_premioEq')
def savepPesqXML(): path1 = globalM.dataRoot + '/b3/_new/pesquisapregao/' pesqs = [] for i, f in enumerate(genFile(2000, path1, 'zip', 'extract_zip_zip', 'xml')): pesqs.append(_mongoImportB3_BD_XML(f, path1)) # if i == 1: # break uu.save_obj(pesqs, 'b3_pesqXML')
def savePregaoFinal(path1=globalM.dataRoot + '/b3/ContratosPregaoFinal/'): #TODO: depurar e fazer codigo de insert no mongo #pregao final dfs = [] for i, f in enumerate(genFile(2000, path1, 'ex_', 'extract_exe', 'txt')): dfs.append(_mongoImportB3BD_Final_csv(f, path1)) # if i==10: # break uu.save_obj(dfs, 'b3_pregaoFinal')
def savePremioRef(): #premio ref path1 = globalM.dataRoot + '/b3/premio_ref/' dfs = [] for i, f in enumerate(genFile(2000, path1, 'ex_', 'extract_exe', 'txt')): dfs.append(_mongoImportB3_premio_csv(f, path1)) # if i == 10: # break #df=pd.concat(dfs) uu.save_obj(dfs, 'b3_premioREF')
def saveCadastroXML(): path1 = globalM.dataRoot + '/b3/_new/cadastroInstrumentos/' #cads=[] cad0 = None for i, f in enumerate(genFile(2000, path1, 'zip', 'extract_zip_zip', 'xml')): cadi = _mongoImportB3_cadastro_XML(f, path1) if cad0 is None: cad0 = cadi else: updateAccum(cad0, cadi, cadi[list(cadi.keys())[0]]['dt']) print(f) if i % 10 == 1: print('saving') uu.save_obj(cad0, 'b3_cadastroXML') # if i == 10: # break #df=pd.concat(dfs) uu.save_obj(cad0, 'b3_cadastroXML')
def saveCleanXML(fileCadastro='b3_cadastroXML', filePx='b3_pesqXML'): cad = uu.load_obj(fileCadastro) px = uu.load_obj(filePx) codes = list(set.union(*[set(p.keys()) for p in px])) codes1 = [ c for c in codes if c in cad and 'code' in cad[c] and ( any([cad[c]['code'].startswith(m) for m in mercList + otherMerc]) or ('nmInf' in cad[c] and cad[c]['nmInf'] == 'OptnOnEqtsInf')) ] cad_clean = Dict({c: cad[c] for c in codes1}) uu.save_obj(cad_clean, 'b3_cadastroXML_clean') #px_clean = [{c: p[c] for c in p if c in codes1} for p in px] px_clean = [ Dict({c: p[c] for c in set.intersection(set(p.keys()), set(codes1))}) for p in px ] uu.save_obj(px_clean, 'b3_pesqXML_clean')
def _getHolidaysXLS(): df = pd.read_excel(globalM.dataRoot + '/feriados_nacionais.xls', 'Plan1') f1 = lambda x: isinstance(x, dt) df = df.Data[df.Data.apply(f1)] uu.save_obj(df.values.tolist(), 'holidays_bz')
import socket import mUtil as uu ip=socket.gethostbyname(socket.gethostname()) uu.save_obj(ip,'ipBlp',path=r'F:\SISTDAD\MEMPGRP\BMORIER\python')