Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

python-infinity

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-infinity - pypi Package Compare versions

Comparing version
0.0.4a1
to
0.0.4
+40
-33
infinity/websocket_client/websocket_client.py

@@ -15,3 +15,3 @@ import json

class WebSocketClient:
def __init__(self, public_ws_url: str = None, private_ws_url: str = None, login: LoginClient = None,
def __init__(self, ws_url: str = None, login: LoginClient = None,
auto_reconnect_retries: int = 0, logger: logging.Logger = None):

@@ -22,4 +22,3 @@ """

Args:
public_ws_url (str): public Websocket
private_ws_url (str): private Websocket
ws_url (str): Websocket
login (LoginClient): login to use private websocket

@@ -32,4 +31,3 @@ auto_reconnect_retries (int): The number of times to attempt auto-reconnection in case of disconnection.

self.__ping_interval = 60
self._PUBLIC_WS_URL = public_ws_url
self._PRIVATE_WS_URL = private_ws_url
self._WS_URL = ws_url
self._private_ws = None

@@ -227,3 +225,3 @@ self._public_ws = None

self._logger.debug(f"Connecting infinity public websocket client...")
new_public_ws = websocket.WebSocketApp(self._PUBLIC_WS_URL,
new_public_ws = websocket.WebSocketApp(self._WS_URL,
on_open=self.on_public_open,

@@ -251,3 +249,3 @@ on_message=self.on_public_message,

ws_header = "Authorization: Bearer " + self._access_token
new_private_ws = websocket.WebSocketApp(self._PRIVATE_WS_URL,
new_private_ws = websocket.WebSocketApp(self._WS_URL,
on_open=self.on_private_open,

@@ -814,12 +812,20 @@ on_message=self.on_private_message,

{
"e": "recentTrades", (channel name)
"E": 1696584281624,
"s": "ETH-SPOT", (market)
"m": 1, (market id)
"P": {
"p": "0.0246", (rate)
"q": "0.3624", (quantity)
"d": 1696584281599, (trade time)
"s": true (side)
}
"e": "recentTrades",
"E": 1702970997315,
"s": "USDT-2023-12-29",
"m": 12148,
"P": [
{
"p": "0.0518",
"q": "1353.3",
"d": 1702970997296,
"s": "True"
},
{
"p": "0.0514",
"q": "4065.21",
"d": 1702970997296,
"s": "True"
}
]
}

@@ -833,18 +839,19 @@ """

rates_type = constants.FIXED_RATE
trade_msg = message.get("P", None)
if trade_msg is not None:
rate = float(trade_msg.get("p", 0))
quantity = float(trade_msg.get("q", 0))
side = constants.BORROW if trade_msg.get("s", None) else constants.LEND
trade_time = datetime.utcfromtimestamp(trade_msg.get("d", None) / 1000)
public_trade = {
constants.INSTRUMENT_ID: instrument_id,
constants.RATES_TYPE: rates_type,
constants.TRADE_TIME: trade_time,
constants.RATE: rate,
constants.QUANTITY: quantity,
constants.SIDE: side
}
self._logger.debug(f"Public trade: {public_trade}.")
self.process_public_trade(public_trade=public_trade)
trades = message.get("P", None)
if trades is not None and len(trades) > 0:
for trade_msg in trades:
rate = float(trade_msg.get("p", 0))
quantity = float(trade_msg.get("q", 0))
side = constants.BORROW if trade_msg.get("s", None) else constants.LEND
trade_time = datetime.utcfromtimestamp(trade_msg.get("d", None) / 1000)
public_trade = {
constants.INSTRUMENT_ID: instrument_id,
constants.RATES_TYPE: rates_type,
constants.TRADE_TIME: trade_time,
constants.RATE: rate,
constants.QUANTITY: quantity,
constants.SIDE: side
}
self._logger.debug(f"Public trade: {public_trade}.")
self.process_public_trade(public_trade=public_trade)
except Exception as e:

@@ -851,0 +858,0 @@ self._logger.error(f"Exception thrown in on_public_trades raw={message}, {e=}. {traceback.format_exc()}")

Metadata-Version: 2.1
Name: python-infinity
Version: 0.0.4a1
Version: 0.0.4
Summary: Unofficial Infinity client packages

@@ -67,4 +67,3 @@ Author-email: pydevbuzz <pydevbuzz@gmail.com>

|-----------------|----------------------------------------------|
| `0.0.3` | Stable release for testnet (**recommended**) |
| `0.0.4a1` | alpha version to prepare 0.0.4 |
| `0.0.4` | Stable release for testnet (**recommended**) |

@@ -187,3 +186,3 @@

# =============================================================================
infinity_public_ws = InfinityWebsocketClient(public_ws_url="Infinity Exchange Public Websocket URL",
infinity_public_ws = InfinityWebsocketClient(ws_url="Infinity Exchange Websocket URL",
auto_reconnect_retries=3) # default is 0 which would disable reconnection retries

@@ -195,4 +194,3 @@ infinity_public_ws.run_all()

# =============================================================================
infinity_ws = InfinityWebsocketClient(public_ws_url="Infinity Exchange Public Websocket URL",
private_ws_url="Infinity Exchange Private Websocket URL",
infinity_ws = InfinityWebsocketClient(ws_url="Infinity Exchange Websocket URL",
login=infinity_login, # Infinity Exchange Login Client

@@ -199,0 +197,0 @@ auto_reconnect_retries=3)

@@ -7,3 +7,3 @@ [build-system]

name = "python-infinity"
version = "0.0.4a1"
version = "0.0.4"
authors = [

@@ -10,0 +10,0 @@ { name="pydevbuzz", email="pydevbuzz@gmail.com" },

Metadata-Version: 2.1
Name: python-infinity
Version: 0.0.4a1
Version: 0.0.4
Summary: Unofficial Infinity client packages

@@ -67,4 +67,3 @@ Author-email: pydevbuzz <pydevbuzz@gmail.com>

|-----------------|----------------------------------------------|
| `0.0.3` | Stable release for testnet (**recommended**) |
| `0.0.4a1` | alpha version to prepare 0.0.4 |
| `0.0.4` | Stable release for testnet (**recommended**) |

@@ -187,3 +186,3 @@

# =============================================================================
infinity_public_ws = InfinityWebsocketClient(public_ws_url="Infinity Exchange Public Websocket URL",
infinity_public_ws = InfinityWebsocketClient(ws_url="Infinity Exchange Websocket URL",
auto_reconnect_retries=3) # default is 0 which would disable reconnection retries

@@ -195,4 +194,3 @@ infinity_public_ws.run_all()

# =============================================================================
infinity_ws = InfinityWebsocketClient(public_ws_url="Infinity Exchange Public Websocket URL",
private_ws_url="Infinity Exchange Private Websocket URL",
infinity_ws = InfinityWebsocketClient(ws_url="Infinity Exchange Websocket URL",
login=infinity_login, # Infinity Exchange Login Client

@@ -199,0 +197,0 @@ auto_reconnect_retries=3)

@@ -50,4 +50,3 @@ # python-infinity

|-----------------|----------------------------------------------|
| `0.0.3` | Stable release for testnet (**recommended**) |
| `0.0.4a1` | alpha version to prepare 0.0.4 |
| `0.0.4` | Stable release for testnet (**recommended**) |

@@ -170,3 +169,3 @@

# =============================================================================
infinity_public_ws = InfinityWebsocketClient(public_ws_url="Infinity Exchange Public Websocket URL",
infinity_public_ws = InfinityWebsocketClient(ws_url="Infinity Exchange Websocket URL",
auto_reconnect_retries=3) # default is 0 which would disable reconnection retries

@@ -178,4 +177,3 @@ infinity_public_ws.run_all()

# =============================================================================
infinity_ws = InfinityWebsocketClient(public_ws_url="Infinity Exchange Public Websocket URL",
private_ws_url="Infinity Exchange Private Websocket URL",
infinity_ws = InfinityWebsocketClient(ws_url="Infinity Exchange Websocket URL",
login=infinity_login, # Infinity Exchange Login Client

@@ -182,0 +180,0 @@ auto_reconnect_retries=3)