pyqqq 0.12.206__py3-none-any.whl → 0.12.208__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.

Potentially problematic release.


This version of pyqqq might be problematic. Click here for more details.

@@ -1,3 +1,10 @@
1
+ import asyncio
2
+ import datetime as dtm
3
+ import json
4
+ from typing import AsyncGenerator
5
+
6
+ import websockets
7
+
1
8
  from pyqqq.brokerage.ebest.oauth import EBestAuth
2
9
  from pyqqq.brokerage.ebest.tr_client import (
3
10
  EBestTRClient,
@@ -6,11 +13,6 @@ from pyqqq.brokerage.ebest.tr_client import (
6
13
  )
7
14
  from pyqqq.utils.limiter import CallLimiter
8
15
  from pyqqq.utils.market_schedule import get_market_schedule
9
- from typing import AsyncGenerator
10
- import asyncio
11
- import datetime as dtm
12
- import json
13
- import websockets
14
16
 
15
17
 
16
18
  class EBestDomesticStock:
@@ -1246,6 +1248,8 @@ class EBestDomesticStock:
1246
1248
 
1247
1249
  async def __on_connect(ws: websockets.WebSocketClientProtocol):
1248
1250
  for asset_code in asset_codes:
1251
+ CallLimiter().wait_limit_rate(75, scope="ebest/listen_trade_event")
1252
+
1249
1253
  await ws.send(
1250
1254
  json.dumps(
1251
1255
  {
@@ -1261,8 +1265,6 @@ class EBestDomesticStock:
1261
1265
  )
1262
1266
  )
1263
1267
 
1264
- await asyncio.sleep(0.01)
1265
-
1266
1268
  client = EBestTRWebsocketClient(
1267
1269
  self.auth,
1268
1270
  on_connect=__on_connect,
@@ -140,6 +140,7 @@ class EBestTRWebsocketClient:
140
140
  dict: 실시간 데이터
141
141
 
142
142
  """
143
+ connected_count = 0
143
144
  websocket_url = f"{self.auth.websocket_url}/websocket"
144
145
 
145
146
  while not self.stop_event.is_set():
@@ -154,9 +155,11 @@ class EBestTRWebsocketClient:
154
155
  continue
155
156
 
156
157
  async with websockets.connect(websocket_url) as ws:
157
- self.logger.info(f"{self.session_id}: connected to websocket")
158
+ connected_count += 1
159
+ self.logger.warning(f"{self.session_id}: connected to websocket (count: {connected_count})")
158
160
  if self.on_connect:
159
161
  await self.on_connect(ws)
162
+ self.logger.info(f"{self.session_id}: on_connect callback done")
160
163
 
161
164
  while not self.stop_event.is_set():
162
165
  data = await self.recv_with_timeout(ws, timeout=1)
@@ -167,7 +170,7 @@ class EBestTRWebsocketClient:
167
170
 
168
171
  else:
169
172
  if json_data["header"]["rsp_cd"] != "00000":
170
- self.logger.warn(json_data)
173
+ self.logger.warning(f"{self.session_id}: {json_data}")
171
174
 
172
175
  elif self.on_ask_keep_connection() == EBestTRWebsocketKeepConnectionStatus.CLOSE:
173
176
  break
@@ -176,28 +179,21 @@ class EBestTRWebsocketClient:
176
179
 
177
180
  except websockets.exceptions.ConnectionClosedError:
178
181
  self.logger.error(f"{self.session_id}: ConnectionClosedError")
179
- await asyncio.sleep(0.5)
182
+ await asyncio.sleep(1)
180
183
  continue
181
184
 
182
185
  except websockets.ConnectionClosed as e:
183
- await asyncio.sleep(0.5)
184
- self.logger.exception(e)
186
+ self.logger.error(f"{self.session_id}: ConnectionClosed: {e}")
187
+ await asyncio.sleep(1)
185
188
  continue
186
189
 
187
190
  except ssl.SSLZeroReturnError:
188
191
  self.logger.error(f"{self.session_id}: SSLZeroReturnError")
189
-
190
- if not hasattr(self, "_sslzero_exc_count"):
191
- self._sslzero_exc_count = 0
192
- if self._sslzero_exc_count < 3:
193
- self._sslzero_exc_count += 1
194
- traceback.print_exc()
195
-
196
192
  await asyncio.sleep(random.uniform(1, 2))
197
193
  continue
198
194
 
199
195
  except TimeoutError as e:
200
- self.logger.exception(e)
196
+ self.logger.error(f"{self.session_id}: TimeoutError: {e}")
201
197
  await asyncio.sleep(1)
202
198
  continue
203
199
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyqqq
3
- Version: 0.12.206
3
+ Version: 0.12.208
4
4
  Summary: Package for quantitative strategy development on the PyQQQ platform
5
5
  License: MIT
6
6
  Author: PyQQQ team
@@ -9,10 +9,10 @@ pyqqq/backtest/utils.py,sha256=Qs8yvZaG_u1twjnf3XnP1r5iNIFWVj8LaqIiT56nTms,4461
9
9
  pyqqq/backtest/wallclock.py,sha256=24IAe7FxGNNbnS_eOfn_vBHGatcy4meywiTT2gUndTU,5003
10
10
  pyqqq/brokerage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  pyqqq/brokerage/ebest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- pyqqq/brokerage/ebest/domestic_stock.py,sha256=zG5gC_yMUixqIrHazmLOmCpSMAcm9lC9xh8__I0VuOU,77420
12
+ pyqqq/brokerage/ebest/domestic_stock.py,sha256=Lw1XWIn8PcmOq5oFK1zwBCYSocHy7ctSBRsxxVMJXSE,77464
13
13
  pyqqq/brokerage/ebest/oauth.py,sha256=3HzReoXDLpDNqLuPBL-3H3vgQmlYQKS1vBkutU_BdZ4,2713
14
14
  pyqqq/brokerage/ebest/simple.py,sha256=Ade3m18yhGt1fyn7ZbN-LmyNKiFP2ahUMSLLqMXWc0g,27585
15
- pyqqq/brokerage/ebest/tr_client.py,sha256=0-qNc-SZdzVN_J_zChS_u1-S9FaEEwelbcTO9EflJ_U,8214
15
+ pyqqq/brokerage/ebest/tr_client.py,sha256=eY2Azhx07JYq-yU1eyAv8IEia43X2XnqWnH58sA80mQ,8248
16
16
  pyqqq/brokerage/helper.py,sha256=6pDiHo2eqsppC5ObIUMJibeMZ7cq8V9pVzNLTsdAy1w,6675
17
17
  pyqqq/brokerage/kis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  pyqqq/brokerage/kis/domestic_stock.py,sha256=8ENXqEj66I0qUrXobw26_Vjc-zEy8444AGNqKBW9_UI,233326
@@ -55,6 +55,6 @@ pyqqq/utils/mock_api.py,sha256=7EsaVQ9mOVZQAqtQW24isPnk9QTbJII7x3guhFyEMAE,10569
55
55
  pyqqq/utils/position_classifier.py,sha256=tIbZMm_baru0F0qv6QDc5b2-oJYNvmn9HyrRr3xaAXU,14975
56
56
  pyqqq/utils/retry.py,sha256=ENNvjRyswn6nwue5JSqyC82QlBJSAMlJYj_gj0kqutY,2187
57
57
  pyqqq/utils/singleton.py,sha256=m6NZ8fwVDpI6U-gUUihMPgVK_NkDh-Z1NSAtjisrpjY,810
58
- pyqqq-0.12.206.dist-info/METADATA,sha256=rNXufQK1_BzUzQbhKm2ybxfDVGujdx4dJQD4m4iqUTw,1664
59
- pyqqq-0.12.206.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
60
- pyqqq-0.12.206.dist-info/RECORD,,
58
+ pyqqq-0.12.208.dist-info/METADATA,sha256=m-60MNmNG8ILgRf9JqjPgFKmmE_BxqCD0pykNB7TcRs,1664
59
+ pyqqq-0.12.208.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
60
+ pyqqq-0.12.208.dist-info/RECORD,,