Skip to content

Commit 4732f70

Browse files
committed
Add version 3.9.0.
1 parent 0f9d541 commit 4732f70

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+11050
-2484
lines changed

PKG-INFO

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Metadata-Version: 1.0
22
Name: blpapi
3-
Version: 3.5.5
4-
Summary: Python SDK for Bloomberg BLPAPI (3.5.5)
5-
Home-page: http://open.bloomberg.com/
3+
Version: 3.9.0
4+
Summary: Python SDK for Bloomberg BLPAPI (<=3.9)
5+
Home-page: http://www.bloomberglabs.com/api/
66
Author: Bloomberg L.P.
7-
Author-email: UNKNOWN
7+
Author-email: [email protected]
88
License: UNKNOWN
99
Description: UNKNOWN
1010
Platform: UNKNOWN

README

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
Bloomberg Python API version 3.5
1+
Bloomberg Python API version 3.9
22
================================
33

44
This directory contains an interface for interacting with Bloomberg API
5-
services using the Python programming language.
5+
services using the Python programming language. This package is the source
6+
installer, and requires a C compilation environment compatible with Python's
7+
`distutils` package. Windows users without such an environment are encourage to
8+
instead use the appropriate binary installer, available from
9+
<http://www.bloomberglabs.com/api/libraries/>.
610

711

812
Dependencies
913
------------
1014

1115
This SDK requires the following products:
1216

13-
- CPython version 2.6 or 2.7
17+
- CPython version 2.6 or higher
1418

15-
- Bloomberg C++ SDK version 3.5 or later
19+
- Bloomberg C++ SDK version 3.9 or later
1620

1721
- Visual C++ 2008 or 2010 (Windows) or GCC 4.1+ (Linux)
1822

@@ -24,8 +28,12 @@ Note that installation requires a working C compiler and the C headers
2428
distributed as part of the Bloomberg C++ SDK.
2529

2630
1. Set the `BLPAPI_ROOT` environment variable to the location at which the
27-
Bloomberg C++ SDK is installed. (On Windows, this location may be of the
28-
form `C:\blp\API\APIv3\C++API\v3.5.2.1\`.)
31+
Bloomberg C++ SDK is installed. (This is the directory containing the
32+
`include` directory. On linux this may be of the form
33+
`$HOME/blpapi_cpp_3.9.5.1`; on Windows, this location may be of the
34+
form `C:\blp\API\APIv3\C++API\v3.9.5.1\`.) Note that this is environment
35+
variable is required only for *installing* the `blpapi` package, not for
36+
running blpapi python applications.
2937

3038
2. To compile and install the `blpapi` Python package for all users, run
3139

@@ -88,7 +96,7 @@ Documentation for individual Bloomberg API classes and functions is provided
8896
through Python's built-in help system.
8997

9098
Further documentation on programming the Bloomberg API is available in the
91-
Developer's Guide, available at <http://open.bloomberg.com>.
99+
Developer's Guide, available at <http://www..bloomberglabs.com/api/>.
92100

93101

94102
Examples
@@ -105,11 +113,11 @@ line.
105113
Implementation Notes
106114
--------------------
107115

108-
- The Python Bloomberg SDK does not provide direct support for Python `unicode`
109-
objects. Clients can pass unicode data to SDK functions accepting strings by
110-
calling `u.encode('utf-8')` for an appropriate `unicode` object `u`; a string
111-
`s` received from an SDK function can be converted to a `unicode` object by
112-
calling `s.decode('utf-8')`.
116+
- The Bloomberg SDK for Python 2 does not provide direct support for Python
117+
`unicode` objects. Clients can pass unicode data to SDK functions accepting
118+
strings by calling `u.encode('utf-8')` for an appropriate `unicode` object
119+
`u`; a string `s` received from an SDK function can be converted to a
120+
`unicode` object by calling `s.decode('utf-8')`.
113121

114122
- Python Bloomberg SDK types do not provide support for the Python `copy` or
115123
`pickle` modules.

blpapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# __init__.py
22

3-
from __future__ import absolute_import
3+
44

55
from .internals import CorrelationId
66

blpapi/abstractsession.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,29 @@
44
55
This file defines a class 'AbstractSession' - an interface which is shared
66
between its concrete implementations 'Session' and 'ProviderSession'.
7+
8+
SERVICE IDENTIFIER
9+
------------------
10+
A service identifier is the fully qualified service name which uniquely
11+
identifies the service in the API infrastructure. A service must be of the
12+
form "//<namespace>/<service-name>" where '<namespace>' and '<local-name>' are
13+
non-empty strings of characters from the set '[-_.a-zA-Z0-9]'. Service
14+
identifiers are case-insensitive, but clients are encouraged to prefer
15+
identifiers without upper-case characters. Note that the <namespace> and
16+
<service-name> cannot contain the character '/'.
717
"""
818

9-
from __future__ import absolute_import
19+
1020

1121
from .exception import _ExceptionUtil
1222
from .identity import Identity
1323
from .service import Service
1424
from . import internals
1525
from .internals import CorrelationId
1626
from . import utils
27+
from .compat import with_metaclass
1728

18-
29+
@with_metaclass(utils.MetaClassForClassesWithEnums)
1930
class AbstractSession(object):
2031
"""A common interface shared between publish and consumer sessions.
2132
@@ -256,8 +267,7 @@ def createIdentity(self):
256267

257268
# Protect enumeration constant(s) defined in this class and in classes
258269
# derived from this class from changes:
259-
__metaclass__ = utils.MetaClassForClassesWithEnums
260-
270+
261271
__copyright__ = """
262272
Copyright 2012. Bloomberg Finance L.P.
263273

blpapi/compat.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# compat.py
2+
3+
import sys
4+
5+
""" Different compatibility tools. Needed to support both
6+
2.x and 3.x python versions."""
7+
8+
def with_metaclass(metaclass):
9+
"""Python 2 and 3 different metaclass syntax workaround. Should be used as a decorator."""
10+
def wrapper(cls):
11+
vars = cls.__dict__.copy()
12+
slots = vars.get('__slots__')
13+
if slots is not None:
14+
if isinstance(slots, str):
15+
slots = [slots]
16+
for slots_var in slots:
17+
vars.pop(slots_var)
18+
vars.pop('__dict__', None)
19+
vars.pop('__weakref__', None)
20+
return metaclass(cls.__name__, cls.__bases__, vars)
21+
return wrapper
22+
23+
# NOTE: this function should be used to convert integer values to long
24+
# values in both python2 and 3.
25+
26+
if sys.version.startswith('2'):
27+
def tolong(val):
28+
return long(val)
29+
else:
30+
def tolong(val):
31+
return int(val)
32+
33+
# NOTE: python2 wrapper uses byte strings (str type) to pass strings to C-functions,
34+
# unicode type is not supported so we need to encode all strings first.
35+
# On the other hand, python3 wrapper uses unicode strings (str type) for this so we need
36+
# to decode byte-strings first to get unicode strings. Rule of thumb: to pass string to any
37+
# wrapper function convert it using `conv2str` function first, to check that type of the
38+
# string is correct - use `isstr` function.
39+
40+
if sys.version.startswith('2'):
41+
def conv2str(s):
42+
"""Convert unicode string to byte string."""
43+
if isinstance(s, str):
44+
return s
45+
elif isinstance(s, unicode):
46+
return s.encode('utf-8')
47+
else:
48+
return None
49+
50+
def isstr(s):
51+
if isinstance(s, (str, unicode)):
52+
return True
53+
return False
54+
else:
55+
def conv2str(s):
56+
"""Convert byte string to unicode string."""
57+
if isinstance(s, bytes):
58+
return s.decode()
59+
elif isinstance(s, str):
60+
return s
61+
else:
62+
return None
63+
64+
def isstr(s):
65+
if isinstance(s, (bytes, str)):
66+
return True
67+
return False
68+
69+
# NOTE: integer typelist for different python versions to use with isinstance builtin function
70+
if sys.version.startswith('2'):
71+
int_typelist = (int, long)
72+
else:
73+
int_typelist = (int,)

blpapi/constant.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
a representation for lists of such constants
1111
"""
1212

13-
from __future__ import absolute_import
13+
1414

1515
from .exception import _ExceptionUtil, NotFoundException, \
1616
IndexOutOfRangeException
@@ -179,7 +179,7 @@ def datatype(self):
179179
def hasConstant(self, name):
180180
"""True if this 'ConstantList' contains an item with this 'name'.
181181
182-
Returns True if this 'ConstantList' contains an item with the specified
182+
Return True if this 'ConstantList' contains an item with the specified
183183
'name', and False otherwise.
184184
185185
Exception is raised if 'name' is neither a Name nor a string.
@@ -208,11 +208,11 @@ def getConstant(self, name):
208208
return Constant(res, self.__sessions)
209209

210210
def getConstantAt(self, position):
211-
"""Return the 'Constant' at the specified 'index'.
211+
"""Return the 'Constant' at the specified 'position'.
212212
213-
Return the 'Constant' at the specified 'index' in this 'ConstantList'.
214-
If 'index' is not in the range from 0 to numConstants() - 1 then an
215-
exception is raised.
213+
Return the 'Constant' at the specified 'position' in this
214+
'ConstantList'. If 'position' is not in the range from 0 to
215+
'numConstants() - 1' then an exception is raised.
216216
"""
217217
res = internals.blpapi_ConstantList_getConstantAt(self.__handle,
218218
position)

blpapi/datatype.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
'DataType' - "enum" representing all possible data types in an Element.
77
"""
88

9-
from __future__ import absolute_import
9+
1010

1111
from . import internals
1212
from . import utils
13+
from .compat import with_metaclass
1314

1415

15-
class DataType:
16+
@with_metaclass(utils.MetaClassForClassesWithEnums)
17+
class DataType(object):
1618
"""Contains the possible data types which can be represented in an Element.
1719
1820
Class attributes:
@@ -70,10 +72,6 @@ class DataType:
7072
CORRELATION_ID = internals.DATATYPE_CORRELATION_ID
7173
"""Used for some internal messages"""
7274

73-
# Protect enumeration constant(s) defined in this class and in classes
74-
# derived from this class from changes:
75-
__metaclass__ = utils.MetaClassForClassesWithEnums
76-
7775
__copyright__ = """
7876
Copyright 2012. Bloomberg Finance L.P.
7977

blpapi/datetime.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
"""Utilities that deal with blpapi.Datetime data type"""
44

55
from __future__ import absolute_import
6+
from __future__ import division
67

78
from . import internals
89
from . import utils
10+
from .compat import with_metaclass
911

1012
import datetime as _dt
1113

1214

15+
@with_metaclass(utils.MetaClassForClassesWithEnums)
1316
class FixedOffset(_dt.tzinfo):
1417
"""Time zone information.
1518
@@ -43,29 +46,43 @@ class FixedOffset(_dt.tzinfo):
4346
"""
4447

4548
def __init__(self, offsetInMinutes=0):
46-
_dt.tzinfo.__init__(self)
4749
self.__offset = _dt.timedelta(minutes=offsetInMinutes)
4850

4951
def utcoffset(self, unused):
5052
return self.__offset
5153

5254
def dst(self, unused):
53-
return FixedOffset._dt.timedelta(0)
55+
return _dt.timedelta(0)
5456

5557
def getOffsetInMinutes(self):
56-
return self.__offset.days * 24 * 60 + self.__offset.seconds / 60
58+
return self.__offset.days * 24 * 60 + self.__offset.seconds // 60
5759

5860
def __hash__(self):
5961
"""x.__hash__() <==> hash(x)"""
6062
return self.getOffsetInMinutes()
6163

6264
def __cmp__(self, other):
63-
"""Let the comparison operations work based on the time delta."""
65+
"""Let the comparison operations work based on the time delta.
66+
NOTE: (compatibility) this method have no special meaning in python3,
67+
we should use __eq__, __lt__ and __le__ instead. Built-in cmp function
68+
is also gone. This method can be called only from python2."""
6469
return cmp(self.getOffsetInMinutes(), other.getOffsetInMinutes())
6570

66-
# Protect enumeration constant(s) defined in this class and in classes
67-
# derived from this class from changes:
68-
__metaclass__ = utils.MetaClassForClassesWithEnums
71+
def __eq__(self, other):
72+
"""Let the equality operator work based on the time delta."""
73+
return self.getOffsetInMinutes() == other.getOffsetInMinutes()
74+
75+
def __lt__(self, other):
76+
"""Let the comparison operator work based on the time delta."""
77+
return self.getOffsetInMinutes() < other.getOffsetInMinutes()
78+
79+
def __le__(self, other):
80+
"""Let the comparison operator work based on the time delta."""
81+
return self.getOffsetInMinutes() <= other.getOffsetInMinutes()
82+
83+
84+
# UTC timezone
85+
UTC = FixedOffset(0)
6986

7087

7188
class _DatetimeUtil(object):
@@ -126,7 +143,7 @@ def convertToBlpapi(dtime):
126143
res.hours = dtime.hour
127144
res.minutes = dtime.minute
128145
res.seconds = dtime.second
129-
res.milliSeconds = dtime.microsecond / 1000
146+
res.milliSeconds = dtime.microsecond // 1000
130147
res.parts = internals.DATETIME_DATE_PART | \
131148
internals.DATETIME_TIMEMILLI_PART
132149
elif isinstance(dtime, _dt.date):
@@ -139,7 +156,7 @@ def convertToBlpapi(dtime):
139156
res.hours = dtime.hour
140157
res.minutes = dtime.minute
141158
res.seconds = dtime.second
142-
res.milliSeconds = dtime.microsecond / 1000
159+
res.milliSeconds = dtime.microsecond // 1000
143160
res.parts = internals.DATETIME_TIMEMILLI_PART
144161
else:
145162
raise TypeError("Datetime could be created only from \

blpapi/diagnosticsutil.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# coding: utf-8
2+
3+
#@PURPOSE: Provide api to access diagnostics information on the blpapi library
4+
#
5+
#@DESCRIPTION: This component provide a collection of functions which give
6+
# access to various sets of diagnostics information on the 'blpapi' library.
7+
8+
import internals
9+
10+
11+
def memoryInfo():
12+
"""Return the string describing the 'blpapi' library's memory usage; the
13+
format of the string is platform-specific."""
14+
return internals.blpapi_DiagnosticsUtil_memoryInfo_wrapper()

0 commit comments

Comments
 (0)