pyqqq 0.12.170__py3-none-any.whl → 0.12.171__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
|
@@ -269,10 +269,12 @@ class TradingBroker(BaseBroker):
|
|
|
269
269
|
def get_price(self, code: str, data_exchange: Optional[DataExchange] = None) -> Decimal:
|
|
270
270
|
if data_exchange:
|
|
271
271
|
price_data = self.data_api.get_price(code, data_exchange=data_exchange)
|
|
272
|
+
if data_exchange == DataExchange.NXT and price_data.get("open_price", 0) == 0: # current_price는 어제의 값을 반환하므로 open_price가 0인지로 NXT 시장 여부 확인
|
|
273
|
+
price_data = self.data_api.get_price(code, data_exchange=DataExchange.KRX)
|
|
272
274
|
else:
|
|
273
|
-
if self.market_nxt_on:
|
|
275
|
+
if self.market_nxt_on: # TODO: 정규장에서도 NXT 가격을 우선 조회하는 것이니 수정 필요
|
|
274
276
|
price_data = self.data_api.get_price(code, data_exchange=DataExchange.NXT)
|
|
275
|
-
if price_data.get("
|
|
277
|
+
if price_data.get("open_price", 0) == 0: # current_price는 어제의 값을 반환하므로 open_price가 0인지로 NXT 시장 여부 확인
|
|
276
278
|
price_data = self.data_api.get_price(code, data_exchange=DataExchange.KRX)
|
|
277
279
|
else:
|
|
278
280
|
price_data = self.data_api.get_price(code, data_exchange=DataExchange.KRX)
|
|
@@ -285,10 +287,12 @@ class TradingBroker(BaseBroker):
|
|
|
285
287
|
def get_minute_price(self, code: str, data_exchange: Optional[DataExchange] = None) -> pd.DataFrame:
|
|
286
288
|
if data_exchange:
|
|
287
289
|
result = self.data_api.get_today_minute_data(code, data_exchange=data_exchange)
|
|
290
|
+
if data_exchange == DataExchange.NXT and (result.empty or result.iloc[-1].close == 0):
|
|
291
|
+
result = self.data_api.get_today_minute_data(code, data_exchange=DataExchange.KRX)
|
|
288
292
|
else:
|
|
289
293
|
if self.market_nxt_on:
|
|
290
294
|
result = self.data_api.get_today_minute_data(code, data_exchange=DataExchange.NXT)
|
|
291
|
-
if result.iloc[-1].close == 0:
|
|
295
|
+
if result.empty or result.iloc[-1].close == 0:
|
|
292
296
|
result = self.data_api.get_today_minute_data(code, data_exchange=DataExchange.KRX)
|
|
293
297
|
else:
|
|
294
298
|
result = self.data_api.get_today_minute_data(code, data_exchange=DataExchange.KRX)
|
|
@@ -297,6 +301,8 @@ class TradingBroker(BaseBroker):
|
|
|
297
301
|
def get_daily_price(self, code: str, from_date: dtm.date, to_date: dtm.date, data_exchange: Optional[DataExchange] = None) -> pd.DataFrame:
|
|
298
302
|
if data_exchange:
|
|
299
303
|
result = self.data_api.get_historical_daily_data(code, from_date, to_date, adjusted_price=True, data_exchange=data_exchange)
|
|
304
|
+
if data_exchange == DataExchange.NXT and result.empty:
|
|
305
|
+
result = self.data_api.get_historical_daily_data(code, from_date, to_date, adjusted_price=True, data_exchange=DataExchange.KRX)
|
|
300
306
|
else:
|
|
301
307
|
if self.market_nxt_on:
|
|
302
308
|
result = self.data_api.get_historical_daily_data(code, from_date, to_date, adjusted_price=True, data_exchange=DataExchange.NXT)
|
|
@@ -309,6 +315,8 @@ class TradingBroker(BaseBroker):
|
|
|
309
315
|
def get_orderbook(self, code: str, data_exchange: Optional[DataExchange] = None):
|
|
310
316
|
if data_exchange:
|
|
311
317
|
result = self.data_api.get_orderbook(code, data_exchange=data_exchange)
|
|
318
|
+
if data_exchange == DataExchange.NXT and not result:
|
|
319
|
+
result = self.data_api.get_orderbook(code, data_exchange=DataExchange.KRX)
|
|
312
320
|
else:
|
|
313
321
|
if self.market_nxt_on:
|
|
314
322
|
result = self.data_api.get_orderbook(code, data_exchange=DataExchange.NXT)
|
|
@@ -326,6 +334,9 @@ class TradingBroker(BaseBroker):
|
|
|
326
334
|
return next((o for o in orders if o["order_no"] == order_no), None)
|
|
327
335
|
|
|
328
336
|
def get_positions(self):
|
|
337
|
+
"""
|
|
338
|
+
포지션 조회 (단, NXT 프리마켓, 애프터마켓에서 현재 가격은 NXT 가격으로 조회되지 않음)
|
|
339
|
+
"""
|
|
329
340
|
return self.trading_api.get_positions()
|
|
330
341
|
|
|
331
342
|
def create_order(self, asset_code: str, side: OrderSide, quantity: int, order_type: OrderType = OrderType.MARKET, price: int | Decimal = 0, exchange: OrderExchange = OrderExchange.KRX) -> str:
|
|
@@ -5,7 +5,7 @@ pyqqq/ai/domestic.py,sha256=FiJNInRlhcnxG7Jxmz2hDvaLhS8_jn-JFpQMze8Ch9s,1888
|
|
|
5
5
|
pyqqq/ai/market_schedule.py,sha256=8HiivwC-xI2EKr8lXS_g4mTj2LYpCQ2QfZsJmIq61O0,818
|
|
6
6
|
pyqqq/ai/minute.py,sha256=C0sTVkBY4-Vuj8Q9VZ7d9kZYAv963FUX4k3vIvhetng,1754
|
|
7
7
|
pyqqq/backtest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
pyqqq/backtest/broker.py,sha256=
|
|
8
|
+
pyqqq/backtest/broker.py,sha256=ynb0hxGk89BGg0xsNGcK6vw2tYc7hchiR5H8gA4GcVQ,66556
|
|
9
9
|
pyqqq/backtest/environment.py,sha256=bkdlwG9MynuNL1u7f0cQ1L271cnPqJ7gX89EYwl8oOg,9313
|
|
10
10
|
pyqqq/backtest/logger.py,sha256=BmoEMjUU76z8rZtMCYCwbspD3AVaHJrdbbT1EAFgrAE,3294
|
|
11
11
|
pyqqq/backtest/positionprovider.py,sha256=wrR7Bntg28Q5_vGQV6XNzxe-SYoO9_GLcV9gDVEDAN4,4164
|
|
@@ -58,6 +58,6 @@ pyqqq/utils/mock_api.py,sha256=7EsaVQ9mOVZQAqtQW24isPnk9QTbJII7x3guhFyEMAE,10569
|
|
|
58
58
|
pyqqq/utils/position_classifier.py,sha256=EaomByAWM2lVuYow5OFdJNrN64Fpukhj-lhFkjYpjeo,14908
|
|
59
59
|
pyqqq/utils/retry.py,sha256=4mw9MQvgSBC8bTLvDauaCEI5N9tL8upHCk8rSfaVRG8,2066
|
|
60
60
|
pyqqq/utils/singleton.py,sha256=m6NZ8fwVDpI6U-gUUihMPgVK_NkDh-Z1NSAtjisrpjY,810
|
|
61
|
-
pyqqq-0.12.
|
|
62
|
-
pyqqq-0.12.
|
|
63
|
-
pyqqq-0.12.
|
|
61
|
+
pyqqq-0.12.171.dist-info/METADATA,sha256=kuPz-J61xk7kylfFJqtiOCree9WhQsSJ6kCO1mD8hWQ,1664
|
|
62
|
+
pyqqq-0.12.171.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
63
|
+
pyqqq-0.12.171.dist-info/RECORD,,
|
|
File without changes
|