[Python] Bloomberg Python Query Returning unknown ValueError

Discussão em 'Python' iniciado por Stack, Outubro 4, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to query specific Bloomberg tickers and write them into an excel. The code itself is pretty straightforward and I have gotten it to work for all tickers except "Move Index". When querying for the this particular ticker, I am getting the exception: raise ValueError(data) ValueError: []. I blocked out the particular query code with try-except to get more information about the error, but it's still returning the same exception with no further detail.

    import os
    from blp import blp
    import pdblp
    import blpapi
    import datetime
    import xlwings
    import pandas as pd
    import win32com.client
    import pythoncom
    import sys
    import os
    from PIL import ImageGrab

    with open(os.path.join(os.getenv("TEMP"), "Bloomberg", "log", "bbcomm.log"),"r") as f:
    try:
    port = f.read().split("BLOOMBERG COMMUNICATION SERVER READY on Port: ")[-1].split("\n")[0]
    except:
    port = 8194

    con = pdblp.BCon(debug = False, port = 8194, timeout = 10000000)
    con.start()
    today = datetime.datetime.today()

    value_growth = con.bdh(['SVX Index','SGX Index'],'PX_Last',elms=[("periodicitySelection", "WEEKLY")], start_date="20220107",end_date= "20800101")
    ten_year = con.bdh(['USGG10YR Index', 'USGG2YR Index'], 'PX_Last',elms=[("periodicitySelection", "WEEKLY")], start_date="20220107",end_date= "20800101" )
    spx_drivers = con.bdh(['SPX Index','USGG2YR Index'],'PX_Last',elms=[("periodicitySelection", "WEEKLY")], start_date="20220107",end_date= "20800101" )
    bloomberg = con.bdh(['GBTP10YR Index','GDBR10 Index','BICLB10Y Index','VIX Index','USGGT05Y Index','.EUCCBS3M G Index','CSI BARC Index','LP02OAS Index','V2X Index','SPX Index', 'SGX Index','S5INDU Index','RTY Index','CO1 Comdty','HG1 Comdty','USGGBE05 Index','XAU Curncy','XBTUSD Curncy'],'PX_Last', elms=[("periodicitySelection", "WEEKLY")], start_date="20220107",end_date= "20800101")
    bloomberg1 = con.bdh('Move index', 'PX_Last',elms=[("periodicitySelection", "WEEKLY")], start_date="20220107",end_date= "20240101")
    bloomberg_merged = pd.concat([bloomberg,bloomberg1], axis = 1)
    with pd.ExcelWriter(r'FILE PATH', engine='openpyxl', if_sheet_exists='overlay', mode='a') as writer:
    value_growth.to_excel(writer, sheet_name='Value_Growth', startcol=0, startrow= 581, header = False)
    ten_year.to_excel(writer, sheet_name='10Y_drivers', startcol = 0, startrow = 216, header = False)
    spx_drivers.to_excel(writer, sheet_name= 'SPX_Drivers', startcol = 0, startrow = 216, header = False)
    bloomberg_merged.to_excel(writer, sheet_name='Bloomberg', startcol=0, startrow=579, header = False)


    My questions are:

    1. I know its a very niche question but has anyone had any success querying Move Index in Bloomberg through python?
    2. How can I better understand what the actual Valueerror is?

    Continue reading...

Compartilhe esta Página