(20241226) Kafka certs in order.
This commit is contained in:
@@ -55,6 +55,7 @@ import httpx
|
||||
|
||||
# To work with date and time:
|
||||
import datetime
|
||||
import pytz
|
||||
|
||||
# To work with datatypes:
|
||||
from typing import Any, List
|
||||
@@ -159,8 +160,8 @@ class NSECorporateActions(AsyncNSEBase):
|
||||
# Done here:
|
||||
return api_response
|
||||
|
||||
@staticmethod
|
||||
def format_data(
|
||||
self,
|
||||
raw_json: List[dict],
|
||||
timestamp: datetime.datetime = None,
|
||||
raise_exception: bool = False
|
||||
@@ -188,26 +189,25 @@ class NSECorporateActions(AsyncNSEBase):
|
||||
try:
|
||||
|
||||
# Format the data:
|
||||
formatted_data = [
|
||||
{
|
||||
formatted_data = []
|
||||
for action in raw_json:
|
||||
formatted_data.append({
|
||||
"scrapeTs": timestamp,
|
||||
"symbol": action["symbol"],
|
||||
"company": action["comp"],
|
||||
"isin": action["isin"],
|
||||
"segment": action["series"],
|
||||
"faceVal": action["faceVal"],
|
||||
"action": action["subject"],
|
||||
"exDate": action["exDate"],
|
||||
"recDate": action["recDate"],
|
||||
"bcStartDate": action["bcStartDate"],
|
||||
"bcEndDate": action["bcEndDate"],
|
||||
"ndStartDate": action["ndStartDate"],
|
||||
"caBroadcastDate": action["caBroadcastDate"],
|
||||
"ind": action["ind"],
|
||||
# "action": action["subject"],
|
||||
# "action": action["subject"],
|
||||
} for action in raw_json
|
||||
]
|
||||
"faceVal": float(action["faceVal"]),
|
||||
"action": action["subject"],
|
||||
"exDate": self.parse_datetime_string(action["exDate"], ["%d-%b-%Y"]),
|
||||
"recDate": self.parse_datetime_string(action["recDate"]),
|
||||
"bcStartDate": self.parse_datetime_string(action["bcStartDate"]),
|
||||
"bcEndDate": self.parse_datetime_string(action["bcEndDate"]),
|
||||
"ndStartDate": self.parse_datetime_string(action["ndStartDate"]),
|
||||
"ndEndDate": self.parse_datetime_string(action["ndEndDate"]),
|
||||
"caBroadcastDate": self.parse_datetime_string(action["caBroadcastDate"])
|
||||
})
|
||||
|
||||
# If something goes wrong:
|
||||
except Exception as exception:
|
||||
@@ -248,14 +248,14 @@ if __name__ == "__main__":
|
||||
|
||||
# Get and show the data:
|
||||
to_date = date_time.get_current_ist_date_time()
|
||||
from_date = to_date - datetime.timedelta(days = 31)
|
||||
from_date = to_date - datetime.timedelta(days = 365)
|
||||
print("FROM :", from_date)
|
||||
print("TO :", to_date)
|
||||
api_response = await my_nse.get_data(
|
||||
action_type = NSECorporateActions.TYPE_EQUITIES,
|
||||
from_date = from_date,
|
||||
to_date = to_date,
|
||||
return_raw = True
|
||||
return_raw = False
|
||||
)
|
||||
print("SUMMARY:", api_response.to_markdown(), "\n---\n\n")
|
||||
if api_response.success: print("CORPORATE ACTIONS:", json.to_string(api_response.data, default = str))
|
||||
|
||||
Reference in New Issue
Block a user