tradx 0.7.9__py3-none-any.whl → 0.7.11__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.
tradx/marketDataEngine.py
CHANGED
@@ -21,6 +21,92 @@ import json
|
|
21
21
|
import pandas
|
22
22
|
import asyncio
|
23
23
|
|
24
|
+
import pandas as pd
|
25
|
+
import math
|
26
|
+
from decimal import Decimal
|
27
|
+
from io import StringIO
|
28
|
+
|
29
|
+
|
30
|
+
def cm_master_string_to_df(cm_master_result: str) -> pd.DataFrame:
|
31
|
+
"""
|
32
|
+
Converts the response of cm_master API to a pandas DataFrame.
|
33
|
+
|
34
|
+
This function takes a string response from the cm_master API, which contains data separated by the '|' character,
|
35
|
+
and converts it into a pandas DataFrame. The DataFrame will have predefined column headers.
|
36
|
+
|
37
|
+
Parameters:
|
38
|
+
cm_master_result (str): The string response from the cm_master API.
|
39
|
+
|
40
|
+
Returns:
|
41
|
+
pd.DataFrame: A pandas DataFrame containing the parsed data from the cm_master_result string.
|
42
|
+
"""
|
43
|
+
col_header = [
|
44
|
+
"ExchangeSegment",
|
45
|
+
"ExchangeInstrumentID",
|
46
|
+
"InstrumentType",
|
47
|
+
"Name",
|
48
|
+
"Description",
|
49
|
+
"Series",
|
50
|
+
"NameWithSeries",
|
51
|
+
"InstrumentID",
|
52
|
+
"PriceBand_High",
|
53
|
+
"PriceBand_Low",
|
54
|
+
"FreezeQty",
|
55
|
+
"TickSize",
|
56
|
+
"LotSize",
|
57
|
+
"Multiplier",
|
58
|
+
"DisplayName",
|
59
|
+
"ISIN",
|
60
|
+
"PriceNumerator",
|
61
|
+
"PriceDenominator",
|
62
|
+
"DetailedDescription",
|
63
|
+
"ExtendedSurvlndicator",
|
64
|
+
"Cautionlndicator",
|
65
|
+
"GSMIndicator",
|
66
|
+
]
|
67
|
+
_dtype = {
|
68
|
+
"ExchangeSegment": str,
|
69
|
+
"ExchangeInstrumentID": int,
|
70
|
+
"InstrumentType": int,
|
71
|
+
"Name": str,
|
72
|
+
"Description": str,
|
73
|
+
"Series": str,
|
74
|
+
"NameWithSeries": str,
|
75
|
+
"InstrumentID": int,
|
76
|
+
"LotSize": int,
|
77
|
+
"Multiplier": int,
|
78
|
+
"DisplayName": str,
|
79
|
+
"ISIN": str,
|
80
|
+
"PriceNumerator": int,
|
81
|
+
"PriceDenominator": int,
|
82
|
+
"DetailedDescription": str,
|
83
|
+
"ExtendedSurvlndicator": int,
|
84
|
+
"Cautionlndicator": int,
|
85
|
+
"GSMIndicator": int,
|
86
|
+
}
|
87
|
+
_converters = {
|
88
|
+
"PriceBand_High": Decimal,
|
89
|
+
"PriceBand_Low": Decimal,
|
90
|
+
"TickSize": Decimal,
|
91
|
+
"FreezeQty": float, # Define FreezeQty as float first
|
92
|
+
}
|
93
|
+
|
94
|
+
cm_master_df = pd.read_csv(
|
95
|
+
StringIO(cm_master_result),
|
96
|
+
sep="|",
|
97
|
+
low_memory=False,
|
98
|
+
header=None,
|
99
|
+
names=col_header,
|
100
|
+
dtype=_dtype,
|
101
|
+
converters=_converters,
|
102
|
+
)
|
103
|
+
|
104
|
+
cm_master_df["FreezeQty"] = cm_master_df["FreezeQty"].apply(
|
105
|
+
lambda x: int(math.floor(x))
|
106
|
+
) # Floor and convert to int
|
107
|
+
|
108
|
+
return cm_master_df
|
109
|
+
|
24
110
|
|
25
111
|
class marketDataEngine(MarketDataSocketClient):
|
26
112
|
"""Class for market DATA API obj"""
|
@@ -436,8 +522,9 @@ class marketDataEngine(MarketDataSocketClient):
|
|
436
522
|
"""Get Master Instruments Request for NSE cash market segment"""
|
437
523
|
exchangesegments = [self.xt.EXCHANGE_NSECM, self.xt.EXCHANGE_BSECM]
|
438
524
|
response = await self.xt.get_master(exchangeSegmentList=exchangesegments)
|
439
|
-
self.CM_MASTER_DF =
|
440
|
-
|
525
|
+
self.CM_MASTER_DF: pandas.DataFrame = cm_master_string_to_df(
|
526
|
+
response["result"]
|
527
|
+
)
|
441
528
|
self.CM_MASTER_DF.to_csv(f"MASTER_CM.csv", index=False)
|
442
529
|
|
443
530
|
if self.user_logger:
|
@@ -2,7 +2,7 @@ tradx/__init__.py,sha256=MlWuula4lJZLPYPi4d5ZE9yoJnYWtgbZ0QsgWdWPwU0,53
|
|
2
2
|
tradx/algoContainer.py,sha256=1IkVCIF_gXIby8z3pDdlVeUablh-PZVZ1EawyCB7oUs,3807
|
3
3
|
tradx/dualHashMap.py,sha256=XsidIc3aMvpVGOvdfV7lOeZaLCWAD5i180BGyAfdYXE,1737
|
4
4
|
tradx/interactiveEngine.py,sha256=ln7dT_S0HaFHA36AW5P0o6svYGSLlmBThheIhJQ6D34,38912
|
5
|
-
tradx/marketDataEngine.py,sha256=
|
5
|
+
tradx/marketDataEngine.py,sha256=W3EF-BSQX20jDm4kdVT9F6Qh1GAI2udO6Z3P280QIYM,37630
|
6
6
|
tradx/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
tradx/baseClass/baseAlgo.py,sha256=LE4ZYb-gLpPMU45ETMg58kRQdGN-Q9wgDhKEasovL-k,20922
|
8
8
|
tradx/baseClass/candleData.py,sha256=tS-iAoRGwK2xVSvrqmNZPYeB63qD53oPPHaUDfJBWkk,2947
|
@@ -28,6 +28,6 @@ tradx/baseClass/tradeEvent.py,sha256=djunJW5AzjeMfJZVMlrFprplB7vrYBi-mmaR1TA0MK4
|
|
28
28
|
tradx/constants/holidays.py,sha256=B4ee4bPFy-gBTKN6-G68Idf1n6HxoRcx72O92zSobcE,1200
|
29
29
|
tradx/logger/logger.py,sha256=DfrjzwYkujTq7arksNTPcQeioXnwT1xgN659blhreog,3232
|
30
30
|
tradx/logger/logger2.py,sha256=ebJ-qqnpnCqvyx1Cz1-kGGULtkH-hfrK6UNfa0bSlH8,2654
|
31
|
-
tradx-0.7.
|
32
|
-
tradx-0.7.
|
33
|
-
tradx-0.7.
|
31
|
+
tradx-0.7.11.dist-info/METADATA,sha256=Anlna3ve8FrC7uvbWc34-VfegzreuHEBWacJY16lJPE,2629
|
32
|
+
tradx-0.7.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
33
|
+
tradx-0.7.11.dist-info/RECORD,,
|
File without changes
|