stock-analysis-plugin 0.2.11 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +234 -382
  2. package/docs/mcp.md +60 -0
  3. package/hermes/__init__.py +35 -0
  4. package/hermes/plugin.yaml +132 -0
  5. package/hermes/schemas.py +6 -0
  6. package/hermes/tools.py +647 -0
  7. package/mcp_host/__init__.py +1 -0
  8. package/mcp_host/__main__.py +3 -0
  9. package/mcp_host/server.py +222 -0
  10. package/package.json +7 -1
  11. package/pi/index.ts +52 -2906
  12. package/scripts/cli-json.mjs +23 -0
  13. package/scripts/exec-process.mjs +89 -0
  14. package/scripts/setup-python.mjs +37 -4
  15. package/scripts/tool-calls.mjs +493 -0
  16. package/skills/bull-trend/SKILL.md +2 -2
  17. package/skills/bull-trend/references/fat-tails.md +76 -3
  18. package/skills/bull-trend/scripts/tail_analysis.py +92 -3
  19. package/skills/event-driven/SKILL.md +2 -2
  20. package/skills/growth-quality/SKILL.md +1 -1
  21. package/skills/market-review/SKILL.md +1 -0
  22. package/skills/stock-analysis/SKILL.md +12 -7
  23. package/skills/stock-analysis/references/stateless-analysis.md +9 -1
  24. package/skills/stock-screener/SKILL.md +1 -1
  25. package/skills/strategy-backtest/SKILL.md +1 -1
  26. package/tools/_cache.py +13 -0
  27. package/tools/_subproc.py +46 -0
  28. package/tools/alert_rules.py +2 -2
  29. package/tools/backtest.py +3 -3
  30. package/tools/capabilities.py +33 -9
  31. package/tools/cli_budgets.json +1 -0
  32. package/tools/credit_data.py +293 -0
  33. package/tools/diagnostics.py +3 -4
  34. package/tools/gather.py +2 -6
  35. package/tools/import_parser.py +3 -4
  36. package/tools/lixinger.py +119 -27
  37. package/tools/market_regime.py +5 -2
  38. package/tools/market_review.py +5 -6
  39. package/tools/name_resolver.py +45 -33
  40. package/tools/report_renderer.py +3 -3
  41. package/tools/requirements.txt +5 -4
  42. package/tools/risk_screening.py +3 -2
  43. package/tools/screener.py +41 -30
  44. package/tools/search_intel.py +79 -10
  45. package/tools/sec_edgar.py +268 -1
  46. package/tools/sec_holders.py +6 -0
  47. package/tools/signal_tracker.py +5 -5
  48. package/tools/stateless_analysis.py +132 -19
  49. package/tools/stock_data.py +1020 -817
  50. package/tools/tiaa_disclosures.py +4 -0
  51. package/tools/tool_schemas.json +2734 -0
  52. package/tools/trading_calendar.py +65 -30
  53. package/tools/value_data.py +423 -175
  54. package/tools/watchlist.py +43 -5
@@ -4,14 +4,17 @@
4
4
  import argparse
5
5
  import json
6
6
  import math
7
+ import os
8
+ import re
7
9
  import sys
8
10
  from concurrent.futures import ThreadPoolExecutor, as_completed
9
11
  from contextlib import nullcontext
10
12
  from pathlib import Path
11
13
 
12
14
  sys.path.insert(0, str(Path(__file__).resolve().parent))
13
- from _subproc import utf8_stdio
15
+ from _subproc import error_message, utf8_stdio
14
16
  from gather import Collection, gather_analysis
17
+ from stock_data import _cn_code
15
18
 
16
19
 
17
20
  def has_analysis_data(data) -> bool:
@@ -65,10 +68,40 @@ def analyze_watchlist(symbols: list[str], workers: int = 3, *, session=None, on_
65
68
  }
66
69
 
67
70
 
71
+ def get_watchlist() -> dict:
72
+ configured = os.environ.get("STOCK_WATCHLIST_FILE")
73
+ data_root = Path(os.environ.get("DSH_HOME") or Path.home() / ".dsh")
74
+ path = Path(configured) if configured else data_root / "stock-analysis" / "watchlist.json"
75
+ try:
76
+ payload = json.loads(path.read_text(encoding="utf-8"))
77
+ except FileNotFoundError:
78
+ return {"symbols": [], "count": 0}
79
+
80
+ values = payload.get("symbols") if isinstance(payload, dict) else None
81
+ if not isinstance(values, list):
82
+ raise ValueError("Watchlist file must contain a symbols array")
83
+ symbols, keys = [], set()
84
+ for value in values:
85
+ if not isinstance(value, str):
86
+ raise ValueError("Watchlist symbols must be strings")
87
+ upper = value.strip().upper()
88
+ if not re.fullmatch(r"[A-Z0-9][A-Z0-9.-]{0,31}", upper):
89
+ raise ValueError("Watchlist contains an invalid symbol")
90
+ symbol = upper.lower() if re.fullmatch(r"(?:SH|SZ|BJ)[0-9]{6}", upper) else upper
91
+ # Same key as dsh dashboardQuoteSymbol: 600519 and sh600519 are one stock.
92
+ key = _cn_code(symbol) if re.fullmatch(r"[0-9]{6}", symbol) else symbol
93
+ if key not in keys:
94
+ keys.add(key)
95
+ symbols.append(symbol)
96
+ return {"symbols": symbols, "count": len(symbols)}
97
+
98
+
68
99
  def main():
69
100
  parser = argparse.ArgumentParser(description="Batch watchlist analysis")
70
101
  sub = parser.add_subparsers(dest="command")
71
102
 
103
+ sub.add_parser("list", help="Read the dsh dashboard watchlist")
104
+
72
105
  p_analyze = sub.add_parser("analyze")
73
106
  p_analyze.add_argument("symbols", help="Comma-separated stock codes")
74
107
  p_analyze.add_argument("--workers", type=int, default=3, help="Concurrency level (default 3)")
@@ -81,13 +114,18 @@ def main():
81
114
  print(json.dumps({"error": "No valid symbols provided"}))
82
115
  sys.exit(1)
83
116
  result = analyze_watchlist(codes, workers=args.workers)
84
- json.dump(result, sys.stdout, ensure_ascii=False, indent=2)
85
- print()
86
- if "error" in result:
87
- sys.exit(1)
117
+ elif args.command == "list":
118
+ try:
119
+ result = get_watchlist()
120
+ except (OSError, ValueError) as exc:
121
+ result = {"error": error_message(exc)}
88
122
  else:
89
123
  parser.print_help()
90
124
  sys.exit(1)
125
+ json.dump(result, sys.stdout, ensure_ascii=False, indent=2)
126
+ print()
127
+ if "error" in result:
128
+ sys.exit(1)
91
129
 
92
130
 
93
131
  if __name__ == "__main__":