quantplay 2.0.33__tar.gz → 2.0.35__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.0.33 → quantplay-2.0.35}/PKG-INFO +1 -1
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/aliceblue.py +2 -4
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/angelone.py +14 -10
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/five_paisa.py +1 -1
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/generics/broker.py +4 -3
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/uplink/uplink_utils.py +0 -1
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/upstox.py +8 -8
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/xts.py +5 -7
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/xts_utils/Connect.py +4 -5
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/xts_utils/InteractiveSocketClient.py +13 -13
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/utils/pickle_utils.py +3 -3
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/wrapper/aws/s3.py +3 -3
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay.egg-info/PKG-INFO +1 -1
- {quantplay-2.0.33 → quantplay-2.0.35}/setup.py +1 -1
- {quantplay-2.0.33 → quantplay-2.0.35}/README.md +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/pyproject.toml +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/auto_login/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/auto_login/aliceblue.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/finvasia_utils/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/finvasia_utils/fa_noren.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/flattrade.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/ft_utils/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/ft_utils/flattrade_utils.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/ft_utils/ft_noren.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/generics/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/iifl_xts.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/kite_utils.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/motilal.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/noren.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/shoonya.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/uplink/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/xts_utils/Exception.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/xts_utils/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/broker/zerodha.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/exception/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/exception/exceptions.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/model/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/model/broker.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/model/generics.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/model/instrument_data.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/model/order_event.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/py.typed +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/utils/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/utils/constant.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/utils/exchange.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/utils/number_utils.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/utils/selenium_utils.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/wrapper/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay/wrapper/aws/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay.egg-info/SOURCES.txt +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay.egg-info/dependency_links.txt +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay.egg-info/requires.txt +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/quantplay.egg-info/top_level.txt +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/setup.cfg +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/tests/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/tests/conftest.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/tests/wrapper/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/tests/wrapper/aws/__init__.py +0 -0
- {quantplay-2.0.33 → quantplay-2.0.35}/tests/wrapper/aws/s3_test.py +0 -0
|
@@ -134,7 +134,7 @@ class Aliceblue(Broker):
|
|
|
134
134
|
return TransactionType.Sell
|
|
135
135
|
|
|
136
136
|
raise InvalidArgumentException(
|
|
137
|
-
"transaction type {} not supported for trading"
|
|
137
|
+
f"transaction type {transaction_type} not supported for trading"
|
|
138
138
|
)
|
|
139
139
|
|
|
140
140
|
def get_order_type(self, order_type):
|
|
@@ -170,9 +170,7 @@ class Aliceblue(Broker):
|
|
|
170
170
|
]:
|
|
171
171
|
return product
|
|
172
172
|
|
|
173
|
-
raise InvalidArgumentException(
|
|
174
|
-
"Product {} not supported for trading".format(product)
|
|
175
|
-
)
|
|
173
|
+
raise InvalidArgumentException(f"Product {product} not supported for trading")
|
|
176
174
|
|
|
177
175
|
def place_order(
|
|
178
176
|
self,
|
|
@@ -5,7 +5,7 @@ import json
|
|
|
5
5
|
import pickle
|
|
6
6
|
from queue import Queue
|
|
7
7
|
import traceback
|
|
8
|
-
from typing import Callable, Dict
|
|
8
|
+
from typing import Any, Callable, Dict
|
|
9
9
|
|
|
10
10
|
from SmartApi.smartExceptions import DataException
|
|
11
11
|
import polars as pl
|
|
@@ -157,9 +157,7 @@ class AngelOne(Broker):
|
|
|
157
157
|
elif product in ["BO", "MARGIN", "INTRADAY", "CARRYFORWARD", "DELIVERY"]:
|
|
158
158
|
return product
|
|
159
159
|
|
|
160
|
-
raise InvalidArgumentException(
|
|
161
|
-
"Product {} not supported for trading".format(product)
|
|
162
|
-
)
|
|
160
|
+
raise InvalidArgumentException(f"Product {product} not supported for trading")
|
|
163
161
|
|
|
164
162
|
def ltp(self, exchange, tradingsymbol: str) -> float:
|
|
165
163
|
if tradingsymbol in MarketConstants.INDEX_SYMBOL_TO_DERIVATIVE_SYMBOL_MAP:
|
|
@@ -224,7 +222,7 @@ class AngelOne(Broker):
|
|
|
224
222
|
"ordertag": tag,
|
|
225
223
|
}
|
|
226
224
|
|
|
227
|
-
Constants.logger.info("[PLACING_ORDER] {
|
|
225
|
+
Constants.logger.info(f"[PLACING_ORDER] {json.dumps(order)}")
|
|
228
226
|
return self.invoke_angelone_api(self.wrapper.placeOrder, orderparams=order)
|
|
229
227
|
|
|
230
228
|
except (TimeoutError, ConnectTimeout):
|
|
@@ -563,22 +561,28 @@ class AngelOne(Broker):
|
|
|
563
561
|
stop_max_attempt_number=3,
|
|
564
562
|
retry_on_exception=retry_exception,
|
|
565
563
|
)
|
|
566
|
-
def invoke_angelone_api(self, fn: Callable, *args, **kwargs) ->
|
|
564
|
+
def invoke_angelone_api(self, fn: Callable, *args, **kwargs) -> Any:
|
|
567
565
|
try:
|
|
568
566
|
response = fn(*args, **kwargs)
|
|
569
567
|
if "errorCode" in response and response["errorCode"] == "AG8001":
|
|
570
568
|
raise TokenException(f"{self.user_id}: Invalid Token")
|
|
571
|
-
|
|
569
|
+
|
|
570
|
+
elif isinstance(response, bytes):
|
|
572
571
|
raise InvalidArgumentException(
|
|
573
572
|
"Invalid data response. AngelOne sent incorrect data, Please check."
|
|
574
573
|
)
|
|
575
574
|
|
|
576
575
|
return response
|
|
576
|
+
|
|
577
577
|
except (TokenException, InvalidArgumentException):
|
|
578
578
|
raise
|
|
579
|
+
|
|
579
580
|
except DataException as e:
|
|
580
|
-
|
|
581
|
+
if "Access denied because of exceeding access rate" in str(e):
|
|
582
|
+
raise RetryableException(str(e))
|
|
583
|
+
|
|
581
584
|
raise BrokerException(str(e))
|
|
582
|
-
|
|
585
|
+
|
|
586
|
+
except Exception as e:
|
|
583
587
|
traceback.print_exc()
|
|
584
|
-
raise RetryableException(
|
|
588
|
+
raise RetryableException(str(e))
|
|
@@ -147,7 +147,7 @@ class Broker:
|
|
|
147
147
|
if not input:
|
|
148
148
|
raise InvalidArgumentException(message)
|
|
149
149
|
|
|
150
|
-
def symbol_attribute(self, exchange: ExchangeType, symbol, value):
|
|
150
|
+
def symbol_attribute(self, exchange: ExchangeType, symbol: str, value):
|
|
151
151
|
try:
|
|
152
152
|
return_value = self.symbol_data[f"{exchange}:{symbol}"][value]
|
|
153
153
|
return return_value
|
|
@@ -307,6 +307,7 @@ class Broker:
|
|
|
307
307
|
file_name = url.split(".txt")[0].split("/")[-1]
|
|
308
308
|
os.system("cp /tmp/{}.txt /tmp/{}.csv".format(file_name, file_name))
|
|
309
309
|
time.sleep(2)
|
|
310
|
+
|
|
310
311
|
return pd.read_csv("/tmp/{}.csv".format(file_name))
|
|
311
312
|
|
|
312
313
|
def initialize_expiry_fields(self):
|
|
@@ -1166,13 +1167,13 @@ class Broker:
|
|
|
1166
1167
|
if modification_count[order_id] > max_modification_count:
|
|
1167
1168
|
order["order_type"] = "MARKET"
|
|
1168
1169
|
order["price"] = 0
|
|
1169
|
-
Constants.logger.info("Placing MARKET order [{}]"
|
|
1170
|
+
Constants.logger.info(f"Placing MARKET order [{order}]")
|
|
1170
1171
|
self.modify_order(order) # type: ignore
|
|
1171
1172
|
|
|
1172
1173
|
elif modification_count[order_id] > 20:
|
|
1173
1174
|
self.cancel_order(order_id)
|
|
1174
1175
|
Constants.logger.error(
|
|
1175
|
-
"Max Modification Limit Exceeded : [{}]"
|
|
1176
|
+
f"Max Modification Limit Exceeded : [{order_id}]"
|
|
1176
1177
|
)
|
|
1177
1178
|
|
|
1178
1179
|
def log_event(
|
|
@@ -142,8 +142,8 @@ class Upstox(Broker):
|
|
|
142
142
|
f"{self.get_exchange(symbol_info['exchange'])}:{tradingsymbol}"
|
|
143
143
|
].last_price
|
|
144
144
|
except ApiException as e:
|
|
145
|
-
Constants.logger.error("Exception when calling MarketQuoteApi->ltp: %s\n" % e)
|
|
146
145
|
self.handle_exception(e)
|
|
146
|
+
Constants.logger.error("Exception when calling MarketQuoteApi->ltp: %s\n" % e)
|
|
147
147
|
return ltp
|
|
148
148
|
|
|
149
149
|
@retry(
|
|
@@ -172,6 +172,7 @@ class Upstox(Broker):
|
|
|
172
172
|
api_response = api_instance.modify_order(body, self.api_version)
|
|
173
173
|
return api_response.status # type:ignore
|
|
174
174
|
except ApiException as e:
|
|
175
|
+
self.handle_exception(e)
|
|
175
176
|
Constants.logger.error(
|
|
176
177
|
"Exception when calling OrderApi->modify_order: %s\n" % e
|
|
177
178
|
)
|
|
@@ -181,10 +182,9 @@ class Upstox(Broker):
|
|
|
181
182
|
order_to_modify["order_id"], order_to_modify["price"]
|
|
182
183
|
)
|
|
183
184
|
)
|
|
184
|
-
self.handle_exception(e)
|
|
185
185
|
return order_to_modify["order_id"]
|
|
186
186
|
|
|
187
|
-
def cancel_order(self, order_id: str, variety=None) -> None:
|
|
187
|
+
def cancel_order(self, order_id: str, variety: str | None = None) -> None:
|
|
188
188
|
api_instance = upstox_client.OrderApi(self.api_client)
|
|
189
189
|
|
|
190
190
|
try:
|
|
@@ -289,8 +289,8 @@ class Upstox(Broker):
|
|
|
289
289
|
self.email = response["email"]
|
|
290
290
|
self.enabled_exchanges = response["exchanges"]
|
|
291
291
|
except ApiException as e:
|
|
292
|
-
Constants.logger.info("error when calling UserApi->get_profile: %s\n" % e)
|
|
293
292
|
self.handle_exception(e)
|
|
293
|
+
Constants.logger.info("error when calling UserApi->get_profile: %s\n" % e)
|
|
294
294
|
|
|
295
295
|
self.user_id = response["user_id"]
|
|
296
296
|
return response
|
|
@@ -305,10 +305,10 @@ class Upstox(Broker):
|
|
|
305
305
|
holdings = [holding.to_dict() for holding in api_response.data] # type:ignore
|
|
306
306
|
holdings_df = pl.DataFrame(holdings)
|
|
307
307
|
except ApiException as e:
|
|
308
|
+
self.handle_exception(e)
|
|
308
309
|
Constants.logger.error(
|
|
309
310
|
"Exception when calling PortfolioApi->get_holdings: %s\n" % e
|
|
310
311
|
)
|
|
311
|
-
self.handle_exception(e)
|
|
312
312
|
|
|
313
313
|
if len(holdings_df) == 0:
|
|
314
314
|
return pl.DataFrame(schema=self.holidings_schema)
|
|
@@ -359,10 +359,10 @@ class Upstox(Broker):
|
|
|
359
359
|
]
|
|
360
360
|
positions_df = pl.DataFrame(positions)
|
|
361
361
|
except ApiException as e:
|
|
362
|
+
self.handle_exception(e)
|
|
362
363
|
Constants.logger.error(
|
|
363
364
|
"Exception when calling PortfolioApi->get_positions: %s\n" % e
|
|
364
365
|
)
|
|
365
|
-
self.handle_exception(e)
|
|
366
366
|
|
|
367
367
|
if len(positions_df) == 0:
|
|
368
368
|
return pl.DataFrame(schema=self.positions_schema)
|
|
@@ -451,10 +451,10 @@ class Upstox(Broker):
|
|
|
451
451
|
orders = [order.to_dict() for order in api_response.data] # type:ignore
|
|
452
452
|
orders_df = pl.DataFrame(orders)
|
|
453
453
|
except ApiException as e:
|
|
454
|
+
self.handle_exception(e)
|
|
454
455
|
Constants.logger.error(
|
|
455
456
|
"Exception when calling OrderApi->get_order_book: %s\n" % e
|
|
456
457
|
)
|
|
457
|
-
self.handle_exception(e)
|
|
458
458
|
|
|
459
459
|
if len(orders_df) == 0:
|
|
460
460
|
return pl.DataFrame(schema=self.orders_schema)
|
|
@@ -570,10 +570,10 @@ class Upstox(Broker):
|
|
|
570
570
|
api_response.data["equity"].available_margin # type:ignore
|
|
571
571
|
)
|
|
572
572
|
except ApiException as e:
|
|
573
|
+
self.handle_exception(e)
|
|
573
574
|
Constants.logger.error(
|
|
574
575
|
"Exception when calling UserApi->get_user_fund_margin: %s\n" % e
|
|
575
576
|
)
|
|
576
|
-
self.handle_exception(e)
|
|
577
577
|
|
|
578
578
|
margins = {
|
|
579
579
|
"margin_used": margin_used,
|
|
@@ -8,9 +8,7 @@ from typing import Dict
|
|
|
8
8
|
|
|
9
9
|
import pandas as pd
|
|
10
10
|
import polars as pl
|
|
11
|
-
import requests
|
|
12
11
|
from retrying import retry # type: ignore
|
|
13
|
-
from urllib3.exceptions import InsecureRequestWarning
|
|
14
12
|
|
|
15
13
|
from quantplay.broker.generics.broker import Broker
|
|
16
14
|
from quantplay.broker.xts_utils.Connect import XTSConnect
|
|
@@ -32,9 +30,6 @@ from quantplay.model.order_event import OrderUpdateEvent
|
|
|
32
30
|
from quantplay.utils.constant import Constants, OrderType
|
|
33
31
|
from quantplay.utils.pickle_utils import InstrumentData, PickleUtils
|
|
34
32
|
|
|
35
|
-
# -# Suppress only the single warning from urllib3 needed.
|
|
36
|
-
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning) # type: ignore
|
|
37
|
-
|
|
38
33
|
|
|
39
34
|
class XTS(Broker):
|
|
40
35
|
source = "WebAPI"
|
|
@@ -57,7 +52,7 @@ class XTS(Broker):
|
|
|
57
52
|
self.root_url = root_url
|
|
58
53
|
|
|
59
54
|
try:
|
|
60
|
-
if wrapper:
|
|
55
|
+
if wrapper and ClientID:
|
|
61
56
|
self.set_wrapper(wrapper, md_wrapper)
|
|
62
57
|
self.ClientID = ClientID
|
|
63
58
|
self.wrapper.root = root_url
|
|
@@ -169,7 +164,7 @@ class XTS(Broker):
|
|
|
169
164
|
):
|
|
170
165
|
raise TokenException(response["description"])
|
|
171
166
|
if "type" in response and response["type"] == "error":
|
|
172
|
-
raise Exception("[XTS_Error]:
|
|
167
|
+
raise Exception(f"[XTS_Error]: {response["description"]}")
|
|
173
168
|
|
|
174
169
|
@retry(
|
|
175
170
|
wait_exponential_multiplier=3000,
|
|
@@ -703,6 +698,9 @@ class XTS(Broker):
|
|
|
703
698
|
)
|
|
704
699
|
|
|
705
700
|
def stream_order_updates(self):
|
|
701
|
+
if self.wrapper.token is None:
|
|
702
|
+
raise InvalidArgumentException("XTS Token Missing")
|
|
703
|
+
|
|
706
704
|
socket = OrderSocket_io(
|
|
707
705
|
userID=self.ClientID,
|
|
708
706
|
token=self.wrapper.token,
|
|
@@ -3,8 +3,6 @@ Connect.py
|
|
|
3
3
|
|
|
4
4
|
API wrapper for XTS Connect REST APIs.
|
|
5
5
|
|
|
6
|
-
:copyright:
|
|
7
|
-
:license: see LICENSE for details.
|
|
8
6
|
"""
|
|
9
7
|
|
|
10
8
|
import json
|
|
@@ -14,6 +12,7 @@ import traceback
|
|
|
14
12
|
from typing import Any, Dict, Literal
|
|
15
13
|
|
|
16
14
|
import requests
|
|
15
|
+
import urllib3
|
|
17
16
|
import requests.adapters
|
|
18
17
|
|
|
19
18
|
from six.moves.urllib.parse import urljoin # type:ignore
|
|
@@ -24,6 +23,9 @@ from quantplay.exception.exceptions import BrokerException
|
|
|
24
23
|
|
|
25
24
|
log = logging.getLogger(__name__)
|
|
26
25
|
|
|
26
|
+
# Disable requests SSL warning
|
|
27
|
+
urllib3.disable_warnings(category=urllib3.exceptions.InsecureRequestWarning)
|
|
28
|
+
|
|
27
29
|
|
|
28
30
|
class XTSCommon:
|
|
29
31
|
"""
|
|
@@ -192,9 +194,6 @@ class XTSConnect(XTSCommon):
|
|
|
192
194
|
else:
|
|
193
195
|
self.reqsession = requests
|
|
194
196
|
|
|
195
|
-
# disable requests SSL warning
|
|
196
|
-
requests.packages.urllib3.disable_warnings() # type:ignore
|
|
197
|
-
|
|
198
197
|
def _set_common_variables(
|
|
199
198
|
self, access_token: str, userID: str, isInvestorClient: bool
|
|
200
199
|
):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Literal
|
|
1
|
+
from typing import Dict, List, Literal
|
|
2
2
|
import socketio
|
|
3
3
|
|
|
4
4
|
|
|
@@ -38,16 +38,16 @@ class OrderSocket_io(socketio.Client):
|
|
|
38
38
|
|
|
39
39
|
def __init__(
|
|
40
40
|
self,
|
|
41
|
-
token,
|
|
42
|
-
userID,
|
|
43
|
-
root_url,
|
|
44
|
-
reconnection=True,
|
|
45
|
-
reconnection_attempts=0,
|
|
46
|
-
reconnection_delay=1,
|
|
47
|
-
reconnection_delay_max=50000,
|
|
48
|
-
randomization_factor=0.5,
|
|
49
|
-
logger=False,
|
|
50
|
-
binary=False,
|
|
41
|
+
token: str,
|
|
42
|
+
userID: str,
|
|
43
|
+
root_url: str,
|
|
44
|
+
reconnection: bool = True,
|
|
45
|
+
reconnection_attempts: int = 0,
|
|
46
|
+
reconnection_delay: float = 1,
|
|
47
|
+
reconnection_delay_max: float = 50000,
|
|
48
|
+
randomization_factor: float = 0.5,
|
|
49
|
+
logger: bool = False,
|
|
50
|
+
binary: bool = False,
|
|
51
51
|
json=None,
|
|
52
52
|
**kwargs,
|
|
53
53
|
):
|
|
@@ -80,9 +80,9 @@ class OrderSocket_io(socketio.Client):
|
|
|
80
80
|
|
|
81
81
|
def connect( # type: ignore
|
|
82
82
|
self,
|
|
83
|
-
headers={},
|
|
83
|
+
headers: Dict[str, str] = {},
|
|
84
84
|
transports: Literal["polling", "websocket"] = "websocket",
|
|
85
|
-
namespaces=None,
|
|
85
|
+
namespaces: List[str] | None = None,
|
|
86
86
|
socketio_path: str = "/interactive/socket.io",
|
|
87
87
|
verify: bool = False,
|
|
88
88
|
):
|
|
@@ -8,12 +8,12 @@ from quantplay.model.instrument_data import InstrumentDataType
|
|
|
8
8
|
class PickleUtils:
|
|
9
9
|
@staticmethod
|
|
10
10
|
def save_data(data: Any, file_name: str):
|
|
11
|
-
with open("/tmp/{}.pickle"
|
|
11
|
+
with open(f"/tmp/{file_name}.pickle", "wb") as handle:
|
|
12
12
|
pickle.dump(data, handle, protocol=pickle.HIGHEST_PROTOCOL)
|
|
13
13
|
|
|
14
14
|
@staticmethod
|
|
15
15
|
def load_data(file_name: str):
|
|
16
|
-
with open("/tmp/{}.pickle"
|
|
16
|
+
with open(f"/tmp/{file_name}.pickle", "rb") as disk_data:
|
|
17
17
|
unserialized_data = pickle.load(disk_data)
|
|
18
18
|
|
|
19
19
|
return unserialized_data
|
|
@@ -44,7 +44,7 @@ class InstrumentData:
|
|
|
44
44
|
|
|
45
45
|
try:
|
|
46
46
|
self.lock.acquire()
|
|
47
|
-
with open("/tmp/{}.pickle"
|
|
47
|
+
with open(f"/tmp/{file_name}.pickle", "rb") as disk_data:
|
|
48
48
|
unserialized_data = pickle.load(disk_data)
|
|
49
49
|
self.instrument_data[file_name] = unserialized_data
|
|
50
50
|
self.lock.release()
|
|
@@ -37,15 +37,15 @@ class S3Utils:
|
|
|
37
37
|
lock.release()
|
|
38
38
|
|
|
39
39
|
except Exception:
|
|
40
|
-
print("Data not found for {}"
|
|
40
|
+
print(f"Data not found for {key}")
|
|
41
41
|
|
|
42
|
-
print("fetching bucket from s3 {} key {}"
|
|
42
|
+
print(f"fetching bucket from s3 {bucket} key {key}")
|
|
43
43
|
|
|
44
44
|
client = boto3.client("s3") # type: ignore
|
|
45
45
|
raw_stream = client.get_object(Bucket=bucket, Key=key)
|
|
46
46
|
content = raw_stream["Body"].read().decode("utf-8")
|
|
47
47
|
|
|
48
|
-
print("Saving data at
|
|
48
|
+
print(f"Saving data at /tmp/{key}")
|
|
49
49
|
full_folder_path = full_path[0 : full_path.rfind("/")]
|
|
50
50
|
if not os.path.exists(full_folder_path):
|
|
51
51
|
os.makedirs(full_folder_path)
|
|
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
|