Initial commit with translated description

This commit is contained in:
2026-03-29 13:19:31 +08:00
commit c38a898a3a
11 changed files with 546 additions and 0 deletions

36
scripts/list_stocks.py Normal file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""
List all stocks in the user's watchlist.
This script reads from the standard watchlist file and displays the current watchlist.
"""
import sys
import os
# Standardized watchlist file path
WATCHLIST_FILE = os.path.expanduser("~/.clawdbot/stock_watcher/watchlist.txt")
def list_stocks():
"""List all stocks in the watchlist."""
if not os.path.exists(WATCHLIST_FILE):
print("Watchlist is empty.")
return
with open(WATCHLIST_FILE, 'r', encoding='utf-8') as f:
lines = [line.strip() for line in f if line.strip()]
if not lines:
print("Watchlist is empty.")
return
print("Your Stock Watchlist:")
print("-" * 40)
for i, line in enumerate(lines, 1):
parts = line.split('|')
if len(parts) == 2:
code, name = parts
print(f"{i}. {code} - {name}")
else:
print(f"{i}. {line}")
if __name__ == "__main__":
list_stocks()