Example #1
0
def refresh_bond_universe():
    """Function to refresh bond universe. Function is called by:
    FlowTradingGUI > MainForm.onUpdateBondUniverse()
    """
    bonds = pandas.ExcelFile(DEFPATH + "bonduniverse.xls").parse("list", index_col=0, has_index_names=True)
    targetBonds = (
        bonds.loc[pandas.isnull(bonds["SECURITY_NAME"]), "REGS"] + " Corp"
    ).to_dict()  # this works better than coupon
    targetFields = list(set(bonds.columns) - set(["REGS", "144A", "TRADITION", "BGC", "GARBAN", "TULLETT", "GFI"]))
    bonds.loc[targetBonds.keys(), targetFields] = blpapiwrapper.simpleReferenceDataRequest(targetBonds, targetFields)
    print bonds.loc[targetBonds.keys(), targetFields]
    bonds.to_excel(DEFPATH + "bonduniverse.xls", "list")
    print "The file bonduniverse.xls has been updated."
Example #2
0
def refresh_bond_universe_old():
    """Function to refresh bond universe. Function is called by:
    FlowTradingGUI > MainForm.onUpdateBondUniverse()
    """
    bonds = pandas.ExcelFile(DEFPATH + "bonduniverse.xls").parse("list", index_col=0, has_index_names=True)
    targetBonds = bonds[pandas.isnull(bonds["SECURITY_NAME"])]  # this works better than coupon
    targetFields = list(set(bonds.columns) - set(["REGS", "144A", "TRADITION", "BGC", "GARBAN", "TULLETT", "GFI"]))
    blpts = blpapiwrapper.BLPTS(list(targetBonds["REGS"] + " Corp"), targetFields)
    blpts.get()
    blpts.closeSession()
    blpts.output["REGS"] = blpts.output.index.str[:-5]
    blpts.output["Bond"] = blpts.output["REGS"].replace(isinsregs)
    blpts.output.set_index("Bond", inplace=True)
    bonds.loc[blpts.output.index, targetFields] = blpts.output
    print blpts.output
    bonds.to_excel(DEFPATH + "bonduniverse.xls", "list")
    print "The file bonduniverse.xls has been updated."
Example #3
0
def refresh_bond_universe_very_old():
    """Function to refresh bond universe. Function is called by:
    FlowTradingGUI > MainForm.onUpdateBondUniverse()
    """
    bbgapi = blpapiwrapper.BLP()
    bonds = pandas.ExcelFile(DEFPATH + "bonduniverse.xls").parse("list", index_col=0, has_index_names=True)
    for bond in bonds.index:
        if pandas.isnull(bonds.loc[bond, "COUPON"]):
            print "Updating " + bond
            for field in bonds.columns:
                if field in ["REGS", "144A", "TRADITION", "BGC", "GARBAN", "TULLETT", "GFI"]:
                    continue
                x = bbgapi.bdp(bonds.loc[bond, "REGS"] + " Corp", str(field))  # otherwise field is u'string'
                if field == "COUPON" or field == "AMT_OUTSTANDING":
                    x = float(x)
                if field == "MATURITY":
                    x = x[5:7] + "/" + x[:2] + "/" + x[:4]
                bonds.loc[bond, field] = x
            print bonds.loc[bond]
    bonds.to_excel(DEFPATH + "bonduniverse.xls", "list")
    print "The file bonduniverse.xls has been updated."