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

pyqqq/backtest/broker.py CHANGED
@@ -1315,6 +1315,8 @@ class MockBroker(BaseBroker):
1315
1315
  dict_list = []
1316
1316
  for trade in self.trading_history:
1317
1317
  d = asdict(trade)
1318
+ d["average_purchase_price"] = Decimal(str(d["average_purchase_price"])) if not isinstance(d["average_purchase_price"], Decimal) else d["average_purchase_price"]
1319
+ d["pnl_rate"] = Decimal(str(d["pnl_rate"])) if not isinstance(d["pnl_rate"], Decimal) else d["pnl_rate"]
1318
1320
 
1319
1321
  if filter_side and d["side"] != filter_side:
1320
1322
  continue
@@ -1,16 +1,18 @@
1
- from enum import Enum
2
- from pyqqq.brokerage.ebest.oauth import EBestAuth
3
- from pyqqq.utils.logger import get_logger
4
- from pyqqq.utils.market_schedule import *
5
- from pyqqq.utils.retry import retry
6
- from typing import AsyncGenerator, Callable
7
1
  import asyncio
8
2
  import json
9
- import ssl
10
3
  import random
4
+ import ssl
5
+ from enum import Enum
6
+ from typing import AsyncGenerator, Callable
7
+
11
8
  import requests
12
9
  import websockets
13
10
 
11
+ from pyqqq.brokerage.ebest.oauth import EBestAuth
12
+ from pyqqq.utils.logger import get_logger
13
+ from pyqqq.utils.market_schedule import *
14
+ from pyqqq.utils.retry import retry
15
+
14
16
 
15
17
  class EBestTRClient:
16
18
  logger = get_logger(__name__ + ".EBestTRClient")
@@ -26,18 +28,10 @@ class EBestTRClient:
26
28
  def __init__(self, auth: EBestAuth, corp_data: dict = None):
27
29
  self.auth = auth
28
30
  self.corp_data = corp_data
31
+ self.session = requests.Session()
29
32
 
30
- @retry(requests.HTTPError)
31
- def request(
32
- self,
33
- path: str,
34
- tr_cd: str,
35
- tr_cont: str = "N",
36
- tr_cont_key: str = "",
37
- params: dict = None,
38
- body: dict = None,
39
- method: str = "POST",
40
- ):
33
+ @retry(requests.HTTPError, delay=1)
34
+ def request(self, path: str, tr_cd: str, tr_cont: str = "N", tr_cont_key: str = "", params: dict = None, body: dict = None, method: str = "POST"):
41
35
  """
42
36
  TR 요청을 보내고 응답을 받는 메서드
43
37
 
@@ -67,13 +61,14 @@ class EBestTRClient:
67
61
 
68
62
  url = f"{self.auth.host_url}{path}"
69
63
 
70
- r = requests.request(method=method, url=url, headers=headers, params=params, json=body)
64
+ r = self.session.request(method=method, url=url, headers=headers, params=params, json=body)
71
65
 
72
66
  if r.status_code != 200:
73
67
  try:
74
68
  res_body = r.json()
75
69
  if "rsp_cd" in res_body and res_body["rsp_cd"] == "IGW00121":
76
70
  self.auth.get_token(refresh=True)
71
+
77
72
  except Exception as e:
78
73
  self.logger.exception(e)
79
74
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyqqq
3
- Version: 0.12.199
3
+ Version: 0.12.201
4
4
  Summary: Package for quantitative strategy development on the PyQQQ platform
5
5
  License: MIT
6
6
  Author: PyQQQ team
@@ -1,6 +1,6 @@
1
1
  pyqqq/__init__.py,sha256=s-r2WUo0H9OzuPiHSGtCjJMyEXfx8Cpt0hri8amUU2Y,1607
2
2
  pyqqq/backtest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- pyqqq/backtest/broker.py,sha256=erLt83WG9zDzFZ9UoGk0sgllCzw3k5znngNjj09keiA,73986
3
+ pyqqq/backtest/broker.py,sha256=JlZ2qioIVEooeDeYYPCzsR2jDQe4YfZ46D3xKseIRIw,74276
4
4
  pyqqq/backtest/environment.py,sha256=cAvXKtRR4xBLFzUo-6xkuihlqRE_Jd0ZYAQ29K5qirg,10229
5
5
  pyqqq/backtest/logger.py,sha256=BmoEMjUU76z8rZtMCYCwbspD3AVaHJrdbbT1EAFgrAE,3294
6
6
  pyqqq/backtest/positionprovider.py,sha256=wrR7Bntg28Q5_vGQV6XNzxe-SYoO9_GLcV9gDVEDAN4,4164
@@ -12,7 +12,7 @@ pyqqq/brokerage/ebest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
12
12
  pyqqq/brokerage/ebest/domestic_stock.py,sha256=zG5gC_yMUixqIrHazmLOmCpSMAcm9lC9xh8__I0VuOU,77420
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=6vtod4xXr35yMAIji5qXUr_C3Bf4C_1NDLgELohDuks,7914
15
+ pyqqq/brokerage/ebest/tr_client.py,sha256=ShgfzZAlJeSa-ZuRf-PA_HZUvkHwctwFDIOrlE5XKq0,7901
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.199.dist-info/METADATA,sha256=w0KawVhD0_oEhBDyGyB4jxD2Gky6O1lBzZbQZwrWGq8,1664
59
- pyqqq-0.12.199.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
60
- pyqqq-0.12.199.dist-info/RECORD,,
58
+ pyqqq-0.12.201.dist-info/METADATA,sha256=02IX1zqK_Cubnn-0WlHPgwnyBnFZ1Aae2xIArtzsPJo,1664
59
+ pyqqq-0.12.201.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
60
+ pyqqq-0.12.201.dist-info/RECORD,,