def export_security_history(security, global_rows=None): if global_rows == None: rows = [GUARDIAN_HISTORY_HEADER] else: rows = [] isin = security.aliases.filter(alias_type__name="ISIN") if isin.exists(): isin = isin[0].alias_value else: isin = None bloomberg = security.aliases.filter(alias_type__name="BLOOMBERG") if bloomberg.exists(): bloomberg = bloomberg[0].alias_value else: bloomberg = None external_information = external_content.get_security_information( GUARDIAN_DATASOURCE, isin=isin, bloomberg=bloomberg ) if external_information != None: content = get_main_track(security, True, False) if content != None: for token in content: row = [] row.append(token["date"]) row.append(external_information["cod_tit"]) row.append(None) row.append(None) row.append(None) row.append(None) row.append(token["value"]) row.append(None) rows.append(row) else: LOGGER.warn( "Security " + str(security.name) + " could not be found with [BLOOMBERG=" + str(bloomberg) + ", ISIN=" + str(isin) + "]" ) if global_rows == None: save_path = os.path.join(WORKING_PATH, security.name + "_HISTORY_" + str(datetime.date.today()) + ".xlsx") simple_xlsx_dump(rows, save_path) return save_path else: return rows
def get_security_divisor(sec_code): return get_security_information('guardian', None, None, sec_code)[u'divisore']