tradx 0.7.10__py3-none-any.whl → 0.7.12__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.
@@ -165,9 +165,9 @@ class BaseAlgo(ABC):
165
165
  order.OrderType,
166
166
  order.OrderQuantity,
167
167
  order.OrderDisclosedQuantity,
168
- order.OrderPrice,
168
+ order.OrderAverageTradedPriceAPI,
169
169
  order.OrderStopPrice,
170
- order.OrderSide,
170
+ order.OrderSideAPI,
171
171
  order.TimeInForce,
172
172
  order.OrderStatus,
173
173
  )
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,20 +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
-
440
- a = response["result"].split("\n")
441
- # List to store successfully parsed DataFrames
442
- dfs = []
443
- for line in a:
444
- try:
445
- df = helper.cm_master_string_to_df(
446
- line
447
- ) # Process each line individually
448
- dfs.append(df) # Store successfully parsed DataFrame
449
- except Exception as e:
450
- print(f"Error processing line: {line}\nError: {e}")
451
-
452
- self.CM_MASTER_DF: pandas.DataFrame = pandas.concat(dfs, ignore_index=True)
525
+ self.CM_MASTER_DF: pandas.DataFrame = cm_master_string_to_df(
526
+ response["result"]
527
+ )
453
528
  self.CM_MASTER_DF.to_csv(f"MASTER_CM.csv", index=False)
454
529
 
455
530
  if self.user_logger:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tradx
3
- Version: 0.7.10
3
+ Version: 0.7.12
4
4
  Summary: A Package Designed to simplify strategy development on package xts-api-client
5
5
  Author-email: "jatin.kumawat" <jatin.kumawat@rmoneyindia.com>
6
6
  Requires-Python: >=3.12
@@ -2,9 +2,9 @@ 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=pGIdYc1z2XVFYy09Qimb9kfcRLu_Nt4Yjcewf_DC3_U,35683
5
+ tradx/marketDataEngine.py,sha256=W3EF-BSQX20jDm4kdVT9F6Qh1GAI2udO6Z3P280QIYM,37630
6
6
  tradx/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- tradx/baseClass/baseAlgo.py,sha256=LE4ZYb-gLpPMU45ETMg58kRQdGN-Q9wgDhKEasovL-k,20922
7
+ tradx/baseClass/baseAlgo.py,sha256=C4vteQwUvzb0rGsiKvYn-b4sKoCc3GrjNw34ed0FF_8,20941
8
8
  tradx/baseClass/candleData.py,sha256=tS-iAoRGwK2xVSvrqmNZPYeB63qD53oPPHaUDfJBWkk,2947
9
9
  tradx/baseClass/cmInstrument.py,sha256=WpibHdJyVGVs0B8o1COiXr4rNXB8bapzFLyRaIG0w9Q,2408
10
10
  tradx/baseClass/futureInstrument.py,sha256=ygsGfzUg337gSwoSaAb8DB31YhLOI-nOv3ApX3z5CWQ,2186
@@ -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.10.dist-info/METADATA,sha256=rQwSNcfhXwpQ64gUcPp4D3t1MK0agqHc1fj0w9DXMq8,2629
32
- tradx-0.7.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
33
- tradx-0.7.10.dist-info/RECORD,,
31
+ tradx-0.7.12.dist-info/METADATA,sha256=yKQqP_m4zcLlSxFllenzhr5fsYOmshke72uL_7uBYl0,2629
32
+ tradx-0.7.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
33
+ tradx-0.7.12.dist-info/RECORD,,
File without changes