pyqqq 0.12.171__tar.gz → 0.12.173__tar.gz
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-0.12.171 → pyqqq-0.12.173}/PKG-INFO +1 -1
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyproject.toml +1 -1
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/backtest/broker.py +16 -7
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/tracker.py +9 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/data/realtime.py +5 -3
- {pyqqq-0.12.171 → pyqqq-0.12.173}/README.md +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/__init__.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/ai/__init__.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/ai/daily.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/ai/domestic.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/ai/market_schedule.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/ai/minute.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/backtest/__init__.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/backtest/environment.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/backtest/logger.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/backtest/positionprovider.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/backtest/strategy.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/backtest/utils.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/backtest/wallclock.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/__init__.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/ebest/__init__.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/ebest/domestic_stock.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/ebest/oauth.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/ebest/simple.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/ebest/tr_client.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/helper.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/kis/__init__.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/kis/domestic_stock.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/kis/oauth.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/kis/overseas_stock.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/kis/simple.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/kis/simple_overseas.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/kis/tr_client.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/brokerage/multiprocess_tracker.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/config.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/data/__init__.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/data/daily.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/data/domestic.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/data/index.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/data/minutes.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/data/overseas.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/data/ticks.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/data/us_stocks.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/datatypes.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/executors/__init__.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/executors/hook.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/__init__.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/api_client.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/array.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/casting.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/compute.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/copycat.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/daily_tickers.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/display.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/kvstore.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/limiter.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/local_cache.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/logger.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/market_schedule.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/mock_api.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/position_classifier.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/retry.py +0 -0
- {pyqqq-0.12.171 → pyqqq-0.12.173}/pyqqq/utils/singleton.py +0 -0
|
@@ -121,9 +121,13 @@ class BaseBroker(ABC):
|
|
|
121
121
|
raise NotImplementedError
|
|
122
122
|
|
|
123
123
|
@abstractmethod
|
|
124
|
-
def get_pending_orders(
|
|
124
|
+
def get_pending_orders(
|
|
125
|
+
self,
|
|
126
|
+
exchanges: List[OrderExchange] = [OrderExchange.KRX]
|
|
127
|
+
) -> List[StockOrder]:
|
|
125
128
|
"""미체결된 모든 주문을 조회합니다.
|
|
126
|
-
|
|
129
|
+
Args:
|
|
130
|
+
exchanges (List[OrderExchange], optional): 조회할 거래소 리스트 (기본값: [OrderExchange.KRX])
|
|
127
131
|
Returns:
|
|
128
132
|
List[StockOrder]: 미체결 주문 객체 리스트
|
|
129
133
|
|
|
@@ -326,11 +330,15 @@ class TradingBroker(BaseBroker):
|
|
|
326
330
|
result = self.data_api.get_orderbook(code, data_exchange=DataExchange.KRX)
|
|
327
331
|
return result
|
|
328
332
|
|
|
329
|
-
def get_pending_orders(self):
|
|
330
|
-
return self.trading_api.get_pending_orders()
|
|
333
|
+
def get_pending_orders(self, exchanges: List[OrderExchange] = [OrderExchange.KRX]):
|
|
334
|
+
return self.trading_api.get_pending_orders(exchanges)
|
|
331
335
|
|
|
332
|
-
def _get_pending_order(
|
|
333
|
-
|
|
336
|
+
def _get_pending_order(
|
|
337
|
+
self,
|
|
338
|
+
order_no: str,
|
|
339
|
+
exchanges: List[OrderExchange] = [OrderExchange.KRX],
|
|
340
|
+
) -> StockOrder | None:
|
|
341
|
+
orders = self.get_pending_orders(exchanges=exchanges)
|
|
334
342
|
return next((o for o in orders if o["order_no"] == order_no), None)
|
|
335
343
|
|
|
336
344
|
def get_positions(self):
|
|
@@ -765,7 +773,8 @@ class MockBroker(BaseBroker):
|
|
|
765
773
|
df = _exclude_today(df)
|
|
766
774
|
return df
|
|
767
775
|
|
|
768
|
-
def get_pending_orders(self):
|
|
776
|
+
def get_pending_orders(self, exchanges: List[OrderExchange] = [OrderExchange.KRX]):
|
|
777
|
+
# MockBroker 에서는 SOR, NXT 주문을 현재 구분하지 않음.
|
|
769
778
|
return self.pending_orders
|
|
770
779
|
|
|
771
780
|
def get_positions(self):
|
|
@@ -311,6 +311,10 @@ class TradingTracker:
|
|
|
311
311
|
def _find_pending_order(self, order_no) -> StockOrder:
|
|
312
312
|
return find(lambda x: x.order_no == order_no, self.pending_orders)
|
|
313
313
|
|
|
314
|
+
def _find_order_in_today_orders(self, order_no) -> StockOrder:
|
|
315
|
+
today_orders = self.simple_api.get_today_order_history(order_no=order_no, exchanges=[OrderExchange.KRX, OrderExchange.NXT, OrderExchange.SOR])
|
|
316
|
+
return find(lambda x: x.order_no == order_no, today_orders)
|
|
317
|
+
|
|
314
318
|
def _find_position(self, asset_code) -> StockPosition:
|
|
315
319
|
return find(lambda x: x.asset_code == asset_code, self.positions)
|
|
316
320
|
|
|
@@ -458,6 +462,11 @@ class TradingTracker:
|
|
|
458
462
|
event.filled_time,
|
|
459
463
|
partial,
|
|
460
464
|
)
|
|
465
|
+
|
|
466
|
+
if order is None:
|
|
467
|
+
self.logger.warn(f"Order not found for order_no: {order_no}")
|
|
468
|
+
order = self._find_order_in_today_orders(order_no)
|
|
469
|
+
self.logger.warn(f"Order found in today's orders: {order}")
|
|
461
470
|
self._notify_pending_order_update("partial" if partial else "completed", order)
|
|
462
471
|
self._notify_position_update(position_event_type, position)
|
|
463
472
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import List, Union
|
|
2
|
+
from pyqqq.datatypes import DataExchange
|
|
2
3
|
from pyqqq.utils.api_client import raise_for_status, send_request
|
|
3
4
|
from pyqqq.utils.logger import get_logger
|
|
4
5
|
from pyqqq.utils.singleton import singleton
|
|
@@ -14,12 +15,13 @@ import datetime as dtm
|
|
|
14
15
|
logger = get_logger(__name__)
|
|
15
16
|
|
|
16
17
|
|
|
17
|
-
def get_all_last_trades(codes: List[str] = None):
|
|
18
|
+
def get_all_last_trades(codes: List[str] = None, exchange: str = "KRX"):
|
|
18
19
|
"""
|
|
19
20
|
모든 종목의 최근 체결 정보를 반환합니다.
|
|
20
21
|
|
|
21
22
|
Args:
|
|
22
23
|
codes (List[str], optional): 종목 코드 리스트. 모든 종목의 체결 정보를 반환하려면 None을 전달합니다.
|
|
24
|
+
exchange (str, optional): 거래소. 기본값은 "KRX"입니다. 지원하는 거래소는 "KRX", "UN" 입니다.
|
|
23
25
|
|
|
24
26
|
Returns:
|
|
25
27
|
list:
|
|
@@ -54,7 +56,7 @@ def get_all_last_trades(codes: List[str] = None):
|
|
|
54
56
|
|
|
55
57
|
params = None
|
|
56
58
|
if codes:
|
|
57
|
-
params = {"codes": ",".join(codes) if isinstance(codes, list) else codes}
|
|
59
|
+
params = {"codes": ",".join(codes) if isinstance(codes, list) else codes, "exchange": exchange}
|
|
58
60
|
|
|
59
61
|
r = send_request("GET", f"{c.PYQQQ_API_URL}/domestic-stock/trades", params=params)
|
|
60
62
|
raise_for_status(r)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|