wiz-trader 0.21.0__py3-none-any.whl → 0.22.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wiz_trader/__init__.py +1 -1
- wiz_trader/quotes/client.py +32 -0
- {wiz_trader-0.21.0.dist-info → wiz_trader-0.22.0.dist-info}/METADATA +1 -1
- wiz_trader-0.22.0.dist-info/RECORD +9 -0
- wiz_trader-0.21.0.dist-info/RECORD +0 -9
- {wiz_trader-0.21.0.dist-info → wiz_trader-0.22.0.dist-info}/WHEEL +0 -0
- {wiz_trader-0.21.0.dist-info → wiz_trader-0.22.0.dist-info}/top_level.txt +0 -0
wiz_trader/__init__.py
CHANGED
wiz_trader/quotes/client.py
CHANGED
@@ -193,6 +193,38 @@ class QuotesClient:
|
|
193
193
|
asyncio.set_event_loop(loop)
|
194
194
|
loop.create_task(self._subscribe_async(instruments))
|
195
195
|
|
196
|
+
async def _unsubscribe_async(self, instruments: List[str]) -> None:
|
197
|
+
"""
|
198
|
+
Internal async unsubscription. Use `unsubscribe()` wrapper to schedule this.
|
199
|
+
"""
|
200
|
+
# Only send unsubs if the socket is open
|
201
|
+
if self.ws and self.ws.state == State.OPEN:
|
202
|
+
to_remove = set(instruments) & self.subscribed_instruments
|
203
|
+
if to_remove:
|
204
|
+
for batch in self._chunk_list(list(to_remove), self.batch_size):
|
205
|
+
logger.info("Unsubscribing from %d instruments", len(batch))
|
206
|
+
await self.ws.send(json.dumps({
|
207
|
+
"action": self.ACTION_UNSUBSCRIBE,
|
208
|
+
"instruments": batch
|
209
|
+
}))
|
210
|
+
await asyncio.sleep(0.1)
|
211
|
+
# remove them from our local set
|
212
|
+
self.subscribed_instruments -= to_remove
|
213
|
+
else:
|
214
|
+
# if we're not connected yet, just remove from the queue
|
215
|
+
self.subscribed_instruments -= set(instruments)
|
216
|
+
|
217
|
+
def unsubscribe(self, instruments: List[str]) -> None:
|
218
|
+
"""
|
219
|
+
Schedule an async unsubscribe so users can call this without 'await'.
|
220
|
+
"""
|
221
|
+
try:
|
222
|
+
loop = asyncio.get_event_loop()
|
223
|
+
except RuntimeError:
|
224
|
+
loop = asyncio.new_event_loop()
|
225
|
+
asyncio.set_event_loop(loop)
|
226
|
+
loop.create_task(self._unsubscribe_async(instruments))
|
227
|
+
|
196
228
|
# You could add a similar unsubscribe wrapper if needed
|
197
229
|
|
198
230
|
async def close(self) -> None:
|
@@ -0,0 +1,9 @@
|
|
1
|
+
wiz_trader/__init__.py,sha256=P9duxOjg6Hdg46ZYq-qkqtq40XGZap7TDsGyxVG3ZEs,182
|
2
|
+
wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
|
3
|
+
wiz_trader/apis/client.py,sha256=GY1aAaV4ia1tnFnB2qaNqnv-qeUvkVlvw9xOKN54qIs,59786
|
4
|
+
wiz_trader/quotes/__init__.py,sha256=RF9g9CNP6bVWlmCh_ad8krm3-EWOIuVfLp0-H9fAeEM,108
|
5
|
+
wiz_trader/quotes/client.py,sha256=NBWH1nxI-PKPjTxrU4ibl0xxKbchHm1pWA4JkMLvWBA,11125
|
6
|
+
wiz_trader-0.22.0.dist-info/METADATA,sha256=ZtYSZAMCOYs4ojPbZN5Shp0J2kthsdy7vUlfKFOa8og,87046
|
7
|
+
wiz_trader-0.22.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
+
wiz_trader-0.22.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
|
9
|
+
wiz_trader-0.22.0.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
wiz_trader/__init__.py,sha256=34Jeuq5zT3Iu6yzfCqm63Zjemvdt3p4Knbk642fZPyI,182
|
2
|
-
wiz_trader/apis/__init__.py,sha256=ItWKMOl4omiW0g2f-M7WRW3v-dss_ULd9vYnFyIIT9o,132
|
3
|
-
wiz_trader/apis/client.py,sha256=GY1aAaV4ia1tnFnB2qaNqnv-qeUvkVlvw9xOKN54qIs,59786
|
4
|
-
wiz_trader/quotes/__init__.py,sha256=RF9g9CNP6bVWlmCh_ad8krm3-EWOIuVfLp0-H9fAeEM,108
|
5
|
-
wiz_trader/quotes/client.py,sha256=LJeMcQPjJIRxrTIGalWsLYh_XfinDXBP5-4cNS7qCxc,9709
|
6
|
-
wiz_trader-0.21.0.dist-info/METADATA,sha256=QAED1SHUWcA_U1IzP0_ugjC1Ne1xkrPsTPKJJIKyZkw,87046
|
7
|
-
wiz_trader-0.21.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
8
|
-
wiz_trader-0.21.0.dist-info/top_level.txt,sha256=lnYS_g8LlA6ryKYnvY8xIQ6K2K-xzOsd-99AWgnW6VY,11
|
9
|
-
wiz_trader-0.21.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|