(20250128) Accepting null messages in WhatsApp Nimbus.
This commit is contained in:
@@ -165,7 +165,7 @@ async def mark_call_as_active(
|
|||||||
redis_key = tick_ref["redisKey"]
|
redis_key = tick_ref["redisKey"]
|
||||||
|
|
||||||
# Mark locally:
|
# Mark locally:
|
||||||
print(f"CALL ({redis_key}):", json.to_string(tick_ref))
|
# print(f"CALL ({redis_key}):", json.to_string(tick_ref))
|
||||||
ACTIVE_CALLS[redis_key] = tick_ref
|
ACTIVE_CALLS[redis_key] = tick_ref
|
||||||
|
|
||||||
# Mark in cache:
|
# Mark in cache:
|
||||||
@@ -175,7 +175,7 @@ async def mark_call_as_active(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Mark in SQL:
|
# Mark in SQL:
|
||||||
proc_name = "portfolio_trade_add"
|
proc_name = "strategy_trade_add"
|
||||||
proc_args = (
|
proc_args = (
|
||||||
tick_ref["userId"], # ........................................................ p_user_id
|
tick_ref["userId"], # ........................................................ p_user_id
|
||||||
tick_ref["billingAccountId"], # .............................................. p_billing_account_id
|
tick_ref["billingAccountId"], # .............................................. p_billing_account_id
|
||||||
@@ -191,7 +191,7 @@ async def mark_call_as_active(
|
|||||||
0, # ......................................................................... p_price
|
0, # ......................................................................... p_price
|
||||||
tick["ltp"], # ............................................................... p_refPrice
|
tick["ltp"], # ............................................................... p_refPrice
|
||||||
tick_ref["eqQty"] if tick_ref["segment"] == "EQ" else tick_ref["foQty"], # ... p_refQty
|
tick_ref["eqQty"] if tick_ref["segment"] == "EQ" else tick_ref["foQty"], # ... p_refQty
|
||||||
tick["exchangeToken"] # ...................................................... p_exchange_code
|
tick_ref["exchangeCode"] # .................................................. p_exchange_code
|
||||||
)
|
)
|
||||||
db_json, db_exception = await sql_reader.call_procedure_and_get_json(
|
db_json, db_exception = await sql_reader.call_procedure_and_get_json(
|
||||||
procedure_name = proc_name,
|
procedure_name = proc_name,
|
||||||
@@ -235,9 +235,9 @@ async def call_is_active(
|
|||||||
|
|
||||||
# Check if the call is active:
|
# Check if the call is active:
|
||||||
if ACTIVE_CALLS.get(redis_key): return True
|
if ACTIVE_CALLS.get(redis_key): return True
|
||||||
# if await redis_cache.get(redis_key):
|
if await redis_cache.get(redis_key):
|
||||||
# ACTIVE_CALLS[redis_key] = tick_ref
|
ACTIVE_CALLS[redis_key] = tick_ref
|
||||||
# return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@@ -525,7 +525,7 @@ async def init(
|
|||||||
|
|
||||||
# Caching connections:
|
# Caching connections:
|
||||||
redis_cache = AsyncRedisCache(
|
redis_cache = AsyncRedisCache(
|
||||||
connection_string = script_cred["redisCache"]["general"]["connectionString"],
|
connection_string = script_cred["redisCache"]["strategies"]["connectionString"],
|
||||||
debug = False,
|
debug = False,
|
||||||
debug_prefix = "Cache | "
|
debug_prefix = "Cache | "
|
||||||
)
|
)
|
||||||
@@ -595,8 +595,9 @@ async def refresh_strategy_reference() -> bool:
|
|||||||
no_context_printer("Refreshing strategy ref.")
|
no_context_printer("Refreshing strategy ref.")
|
||||||
|
|
||||||
# Query the database:
|
# Query the database:
|
||||||
proc_name = "strategy_results"
|
proc_name = "strategy_results_all"
|
||||||
proc_args = (0, 184, 0)
|
# proc_args = (0, 184, 0)
|
||||||
|
proc_args = ()
|
||||||
db_json, db_exception = await sql_reader.call_procedure_and_get_json(
|
db_json, db_exception = await sql_reader.call_procedure_and_get_json(
|
||||||
procedure_name = proc_name,
|
procedure_name = proc_name,
|
||||||
procedure_args = proc_args,
|
procedure_args = proc_args,
|
||||||
@@ -629,6 +630,7 @@ async def refresh_strategy_reference() -> bool:
|
|||||||
key_items.append(str(i["right"]))
|
key_items.append(str(i["right"]))
|
||||||
key_items.append(str(i["strike"]))
|
key_items.append(str(i["strike"]))
|
||||||
tick_key = "_".join(key_items)
|
tick_key = "_".join(key_items)
|
||||||
|
strategy_id = i["strategy_id"]
|
||||||
strategy_name = i["name"]
|
strategy_name = i["name"]
|
||||||
strategy_entry = i["entry"].upper().strip()
|
strategy_entry = i["entry"].upper().strip()
|
||||||
formatted_reference.append({
|
formatted_reference.append({
|
||||||
@@ -637,7 +639,7 @@ async def refresh_strategy_reference() -> bool:
|
|||||||
"eqQty": i["eq_qty"],
|
"eqQty": i["eq_qty"],
|
||||||
"foQty": i["fno_qty"],
|
"foQty": i["fno_qty"],
|
||||||
"tickKey": tick_key,
|
"tickKey": tick_key,
|
||||||
"redisKey": f"{tick_key}_{strategy_name}_{strategy_entry}",
|
"redisKey": f"{tick_key}_{strategy_name}_{strategy_id}_{strategy_entry}",
|
||||||
"stratId": i["strategy_id"], # .......... As inserted by the user.
|
"stratId": i["strategy_id"], # .......... As inserted by the user.
|
||||||
"stratName": strategy_name, # .......... As inserted by the user.
|
"stratName": strategy_name, # .......... As inserted by the user.
|
||||||
"watchlistId": i["watch_list_id"], # ... A unique id in case 2 users come up with the same name.
|
"watchlistId": i["watch_list_id"], # ... A unique id in case 2 users come up with the same name.
|
||||||
@@ -650,7 +652,8 @@ async def refresh_strategy_reference() -> bool:
|
|||||||
"expiry": i["expiry_date"],
|
"expiry": i["expiry_date"],
|
||||||
"strike": i["strike"],
|
"strike": i["strike"],
|
||||||
"right": i["right"],
|
"right": i["right"],
|
||||||
"symbol": i["symbol"]
|
"symbol": i["symbol"],
|
||||||
|
"exchangeCode": i["exchange_code"],
|
||||||
})
|
})
|
||||||
|
|
||||||
# Save the new reference in the global variable:
|
# Save the new reference in the global variable:
|
||||||
|
|||||||
@@ -92,10 +92,11 @@ class NimbusWhatsAppMessage(BaseModel):
|
|||||||
frozen = True
|
frozen = True
|
||||||
)
|
)
|
||||||
|
|
||||||
message: str = Field(
|
message: str | None = Field(
|
||||||
description = "The actual text that you want to send.",
|
description = "The actual text that you want to send.",
|
||||||
min_length = 1,
|
# min_length = 1,
|
||||||
frozen = True
|
frozen = True,
|
||||||
|
default = None
|
||||||
)
|
)
|
||||||
|
|
||||||
pdfUrl: str | None = Field(
|
pdfUrl: str | None = Field(
|
||||||
|
|||||||
Reference in New Issue
Block a user