Skip to content

Commit bb03a09

Browse files
committed
add support for python >= 3.8
1 parent dbb8f6f commit bb03a09

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
requests>=2.20.0
22
simplejson>=3.10.0
33
enum34>=1.1.6
4-
websocket-client>=0.54.0,<0.58.0
4+
websocket-client>=1.6.4

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="pyRofex",
8-
version="0.5.0rc1",
8+
version="0.5.0",
99
author="Franco Zanuso",
1010
author_email="francozanuso89@gmail.com",
1111
description="Python connector for ROFEX's Rest and Websocket APIs.",
@@ -18,7 +18,7 @@
1818
'requests>=2.20.0',
1919
'simplejson>=3.10.0',
2020
'enum34>=1.1.6',
21-
'websocket-client>=0.54.0,<0.58.0',
21+
'websocket-client>=1.6.4',
2222
],
2323
classifiers=[
2424
"Programming Language :: Python :: 3",

src/pyRofex/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
pyRofex: Python connector for ROFEX Rest and Websocket APIs.
44
5-
This modules expose functions and enumerations of the library.
5+
This module expose functions and enumerations of the library.
66
"""
77
from .service import initialize
88
from .service import set_default_environment
@@ -46,4 +46,4 @@
4646
from .components.enums import Side
4747
from .components.enums import TimeInForce
4848

49-
__version__ = "0.5.0rc1"
49+
__version__ = "0.5.0"

src/pyRofex/clients/websocket_rfx.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77
import threading
88
import time
9-
import ssl
9+
import logging
1010

1111
import websocket
1212
import simplejson
@@ -149,7 +149,7 @@ def connect(self):
149149
if self.ws_connection.sock is None or not self.ws_connection.sock.connected:
150150
self.on_exception(ApiException("Connection could not be established."))
151151

152-
def on_message(self, message):
152+
def on_message(self, ws, message):
153153
""" Called when a new message is received through the connection.
154154
155155
:param message: message received.
@@ -186,7 +186,7 @@ def on_message(self, message):
186186
except Exception as e:
187187
self.on_exception(e)
188188

189-
def on_error(self, exception):
189+
def on_error(self, ws, exception):
190190
""" Called when an error occurred within the connection.
191191
192192
:param exception: exception raised.
@@ -204,13 +204,14 @@ def on_exception(self, exception):
204204
if self.exception_handler is not None:
205205
self.exception_handler(exception)
206206

207-
def on_close(self):
208-
""" Called when the connection was closed.
207+
def on_close(self, ws, close_status_code, close_msg):
208+
""" Called when the connection is closed.
209209
"""
210+
logging.log(logging.INFO, f"connection closed. code: {close_status_code}. message: {close_msg}")
210211
self.connected = False
211212

212-
def on_open(self):
213-
""" Called when the connection was opened.
213+
def on_open(self, ws):
214+
""" Called when the connection is opened.
214215
"""
215216
self.connected = True
216217

src/pyRofex/service.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
All the library exposed functionality
66
"""
7-
import warnings
8-
from inspect import getargspec
7+
import logging
8+
from inspect import getfullargspec
99

1010
from .clients.rest_rfx import RestClient
1111
from .clients.websocket_rfx import WebSocketClient
@@ -535,7 +535,7 @@ def init_websocket_connection(market_data_handler=None,
535535
# Gets the client for the environment
536536
client = globals.environment_config[environment]["ws_client"]
537537

538-
# Checks handlers and adds the them into the client.
538+
# Checks handlers and adds them into the client.
539539
if market_data_handler is not None:
540540
_validate_handler(market_data_handler)
541541
client.add_market_data_handler(market_data_handler)
@@ -549,7 +549,7 @@ def init_websocket_connection(market_data_handler=None,
549549
client.add_error_handler(error_handler)
550550

551551
if exception_handler is not None:
552-
_validate_handler(error_handler)
552+
_validate_handler(exception_handler)
553553
client.set_exception_handler(exception_handler)
554554

555555
# Initiates the connection with the Websocket API
@@ -964,9 +964,9 @@ def _validate_handler(handler):
964964
raise ApiException("Handler '{handler}' is not callable.".format(handler=handler))
965965

966966
# Checks if function can receive an argument
967-
fun_arg_spec = getargspec(handler)
967+
fun_arg_spec = getfullargspec(handler)
968968
if not fun_arg_spec.args and not fun_arg_spec.varargs:
969-
print("Handler '{handler}' can't receive an argument.".format(handler=handler))
969+
logging.error("Handler '{handler}' can't receive an argument.".format(handler=handler))
970970

971971

972972
def _validate_market_data_entries(entries):
@@ -984,6 +984,6 @@ def _validate_market_data_entries(entries):
984984
else:
985985
for entry in entries:
986986
if not isinstance(entry, MarketDataEntry):
987-
print("WARNING: Market Data Entry not defined: " + str(entry))
987+
logging.warn("WARNING: Market Data Entry not defined: " + str(entry))
988988

989989
return entries

0 commit comments

Comments
 (0)