feat: Add detailed debug logging for watchlist item creation and insertion
This commit is contained in:
parent
bcd1b2badb
commit
0eb83197cb
@ -231,6 +231,16 @@ def trading_system_page():
|
||||
|
||||
if st.button("Add to Watch List", key="add_to_watchlist"):
|
||||
try:
|
||||
# Debug print before creating item
|
||||
print("\n=== PRE-WATCHLIST ITEM CREATION ===")
|
||||
print(f"Ticker: {ticker}")
|
||||
print(f"Entry Price: {entry_price}")
|
||||
print(f"Target Price: {target_price}")
|
||||
print(f"Stop Loss: {position['stop_loss']}")
|
||||
print(f"Notes: {notes}")
|
||||
print(f"Selected Watchlist ID: {selected_list[0]}")
|
||||
print("=====================================\n")
|
||||
|
||||
logger.info(f"Attempting to add {ticker} to watchlist {selected_list[0]}")
|
||||
logger.info(f"Entry: {entry_price}, Target: {target_price}, Stop: {position['stop_loss']}")
|
||||
|
||||
|
||||
@ -37,6 +37,18 @@ def get_watchlists() -> List[dict]:
|
||||
def add_to_watchlist(watchlist_id: int, item: WatchlistItem) -> bool:
|
||||
with create_client() as client:
|
||||
try:
|
||||
# Debug print at start of function
|
||||
print("\n=== WATCHLIST INSERT ATTEMPT ===")
|
||||
print("Input parameters:")
|
||||
print(f"Watchlist ID: {watchlist_id}")
|
||||
print(f"Item details:")
|
||||
print(f" Ticker: {item.ticker}")
|
||||
print(f" Entry Price: {item.entry_price}")
|
||||
print(f" Target Price: {item.target_price}")
|
||||
print(f" Stop Loss: {item.stop_loss}")
|
||||
print(f" Notes: {item.notes}")
|
||||
print("=============================\n")
|
||||
|
||||
# Log the initial state
|
||||
logger.info("=== Starting add_to_watchlist operation ===")
|
||||
|
||||
@ -92,6 +104,14 @@ def add_to_watchlist(watchlist_id: int, item: WatchlistItem) -> bool:
|
||||
logger.info(f"Column Types: {column_types}")
|
||||
logger.info(f"Data to insert: {data}")
|
||||
|
||||
# Add debug print before actual insert
|
||||
print("\n=== DATABASE INSERT ATTEMPT ===")
|
||||
print(f"Table: stock_db.watchlist_items")
|
||||
print(f"Data to insert: {data}")
|
||||
print(f"Column names: {column_names}")
|
||||
print(f"Column types: {column_types}")
|
||||
print("============================\n")
|
||||
|
||||
# Perform insert
|
||||
try:
|
||||
client.insert(
|
||||
@ -100,8 +120,10 @@ def add_to_watchlist(watchlist_id: int, item: WatchlistItem) -> bool:
|
||||
column_names=column_names,
|
||||
column_types=column_types
|
||||
)
|
||||
logger.info("Insert operation completed")
|
||||
print("Insert operation completed successfully")
|
||||
except Exception as insert_error:
|
||||
print(f"\nINSERT ERROR: {insert_error}")
|
||||
print(f"Error type: {type(insert_error)}")
|
||||
logger.error(f"Insert operation failed: {insert_error}")
|
||||
raise
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user