Skip to content

Commit

Permalink
add support for python >= 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
fzanuso committed Nov 12, 2023
1 parent dbb8f6f commit bb03a09
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
requests>=2.20.0
simplejson>=3.10.0
enum34>=1.1.6
websocket-client>=0.54.0,<0.58.0
websocket-client>=1.6.4
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pyRofex",
version="0.5.0rc1",
version="0.5.0",
author="Franco Zanuso",
author_email="[email protected]",
description="Python connector for ROFEX's Rest and Websocket APIs.",
Expand All @@ -18,7 +18,7 @@
'requests>=2.20.0',
'simplejson>=3.10.0',
'enum34>=1.1.6',
'websocket-client>=0.54.0,<0.58.0',
'websocket-client>=1.6.4',
],
classifiers=[
"Programming Language :: Python :: 3",
Expand Down
4 changes: 2 additions & 2 deletions src/pyRofex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
pyRofex: Python connector for ROFEX Rest and Websocket APIs.
This modules expose functions and enumerations of the library.
This module expose functions and enumerations of the library.
"""
from .service import initialize
from .service import set_default_environment
Expand Down Expand Up @@ -46,4 +46,4 @@
from .components.enums import Side
from .components.enums import TimeInForce

__version__ = "0.5.0rc1"
__version__ = "0.5.0"
15 changes: 8 additions & 7 deletions src/pyRofex/clients/websocket_rfx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import threading
import time
import ssl
import logging

import websocket
import simplejson
Expand Down Expand Up @@ -149,7 +149,7 @@ def connect(self):
if self.ws_connection.sock is None or not self.ws_connection.sock.connected:
self.on_exception(ApiException("Connection could not be established."))

def on_message(self, message):
def on_message(self, ws, message):
""" Called when a new message is received through the connection.
:param message: message received.
Expand Down Expand Up @@ -186,7 +186,7 @@ def on_message(self, message):
except Exception as e:
self.on_exception(e)

def on_error(self, exception):
def on_error(self, ws, exception):
""" Called when an error occurred within the connection.
:param exception: exception raised.
Expand All @@ -204,13 +204,14 @@ def on_exception(self, exception):
if self.exception_handler is not None:
self.exception_handler(exception)

def on_close(self):
""" Called when the connection was closed.
def on_close(self, ws, close_status_code, close_msg):
""" Called when the connection is closed.
"""
logging.log(logging.INFO, f"connection closed. code: {close_status_code}. message: {close_msg}")
self.connected = False

def on_open(self):
""" Called when the connection was opened.
def on_open(self, ws):
""" Called when the connection is opened.
"""
self.connected = True

Expand Down
14 changes: 7 additions & 7 deletions src/pyRofex/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
All the library exposed functionality
"""
import warnings
from inspect import getargspec
import logging
from inspect import getfullargspec

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

# Checks handlers and adds the them into the client.
# Checks handlers and adds them into the client.
if market_data_handler is not None:
_validate_handler(market_data_handler)
client.add_market_data_handler(market_data_handler)
Expand All @@ -549,7 +549,7 @@ def init_websocket_connection(market_data_handler=None,
client.add_error_handler(error_handler)

if exception_handler is not None:
_validate_handler(error_handler)
_validate_handler(exception_handler)
client.set_exception_handler(exception_handler)

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

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


def _validate_market_data_entries(entries):
Expand All @@ -984,6 +984,6 @@ def _validate_market_data_entries(entries):
else:
for entry in entries:
if not isinstance(entry, MarketDataEntry):
print("WARNING: Market Data Entry not defined: " + str(entry))
logging.warn("WARNING: Market Data Entry not defined: " + str(entry))

return entries

0 comments on commit bb03a09

Please sign in to comment.