[Python] Bloomberg blpapi on Python with remote/server connection

Discussão em 'Python' iniciado por Stack, Junho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I am currently developing a new solution on Python using the Bloomberg api, and it is working very well, however I have to open a Bloomberg terminal each time I want to execute the code otherwise the api is not working. Does someone know if the Bloomberg api can be called on a server (by changing connection settings), instead of a local connection, allowing the code to be executed on airflow for instance instead of having to open Bloomberg every time?

    Here is the beginning of my code where the connection settings can be found:

    from __future__ import print_function
    from __future__ import absolute_import

    import blpapi
    import pandas as pd
    import pickle
    from optparse import OptionParser

    def parseCmdLine():
    parser = OptionParser(description="Retrieve reference data.")
    parser.add_option("-a",
    "--ip",
    dest="host",
    help="server name or IP (default: %default)",
    metavar="ipAddress",
    default="localhost")
    parser.add_option("-p",
    dest="port",
    type="int",
    help="server port (default: %default)",
    metavar="tcpPort",
    default=8194)

    (options, args) = parser.parse_args()

    return options

    def _get_flows_from_bbg(isin:int):
    global options
    options = parseCmdLine()

    # Fill SessionOptions
    sessionOptions = blpapi.SessionOptions()
    sessionOptions.setServerHost(options.host)
    sessionOptions.setServerPort(options.port)

    #print("Connecting to %s:%d" % (options.host, options.port))

    # Create a Session
    session = blpapi.Session(sessionOptions)


    Thanks in advance!

    Continue reading...

Compartilhe esta Página