diff --git a/background/finstitutions/trading/strategy_bhandari_0.py b/background/finstitutions/trading/strategy_bhandari_0.py index aa33cc4..3783790 100644 --- a/background/finstitutions/trading/strategy_bhandari_0.py +++ b/background/finstitutions/trading/strategy_bhandari_0.py @@ -165,7 +165,7 @@ async def mark_call_as_active( redis_key = tick_ref["redisKey"] # 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 # Mark in cache: @@ -175,7 +175,7 @@ async def mark_call_as_active( ) # Mark in SQL: - proc_name = "portfolio_trade_add" + proc_name = "strategy_trade_add" proc_args = ( tick_ref["userId"], # ........................................................ p_user_id tick_ref["billingAccountId"], # .............................................. p_billing_account_id @@ -191,7 +191,7 @@ async def mark_call_as_active( 0, # ......................................................................... p_price tick["ltp"], # ............................................................... p_refPrice 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( procedure_name = proc_name, @@ -235,9 +235,9 @@ async def call_is_active( # Check if the call is active: if ACTIVE_CALLS.get(redis_key): return True - # if await redis_cache.get(redis_key): - # ACTIVE_CALLS[redis_key] = tick_ref - # return True + if await redis_cache.get(redis_key): + ACTIVE_CALLS[redis_key] = tick_ref + return True return False @@ -525,7 +525,7 @@ async def init( # Caching connections: redis_cache = AsyncRedisCache( - connection_string = script_cred["redisCache"]["general"]["connectionString"], + connection_string = script_cred["redisCache"]["strategies"]["connectionString"], debug = False, debug_prefix = "Cache | " ) @@ -595,8 +595,9 @@ async def refresh_strategy_reference() -> bool: no_context_printer("Refreshing strategy ref.") # Query the database: - proc_name = "strategy_results" - proc_args = (0, 184, 0) + proc_name = "strategy_results_all" + # proc_args = (0, 184, 0) + proc_args = () db_json, db_exception = await sql_reader.call_procedure_and_get_json( procedure_name = proc_name, 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["strike"])) tick_key = "_".join(key_items) + strategy_id = i["strategy_id"] strategy_name = i["name"] strategy_entry = i["entry"].upper().strip() formatted_reference.append({ @@ -637,7 +639,7 @@ async def refresh_strategy_reference() -> bool: "eqQty": i["eq_qty"], "foQty": i["fno_qty"], "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. "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. @@ -650,7 +652,8 @@ async def refresh_strategy_reference() -> bool: "expiry": i["expiry_date"], "strike": i["strike"], "right": i["right"], - "symbol": i["symbol"] + "symbol": i["symbol"], + "exchangeCode": i["exchange_code"], }) # Save the new reference in the global variable: diff --git a/models/message/chat/send.py b/models/message/chat/send.py index 3c518be..fbebff7 100644 --- a/models/message/chat/send.py +++ b/models/message/chat/send.py @@ -92,10 +92,11 @@ class NimbusWhatsAppMessage(BaseModel): frozen = True ) - message: str = Field( + message: str | None = Field( description = "The actual text that you want to send.", - min_length = 1, - frozen = True + # min_length = 1, + frozen = True, + default = None ) pdfUrl: str | None = Field(