Resetting utils subtree.
This commit is contained in:
@@ -88,7 +88,7 @@ http_client = httpx.AsyncClient(
|
||||
pool = 120.0, # .... Time to wait for a free connection from the pool.
|
||||
connect = 2.5, # ... Time to wait for establishing a connection to the server.
|
||||
write = 10.0, # .... Time to wait for sending data.
|
||||
read = 9.9 # ....... Time to wait for receiving data.
|
||||
read = 120.0 # ..... Time to wait for receiving data.
|
||||
)
|
||||
)
|
||||
|
||||
@@ -339,13 +339,6 @@ async def capture_fo_eod_data(
|
||||
query_data.append(one_query_data)
|
||||
|
||||
# Run the commands:
|
||||
print(query_data[3034][19])
|
||||
print(query_data[3035][19])
|
||||
print(query_data[3036][19])
|
||||
print("---")
|
||||
print(query_data[2731][19])
|
||||
print(query_data[2732][19])
|
||||
print(query_data[2733][19])
|
||||
no_context_printer("Saving FO data to DB.")
|
||||
rows_affected, db_response = await sql_writer.execute_many(
|
||||
query = query_str,
|
||||
@@ -363,7 +356,9 @@ async def capture_fo_eod_data(
|
||||
|
||||
async def main(
|
||||
target_dates: List[str],
|
||||
interval: float = 5.0
|
||||
interval: float = 5.0,
|
||||
capture_eq: bool = True,
|
||||
capture_fo: bool = True
|
||||
):
|
||||
|
||||
# Declare the needed global variables:
|
||||
@@ -376,6 +371,7 @@ async def main(
|
||||
nse_fo_bhavcopy = NSEFNOBhavCopy(http_client = http_client, debug = False)
|
||||
|
||||
# Load the data for each date:
|
||||
printer(len(target_dates))
|
||||
for dt_str in target_dates:
|
||||
|
||||
# Try parsing the date:
|
||||
@@ -392,30 +388,31 @@ async def main(
|
||||
|
||||
no_context_printer("Picked date.", dt_str)
|
||||
|
||||
# # Fetch the equity data:
|
||||
# success = await capture_eq_eod_data(
|
||||
# nse_conn = nse_eq_bhavcopy,
|
||||
# target_date = dt
|
||||
# )
|
||||
# if not success:
|
||||
# no_context_printer("FAILED equity for date.", dt_str)
|
||||
# failed_eq_dates.append(dt_str)
|
||||
# Fetch the equity data:
|
||||
if capture_eq:
|
||||
success = await capture_eq_eod_data(
|
||||
nse_conn = nse_eq_bhavcopy,
|
||||
target_date = dt
|
||||
)
|
||||
if not success:
|
||||
no_context_printer("FAILED equity for date.", dt_str)
|
||||
failed_eq_dates.append(dt_str)
|
||||
|
||||
# Fetch the derivative data:
|
||||
success = await capture_fo_eod_data(
|
||||
nse_conn = nse_fo_bhavcopy,
|
||||
target_date = dt
|
||||
)
|
||||
if not success:
|
||||
no_context_printer("FAILED derivatives for date.", dt_str)
|
||||
failed_fo_dates.append(dt_str)
|
||||
if capture_fo:
|
||||
success = await capture_fo_eod_data(
|
||||
nse_conn = nse_fo_bhavcopy,
|
||||
target_date = dt
|
||||
)
|
||||
if not success:
|
||||
no_context_printer("FAILED derivatives for date.", dt_str)
|
||||
failed_fo_dates.append(dt_str)
|
||||
|
||||
# Pause for a while to not get rate-limited/blocked:
|
||||
await asyncio.sleep(interval)
|
||||
# break
|
||||
|
||||
# Show the report:
|
||||
printer("Process complete.", failed_to_parse_dates, failed_eq_dates, failed_fo_dates)
|
||||
printer("Process complete.", failed_to_parse_dates, capture_eq, failed_eq_dates, capture_fo, failed_fo_dates)
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
@@ -464,6 +461,20 @@ if __name__ == "__main__":
|
||||
help = "Whether, or not, you want to see debugging messages in the terminal.",
|
||||
default = False
|
||||
)
|
||||
parser.add_argument(
|
||||
"-e", "--eq",
|
||||
dest = "eq",
|
||||
action = "store_true",
|
||||
help = "Whether, or not, you want to capture equity data.",
|
||||
default = False
|
||||
)
|
||||
parser.add_argument(
|
||||
"-f", "--fo",
|
||||
dest = "fo",
|
||||
action = "store_true",
|
||||
help = "Whether, or not, you want to capture F&O (derivatives) data.",
|
||||
default = False
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
@@ -477,7 +488,12 @@ if __name__ == "__main__":
|
||||
if await init(
|
||||
script_id = args.script_id,
|
||||
debug = args.debug
|
||||
): await main(target_dates = target_dates, interval = args.interval)
|
||||
): await main(
|
||||
target_dates = target_dates,
|
||||
interval = args.interval,
|
||||
capture_eq = args.eq,
|
||||
capture_fo = args.fo
|
||||
)
|
||||
|
||||
# Disconnect from the database:
|
||||
disconnected = await sql_writer.disconnect()
|
||||
|
||||
Reference in New Issue
Block a user