quantplay 2.1.72__tar.gz → 2.1.74__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.
- {quantplay-2.1.72 → quantplay-2.1.74}/PKG-INFO +1 -1
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/generics/broker.py +8 -3
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/jainam_xts.py +28 -2
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/kotak.py +8 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/xts.py +4 -1
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay.egg-info/PKG-INFO +1 -1
- {quantplay-2.1.72 → quantplay-2.1.74}/setup.py +1 -1
- {quantplay-2.1.72 → quantplay-2.1.74}/README.md +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/pyproject.toml +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/aliceblue.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/angelone.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/angelone_utils/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/angelone_utils/angeloneWS.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/auto_login/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/auto_login/aliceblue.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/breeze/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/breeze/breeze_utils.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/broker_factory.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/dhan.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/finvasia_utils/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/finvasia_utils/fa_noren.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/five_paisa.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/flattrade.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/ft_utils/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/ft_utils/flattrade_utils.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/ft_utils/ft_noren.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/generics/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/icici_direct.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/iifl_xts.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/kite_utils.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/kotak_utils/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/kotak_utils/kotak_ws.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/kotak_utils/kotak_ws_lib.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/motilal.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/noren.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/shoonya.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/uplink/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/uplink/uplink_utils.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/upstox.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/xts_utils/Connect.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/xts_utils/Exception.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/xts_utils/InteractiveSocketClient.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/xts_utils/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/xts_utils_v2/ConnectV2.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/xts_utils_v2/InteractiveSocketClientV2.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/xts_utils_v2/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/zerodha.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/core/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/core/strategy.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/exception/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/exception/exceptions.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/indicator/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/indicator/iv.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/model/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/model/broker.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/model/broker_response.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/model/generics.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/model/instrument_data.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/model/order_event.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/py.typed +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/strategy/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/strategy/iv_spike.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/strategy/obuy.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/utils/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/utils/caching.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/utils/constant.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/utils/exchange.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/utils/number_utils.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/utils/pickle_utils.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/utils/selenium_utils.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/wrapper/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/wrapper/aws/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/wrapper/aws/s3.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay/wrapper/redis.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay.egg-info/SOURCES.txt +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay.egg-info/dependency_links.txt +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay.egg-info/requires.txt +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/quantplay.egg-info/top_level.txt +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/setup.cfg +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/tests/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/tests/conftest.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/tests/wrapper/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/tests/wrapper/aws/__init__.py +0 -0
- {quantplay-2.1.72 → quantplay-2.1.74}/tests/wrapper/aws/s3_test.py +0 -0
|
@@ -141,6 +141,8 @@ class Broker(ABC):
|
|
|
141
141
|
self.lock = Lock()
|
|
142
142
|
self.square_off_lock = Lock()
|
|
143
143
|
|
|
144
|
+
self.ORDER_POLLING_INTERVAL = 3
|
|
145
|
+
|
|
144
146
|
def symbol_attribute(self, exchange: ExchangeType, symbol: str, value: str) -> Any:
|
|
145
147
|
try:
|
|
146
148
|
return_value: Any = self.symbol_data[f"{exchange}:{symbol}"][value]
|
|
@@ -627,7 +629,7 @@ class Broker(ABC):
|
|
|
627
629
|
|
|
628
630
|
def stream_order_updates(self) -> None:
|
|
629
631
|
self.order_log: dict[str, Any] = {}
|
|
630
|
-
while
|
|
632
|
+
while True:
|
|
631
633
|
try:
|
|
632
634
|
orders = self.orders(add_ltp=False)
|
|
633
635
|
|
|
@@ -661,13 +663,16 @@ class Broker(ABC):
|
|
|
661
663
|
self.convert_to_event(order)
|
|
662
664
|
|
|
663
665
|
self.order_log[order_id] = copy.deepcopy(order)
|
|
664
|
-
time.sleep(
|
|
666
|
+
time.sleep(self.ORDER_POLLING_INTERVAL)
|
|
665
667
|
except Exception:
|
|
666
668
|
traceback.print_exc()
|
|
667
669
|
print(f"Unable to process order stream for {self.user_id}")
|
|
668
|
-
time.sleep(
|
|
670
|
+
time.sleep(self.ORDER_POLLING_INTERVAL + 2)
|
|
669
671
|
|
|
670
672
|
def stream_order_data(self) -> None:
|
|
673
|
+
if self.order_updates is None:
|
|
674
|
+
raise Exception("Event Queue Not Initalised")
|
|
675
|
+
|
|
671
676
|
th = threading.Thread(target=self.stream_order_updates, daemon=True)
|
|
672
677
|
th.start()
|
|
673
678
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import traceback
|
|
2
2
|
from typing import Literal
|
|
3
3
|
|
|
4
|
+
import polars as pl
|
|
5
|
+
|
|
4
6
|
from quantplay.broker.xts import XTS
|
|
5
7
|
from quantplay.broker.xts_utils_v2.ConnectV2 import XTSConnectV2
|
|
6
8
|
from quantplay.broker.xts_utils_v2.InteractiveSocketClientV2 import (
|
|
@@ -39,7 +41,11 @@ class Jainam(XTS):
|
|
|
39
41
|
if is_dealer:
|
|
40
42
|
self.ClientID = "*****"
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
self.ORDER_POLLING_INTERVAL = 5
|
|
45
|
+
|
|
46
|
+
def login(
|
|
47
|
+
self, api_key: str, api_secret: str, md_api_key: str, md_api_secret: str
|
|
48
|
+
) -> None:
|
|
43
49
|
try:
|
|
44
50
|
self.wrapper = XTSConnectV2(
|
|
45
51
|
apiKey=api_key,
|
|
@@ -79,7 +85,7 @@ class Jainam(XTS):
|
|
|
79
85
|
traceback.print_exc()
|
|
80
86
|
raise InvalidArgumentException("Invalid api key/secret")
|
|
81
87
|
|
|
82
|
-
def
|
|
88
|
+
def stream_order_updates_ws(self) -> None:
|
|
83
89
|
if self.wrapper.token is None:
|
|
84
90
|
raise InvalidArgumentException("XTS Token Missing")
|
|
85
91
|
|
|
@@ -90,3 +96,23 @@ class Jainam(XTS):
|
|
|
90
96
|
)
|
|
91
97
|
socket.setup_event_listners(on_order=self.order_event_handler)
|
|
92
98
|
socket.connect()
|
|
99
|
+
|
|
100
|
+
def stream_order_updates(self) -> None:
|
|
101
|
+
self.stream_order_updates_legacy()
|
|
102
|
+
|
|
103
|
+
def orders(self, tag: str | None = None, add_ltp: bool = True) -> pl.DataFrame:
|
|
104
|
+
orders = super().orders(tag, add_ltp)
|
|
105
|
+
orders = orders.with_columns(
|
|
106
|
+
pl.when(
|
|
107
|
+
pl.col("status").eq("CANCELLED")
|
|
108
|
+
& pl.col("status_message")
|
|
109
|
+
.str.to_lowercase()
|
|
110
|
+
.str.replace_all(" ", "")
|
|
111
|
+
.str.contains("selftrade")
|
|
112
|
+
)
|
|
113
|
+
.then(pl.lit("REJECTED"))
|
|
114
|
+
.otherwise(pl.col("status"))
|
|
115
|
+
.alias("status")
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
return orders
|
|
@@ -10,6 +10,7 @@ import polars as pl
|
|
|
10
10
|
import pyotp
|
|
11
11
|
import requests
|
|
12
12
|
import shortuuid # type:ignore
|
|
13
|
+
from retrying import retry # type: ignore
|
|
13
14
|
|
|
14
15
|
from quantplay.broker.generics.broker import Broker
|
|
15
16
|
from quantplay.broker.kotak_utils.kotak_ws import NeoWebSocket
|
|
@@ -18,6 +19,7 @@ from quantplay.exception.exceptions import (
|
|
|
18
19
|
BrokerException,
|
|
19
20
|
InvalidArgumentException,
|
|
20
21
|
QuantplayOrderPlacementException,
|
|
22
|
+
retry_exception,
|
|
21
23
|
)
|
|
22
24
|
from quantplay.model.broker import (
|
|
23
25
|
MarginsResponse,
|
|
@@ -624,6 +626,12 @@ class Kotak(Broker):
|
|
|
624
626
|
def profile(self) -> UserBrokerProfileResponse:
|
|
625
627
|
return {"user_id": self.user_id or ""}
|
|
626
628
|
|
|
629
|
+
@retry(
|
|
630
|
+
wait_exponential_multiplier=3000,
|
|
631
|
+
wait_exponential_max=10000,
|
|
632
|
+
stop_max_attempt_number=2,
|
|
633
|
+
retry_on_exception=retry_exception,
|
|
634
|
+
)
|
|
627
635
|
def margins(self) -> MarginsResponse:
|
|
628
636
|
limits_resp = self.request(
|
|
629
637
|
"limits", body={"seg": "ALL", "exch": "ALL", "prod": "ALL"}
|
|
@@ -746,7 +746,10 @@ class XTS(Broker):
|
|
|
746
746
|
def get_product(self, product: ProductType) -> Any:
|
|
747
747
|
return product
|
|
748
748
|
|
|
749
|
-
def
|
|
749
|
+
def stream_order_updates_legacy(self) -> None:
|
|
750
|
+
return super().stream_order_updates()
|
|
751
|
+
|
|
752
|
+
def stream_order_updates(self) -> None:
|
|
750
753
|
if self.wrapper.token is None:
|
|
751
754
|
raise InvalidArgumentException("XTS Token Missing")
|
|
752
755
|
|
|
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
|
{quantplay-2.1.72 → quantplay-2.1.74}/quantplay/broker/xts_utils_v2/InteractiveSocketClientV2.py
RENAMED
|
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
|