Skip to content

Commit

Permalink
Bump to v3.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
msitt committed Jul 19, 2023
1 parent 015faff commit ec021c4
Show file tree
Hide file tree
Showing 34 changed files with 588 additions and 180 deletions.
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: blpapi
Version: 3.19.3
Version: 3.20.1
Summary: Python SDK for Bloomberg BLPAPI
Home-page: http://www.bloomberglabs.com/api/
Author: Bloomberg L.P.
Expand Down
24 changes: 21 additions & 3 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
Version 3.20.1:
===============
- Support for application identity key (AIK)
The application identity key (AIK) is obtained through Bloomberg for registered
applications. It uniquely identifies the registered application for a given Session
and can be provided by 'SessionOptions.setApplicationIdentityKey'.

- Stability and performance improvements

Version 3.20.0:
===============
- Add SOCKS5 proxy support
Users can configure, per endpoint in `SessionOptions`, a single SOCKS5
proxy host by using `Socks5Config` class. SOCKS5 authentication is not
supported.

- Stability and performance improvements

Version 3.19.3:
==============
- Add 'expected_cpp_sdk_version()' method that returns a minimum compatible
Expand Down Expand Up @@ -77,13 +95,13 @@ Version 3.17.0:
to convert a 'Message' to 'dict' with 'Message.toPy'. 'Message's and
'Request's have 'dict'-like behavior with '__getitem__' and
'__setitem__'.

- A new method 'correlationId()' is added to 'blpapi.Message'
A new method 'Message.correlationId()' is added to return the
single CorrelationId associated with the message or None if the
message has no CorrelationIds. If the message has multiple
CorrelationIds, the first one is returned.

- Constants for common used `Names`
A new utility class `blpapi.Names` has been added with common
message names.
Expand Down Expand Up @@ -174,7 +192,7 @@ Version 3.15.0:
- Simplified existing multi-phased approach to authorization so that both
token generation and authorization can be done by the SDK.
- If 'AuthOptions' instance is provided to the session through the
newly introduced 'setSessionIdentityOptions' (part of'SessionOptions'),
newly introduced 'setSessionIdentityOptions' (part of 'SessionOptions'),
both token generation and subsequent authorization will be done by the
SDK. Successfully authorized identity would become the default
identity for the session that's used for all future requests unless
Expand Down
2 changes: 0 additions & 2 deletions examples/demoapps/ApiFieldsExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def main():
if eventType == blpapi.Event.REQUEST_STATUS:
for msg in event:
if msg.messageType() == blpapi.Names.REQUEST_FAILURE:

# Request has failed, exit
print(msg)
done = True
Expand All @@ -108,7 +107,6 @@ def main():
blpapi.Event.RESPONSE,
blpapi.Event.PARTIAL_RESPONSE,
]:

processResponse(options.requestType, event)

# Received the final response, no further response events are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def _handleException(self, session, _2, exception):
self._stop(session)

def _handleSessionStarted(self, session, _1, _2):

# Add the authorization message handlers after the session
# started to only react to the authorization messages of users,
# i.e., avoid those of the session identity.
Expand Down Expand Up @@ -217,7 +216,6 @@ def _distributeResponses(self, userIdentifier, identity):
self._distributeResponse(event, userIdentifier, identity)

def _distributeResponse(self, event, userIdentifier, identity):

for msg in event:
if msg.hasElement(RESPONSE_ERROR, excludeNullElements=True):
continue
Expand Down
1 change: 0 additions & 1 deletion examples/demoapps/MultipleRequestsOverrideExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


def main():

parser = ArgumentParser(
formatter_class=RawTextHelpFormatter,
description="Multiple requests with override example",
Expand Down
1 change: 0 additions & 1 deletion examples/demoapps/RequestServiceProviderExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def parseCmdLine():


def processEvent(event, session):

print("Server received an event")

if event.eventType() == blpapi.Event.REQUEST:
Expand Down
1 change: 0 additions & 1 deletion examples/demoapps/SubscriptionWithEventPollingExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def processSubscriptionEvents(session, maxEvents):
f"Received init paint with RequestId {msg.getRequestId()}"
)
else:

# SESSION_STATUS events can happen at any time and
# should be handled as the session can be terminated,
# e.g. session identity can be revoked at a later
Expand Down
1 change: 0 additions & 1 deletion examples/demoapps/UserModeExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def _handleSessionStarted(
_event: blpapi.Event,
_msg: blpapi.Message,
):

# Add the authorization messages handlers after the session
# started to only react to the authorization messages of users,
# i.e., avoid those of the session identity.
Expand Down
59 changes: 51 additions & 8 deletions examples/demoapps/util/ConnectionAndAuthOptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from blpapi_import_helper import blpapi
from argparse import Action
from collections import namedtuple


_SESSION_IDENTITY_AUTH_OPTIONS = "sessionIdentityAuthOptions"
Expand Down Expand Up @@ -69,16 +70,38 @@ def __call__(self, parser, args, values, option_string=None):
setattr(args, _SESSION_IDENTITY_AUTH_OPTIONS, authOptions)


HostPort = namedtuple("HostPort", ["host", "port"])
ServerAddress = namedtuple("ServerAddress", ["endpoint", "socks5"])


class HostAction(Action):
"""The action that parses host options from user input"""

def __call__(self, parser, args, values, option_string=None):
vals = values.split(":", 1)
@staticmethod
def _parseHostPort(parser, value):
vals = value.split(":", 1)
if len(vals) != 2:
parser.error(f"Invalid host option '{value}'")

maxPortValue = 65535
if int(vals[1]) <= 0 or int(vals[1]) > maxPortValue:
parser.error(
f"Invalid port '{value}', value must be 1 through {maxPortValue}"
)
return HostPort(vals[0], vals[1])

def __call__(self, parser, args, values, option_string=None):
endpointSocks5 = values.split("/", 1)
if len(endpointSocks5) == 0 or len(endpointSocks5) > 2:
parser.error(f"Invalid host option '{values}'")

endpoint = HostAction._parseHostPort(parser, endpointSocks5[0])
socks5 = None
if len(endpointSocks5) == 2:
socks5 = HostAction._parseHostPort(parser, endpointSocks5[1])

hosts = getattr(args, self.dest)
hosts.append((vals[0], int(vals[1])))
hosts.append(ServerAddress(endpoint, socks5))


class UserIdIpAction(Action):
Expand Down Expand Up @@ -106,8 +129,9 @@ def addConnectionAndAuthOptions(parser, forClientServerSetup=False):
"-H",
"--host",
dest="hosts",
help="server name or IP (default: 127.0.0.1:8194). Can be specified multiple times.",
metavar="host:port",
help="Endpoint host:port and optional SOCKS5 host:port to use to connect"
" (default: localhost:8194). Can be specified multiple times.",
metavar="host:port[/socks5Host:socks5Port]",
action=HostAction,
default=[],
)
Expand Down Expand Up @@ -291,18 +315,37 @@ def createSessionOptions(options):
)
else:
sessionOptions = blpapi.SessionOptions()
for idx, host in enumerate(options.hosts):
sessionOptions.setServerAddress(host[0], host[1], idx)
for idx, serverAddress in enumerate(options.hosts):
socks5Config = (
blpapi.Socks5Config(
serverAddress.socks5.host, int(serverAddress.socks5.port)
)
if serverAddress.socks5
else None
)
sessionOptions.setServerAddress(
serverAddress.endpoint.host,
int(serverAddress.endpoint.port),
idx,
socks5Config,
)

if tlsOptions:
sessionOptions.setTlsOptions(tlsOptions)

sessionOptions.setSessionIdentityOptions(
options.sessionIdentityAuthOptions
)

def serverAddressToString(server: ServerAddress):
tostr = ":".join(server.endpoint)
if server.socks5:
tostr = f"{tostr}/{':'.join(server.socks5)}"
return tostr

print(
f"Connecting to "
f"{', '.join([h[0] + ':' + str(h[1]) for h in sessionOptions.serverAddresses()])}"
f"{', '.join([serverAddressToString(h) for h in options.hosts])}"
)

return sessionOptions
Expand Down
1 change: 0 additions & 1 deletion examples/demoapps/util/events/SessionRouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def printEvent(event: blpapi.Event):


class SessionRouter:

EventHandler = Callable[[blpapi.AbstractSession, blpapi.Event], None]
MessageHandler = Callable[
[blpapi.AbstractSession, blpapi.Event, blpapi.Message], None
Expand Down
1 change: 0 additions & 1 deletion examples/unittests/market-data-notifier/src/appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class AuthOptionsAction(Action): # pylint: disable=too-few-public-methods
"""Parse authorization args from user input."""

def __call__(self, parser, args, values, option_string=None):

value = values
vals = value.split("=", 1)

Expand Down
1 change: 1 addition & 0 deletions examples/unittests/market-data-notifier/src/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import print_function


# pylint: disable=too-few-public-methods
class Application:
"""Custom application for demonstration purposes."""
Expand Down
1 change: 1 addition & 0 deletions examples/unittests/market-data-notifier/src/authorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

TOKEN = blpapi.Name("token")


# pylint: disable=too-few-public-methods, too-many-branches
class Authorizer:
"""Helper for authorization."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Dummy 'compute engine' for testing purposes"""


# pylint: disable=too-few-public-methods, no-init, no-self-use
class ComputeEngine:
"""A class that does some 'financial computation'."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
TOKEN = blpapi.Name("token")
LAST_PRICE = blpapi.Name("LAST_PRICE")


# pylint: disable=too-few-public-methods
class EventProcessor:
"""Custom EventHandler implementation for demonstration purposes."""
Expand Down
1 change: 1 addition & 0 deletions examples/unittests/market-data-notifier/src/notifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Sample class for testing purposes."""
from __future__ import print_function


# pylint: disable=no-init,no-self-use
class Notifier:
"""
Expand Down
1 change: 1 addition & 0 deletions examples/unittests/market-data-notifier/src/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import blpapi


# pylint: disable=too-few-public-methods,too-many-arguments
class Subscriber:
"""Custom Subscriber implementation for demonstration purposes."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
TOKEN_FAILURE = blpapi.Names.TOKEN_GENERATION_FAILURE
TOKEN = blpapi.Name("token")


# pylint: disable=too-few-public-methods
class TokenGenerator:
"""Generates a token for later authorization."""
Expand Down
2 changes: 2 additions & 0 deletions examples/unittests/snippets/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def testSessionConnectionUp(self):
"serverId": "ny-hostname",
"encryptionStatus": "Clear",
"compressionStatus": "Uncompressed",
"socks5Proxy": "socks5Host:1080",
}

formatter.formatMessageDict(content)
Expand All @@ -118,6 +119,7 @@ def testSessionConnectionDown(self):
content = {
"server": "12.34.56.78:8194",
"serverId": "ny-hostname",
"socks5Proxy": "socks5Host:1080",
}

formatter.formatMessageDict(content)
Expand Down
2 changes: 1 addition & 1 deletion src/blpapi.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: blpapi
Version: 3.19.3
Version: 3.20.1
Summary: Python SDK for Bloomberg BLPAPI
Home-page: http://www.bloomberglabs.com/api/
Author: Bloomberg L.P.
Expand Down
2 changes: 1 addition & 1 deletion src/blpapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
SubscriptionPreprocessError,
SubscriptionPreprocessMode,
)
from .sessionoptions import SessionOptions, TlsOptions
from .sessionoptions import SessionOptions, TlsOptions, Socks5Config
from .subscriptionlist import SubscriptionList
from .topic import Topic
from .topiclist import TopicList
Expand Down
Loading

0 comments on commit ec021c4

Please sign in to comment.