stock-analysis-plugin 0.2.2 → 0.2.3

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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -11
  3. package/package.json +5 -5
  4. package/pi/index.ts +86 -8
  5. package/scripts/ci-resolve-llm-host.mjs +29 -0
  6. package/scripts/setup-python.mjs +7 -9
  7. package/skills/hot-theme/SKILL.md +3 -2
  8. package/skills/stock-screener/SKILL.md +1 -1
  9. package/skills/strategy-backtest/SKILL.md +9 -5
  10. package/strategies/examples/bottom_volume.yaml +5 -0
  11. package/strategies/examples/box_oscillation.yaml +5 -0
  12. package/strategies/examples/bull_trend.yaml +11 -3
  13. package/strategies/examples/dragon_head.yaml +4 -2
  14. package/strategies/examples/emotion_cycle.yaml +5 -0
  15. package/strategies/examples/ma_crossover.yaml +10 -3
  16. package/strategies/examples/rsi_oversold.yaml +5 -0
  17. package/strategies/examples/shrink_pullback.yaml +7 -1
  18. package/strategies/examples/volume_breakout.yaml +7 -1
  19. package/tools/_subproc.py +49 -0
  20. package/tools/alert_rules.py +19 -9
  21. package/tools/anomaly_detect.py +24 -35
  22. package/tools/backtest.py +180 -100
  23. package/tools/capabilities.py +4 -5
  24. package/tools/diagnostics.py +6 -6
  25. package/tools/gather.py +13 -9
  26. package/tools/import_parser.py +2 -5
  27. package/tools/market_regime.py +27 -35
  28. package/tools/market_review.py +56 -9
  29. package/tools/name_resolver.py +2 -5
  30. package/tools/pattern.py +2 -5
  31. package/tools/position_context.py +2 -5
  32. package/tools/report_renderer.py +10 -6
  33. package/tools/requirements.txt +2 -1
  34. package/tools/risk_screening.py +29 -23
  35. package/tools/screener.py +26 -16
  36. package/tools/search_intel.py +5 -13
  37. package/tools/signal_tracker.py +2 -6
  38. package/tools/stock_data.py +301 -92
  39. package/tools/technical.py +136 -40
  40. package/tools/trading_calendar.py +78 -18
  41. package/tools/volume_analysis.py +2 -5
  42. package/tools/watchlist.py +2 -5
  43. package/tools/watchlist_context.py +2 -5
@@ -4,22 +4,20 @@
4
4
  import argparse
5
5
  import json
6
6
  import os
7
- import subprocess
8
7
  import sys
9
8
 
10
9
  import numpy as np
11
10
  import pandas as pd
12
11
 
12
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
13
+
14
+ from _subproc import run_tool, utf8_stdio
15
+
13
16
 
14
17
  def fetch_kline(symbol: str, period: str = "daily", count: int = 120) -> list:
15
- script = os.path.join(os.path.dirname(os.path.abspath(__file__)), "stock_data.py")
16
- r = subprocess.run(
17
- [sys.executable, script, "kline", symbol, "--period", period, "--count", str(count)],
18
- capture_output=True,
19
- text=True,
20
- encoding="utf-8",
21
- )
22
- return json.loads(r.stdout)
18
+ # 30s default matches the sibling kline callers (market_regime, signal_tracker);
19
+ # failure returns None, which callers surface as a clean {"error": ...} result.
20
+ return run_tool("stock_data.py", ["kline", symbol, "--period", period, "--count", str(count)])
23
21
 
24
22
 
25
23
  def to_dataframe(records: list) -> pd.DataFrame:
@@ -34,12 +32,59 @@ def to_dataframe(records: list) -> pd.DataFrame:
34
32
 
35
33
 
36
34
  # --------------- Indicators ---------------
35
+ #
36
+ # The *_series functions are the single authoritative implementations of
37
+ # MA/EMA/MACD/RSI/BOLL/KDJ; anomaly_detect.py, backtest.py and market_regime.py
38
+ # import them instead of keeping local copies. The calc_* wrappers below reduce
39
+ # a series to the latest-value dict shape the analyze CLI emits.
40
+
41
+
42
+ def ma_series(close: pd.Series, period: int) -> pd.Series:
43
+ return close.rolling(period).mean()
44
+
45
+
46
+ def ema_series(close: pd.Series, period: int) -> pd.Series:
47
+ return close.ewm(span=period, adjust=False).mean()
48
+
49
+
50
+ def macd_series(close: pd.Series) -> tuple:
51
+ """Full (dif, dea, macd) series: dif = EMA12-EMA26, dea = EMA9(dif), macd = 2*(dif-dea)."""
52
+ dif = ema_series(close, 12) - ema_series(close, 26)
53
+ dea = ema_series(dif, 9)
54
+ return dif, dea, 2 * (dif - dea)
55
+
56
+
57
+ def rsi_series(close: pd.Series, period: int) -> pd.Series:
58
+ """Full RSI series (SMA of gains/losses over `period`). NaN where there were no losses."""
59
+ delta = close.diff()
60
+ gain = delta.where(delta > 0, 0.0).rolling(period).mean()
61
+ loss = (-delta.where(delta < 0, 0.0)).rolling(period).mean()
62
+ rs = gain / loss.replace(0, np.nan)
63
+ return 100 - 100 / (1 + rs)
64
+
65
+
66
+ def bollinger_series(close: pd.Series, period: int = 20) -> tuple:
67
+ """Full (upper, mid, lower) Bollinger series; pandas sample std (ddof=1)."""
68
+ mid = ma_series(close, period)
69
+ std = close.rolling(period).std()
70
+ return mid + 2 * std, mid, mid - 2 * std
71
+
72
+
73
+ def kdj_series(high: pd.Series, low: pd.Series, close: pd.Series) -> tuple:
74
+ """Full (k, d, j) KDJ series; RSV gaps (flat 9-bar windows) are filled with 50."""
75
+ low_n = low.rolling(9).min()
76
+ high_n = high.rolling(9).max()
77
+ rsv = (close - low_n) / (high_n - low_n).replace(0, np.nan) * 100
78
+ rsv = rsv.fillna(50)
79
+ k = rsv.ewm(com=2, adjust=False).mean()
80
+ d = k.ewm(com=2, adjust=False).mean()
81
+ return k, d, 3 * k - 2 * d
37
82
 
38
83
 
39
84
  def calc_ma(close: pd.Series) -> dict:
40
85
  mas = {}
41
86
  for n in [5, 10, 20, 60]:
42
- ma = close.rolling(n).mean()
87
+ ma = ma_series(close, n)
43
88
  mas[f"ma{n}"] = round(float(ma.iloc[-1]), 2) if len(ma.dropna()) > 0 else None
44
89
  vals = [mas.get(f"ma{n}") for n in [5, 10, 20, 60]]
45
90
  valid = [v for v in vals if v is not None]
@@ -56,11 +101,7 @@ def calc_ma(close: pd.Series) -> dict:
56
101
 
57
102
 
58
103
  def calc_macd(close: pd.Series) -> dict:
59
- ema12 = close.ewm(span=12, adjust=False).mean()
60
- ema26 = close.ewm(span=26, adjust=False).mean()
61
- dif = ema12 - ema26
62
- dea = dif.ewm(span=9, adjust=False).mean()
63
- macd = 2 * (dif - dea)
104
+ dif, dea, macd = macd_series(close)
64
105
  d, de, m = float(dif.iloc[-1]), float(dea.iloc[-1]), float(macd.iloc[-1])
65
106
  signal = "bullish" if d > de else "bearish"
66
107
  prev_cross = (
@@ -79,11 +120,7 @@ def calc_macd(close: pd.Series) -> dict:
79
120
  def calc_rsi(close: pd.Series) -> dict:
80
121
  result = {}
81
122
  for n in [6, 12, 24]:
82
- delta = close.diff()
83
- gain = delta.where(delta > 0, 0.0).rolling(n).mean()
84
- loss = (-delta.where(delta < 0, 0.0)).rolling(n).mean()
85
- rs = gain / loss.replace(0, np.nan)
86
- rsi = 100 - 100 / (1 + rs)
123
+ rsi = rsi_series(close, n)
87
124
  val = float(rsi.iloc[-1]) if not np.isnan(rsi.iloc[-1]) else None
88
125
  result[f"rsi{n}"] = round(val, 2) if val is not None else None
89
126
 
@@ -105,10 +142,7 @@ def calc_rsi(close: pd.Series) -> dict:
105
142
 
106
143
 
107
144
  def calc_bollinger(close: pd.Series) -> dict:
108
- mid = close.rolling(20).mean()
109
- std = close.rolling(20).std()
110
- upper = mid + 2 * std
111
- lower = mid - 2 * std
145
+ upper, mid, lower = bollinger_series(close)
112
146
  u, m, l_ = float(upper.iloc[-1]), float(mid.iloc[-1]), float(lower.iloc[-1])
113
147
  price = float(close.iloc[-1])
114
148
  bw = (u - l_) / m * 100 if m != 0 else 0
@@ -131,13 +165,7 @@ def calc_bollinger(close: pd.Series) -> dict:
131
165
 
132
166
 
133
167
  def calc_kdj(high: pd.Series, low: pd.Series, close: pd.Series) -> dict:
134
- low_n = low.rolling(9).min()
135
- high_n = high.rolling(9).max()
136
- rsv = (close - low_n) / (high_n - low_n).replace(0, np.nan) * 100
137
- rsv = rsv.fillna(50)
138
- k = rsv.ewm(com=2, adjust=False).mean()
139
- d = k.ewm(com=2, adjust=False).mean()
140
- j = 3 * k - 2 * d
168
+ k, d, j = kdj_series(high, low, close)
141
169
  kv, dv, jv = float(k.iloc[-1]), float(d.iloc[-1]), float(j.iloc[-1])
142
170
  if jv > 80:
143
171
  signal = "overbought"
@@ -497,7 +525,7 @@ def calculate_ma_standalone(
497
525
  if len(close) < n:
498
526
  mas[f"ma{n}"] = None
499
527
  continue
500
- val = float(close.rolling(n).mean().iloc[-1])
528
+ val = float(ma_series(close, n).iloc[-1])
501
529
  mas[f"ma{n}"] = round(val, 2)
502
530
 
503
531
  bias = {}
@@ -526,8 +554,8 @@ def calculate_ma_standalone(
526
554
  continue
527
555
  if len(close) < max(fast, slow) + 1:
528
556
  continue
529
- ma_fast = close.rolling(fast).mean()
530
- ma_slow = close.rolling(slow).mean()
557
+ ma_fast = ma_series(close, fast)
558
+ ma_slow = ma_series(close, slow)
531
559
  if len(ma_fast.dropna()) >= 2 and len(ma_slow.dropna()) >= 2:
532
560
  prev_diff = float(ma_fast.iloc[-2]) - float(ma_slow.iloc[-2])
533
561
  curr_diff = float(ma_fast.iloc[-1]) - float(ma_slow.iloc[-1])
@@ -547,6 +575,69 @@ def calculate_ma_standalone(
547
575
  }
548
576
 
549
577
 
578
+ # --------------- Multi-period resonance ---------------
579
+
580
+
581
+ def parse_periods_arg(raw: str) -> list | dict:
582
+ """Parse the analyze --periods CSV into period names, or an {"error": ...} dict."""
583
+ periods = [p.strip() for p in raw.split(",")]
584
+ if not any(periods):
585
+ return {"error": "Empty --periods (want CSV like daily,weekly)"}
586
+ for p in periods:
587
+ if not p:
588
+ return {"error": f"Empty period in --periods: {raw!r}"}
589
+ if p not in ("daily", "weekly", "monthly"):
590
+ return {"error": f"Unknown period in --periods: {p} (choose from daily, weekly, monthly)"}
591
+ if len(set(periods)) != len(periods):
592
+ dupes = sorted({p for p in periods if periods.count(p) > 1})
593
+ return {"error": f"Duplicate period in --periods: {', '.join(dupes)}"}
594
+ return periods
595
+
596
+
597
+ def _period_summary(result: dict) -> dict:
598
+ """Compact per-period summary picked from a full analyze() result (no new computation)."""
599
+ return {
600
+ "period": result["period"],
601
+ "trend_overall": result["trend"]["overall"],
602
+ "ma_arrangement": result["moving_averages"]["ma_arrangement"],
603
+ "macd_signal": result["macd"]["signal"],
604
+ "rsi_signal": result["rsi"]["signal"],
605
+ "buy_signal": result["buy_signal"],
606
+ "signal_score": result["signal_score"],
607
+ }
608
+
609
+
610
+ def calc_resonance(summaries: list) -> dict:
611
+ """Resonance over per-period trend direction: aligned only when every analyzed period agrees."""
612
+ counts = {"bullish": 0, "bearish": 0, "neutral": 0}
613
+ for s in summaries:
614
+ if s.get("trend_overall") in counts:
615
+ counts[s["trend_overall"]] += 1
616
+ total = sum(counts.values())
617
+ if total and counts["bullish"] == total:
618
+ direction = "aligned_bullish"
619
+ elif total and counts["bearish"] == total:
620
+ direction = "aligned_bearish"
621
+ else:
622
+ direction = "divergent"
623
+ return {"direction": direction, **counts, "total": total}
624
+
625
+
626
+ def analyze_multi(symbol: str, period: str, count: int, periods: list) -> dict:
627
+ """analyze() across several periods: top level stays `period`, with a multi_period block added."""
628
+ result = analyze(symbol, period, count)
629
+ if "error" in result:
630
+ return result
631
+ # periods is dupe-free (parse_periods_arg rejects repeats); only the main
632
+ # period can collide, so reuse it directly instead of a results dict.
633
+ summaries = []
634
+ for p in periods:
635
+ r = result if p == period else analyze(symbol, p, count)
636
+ summaries.append({"period": p, "error": r["error"]} if "error" in r else _period_summary(r))
637
+ result["multi_period"] = {"periods": summaries, "resonance": calc_resonance(summaries)}
638
+ return result
639
+
640
+
550
641
  # --------------- Main ---------------
551
642
 
552
643
 
@@ -611,6 +702,9 @@ def main():
611
702
  p.add_argument("symbol")
612
703
  p.add_argument("--period", default="daily", choices=["daily", "weekly", "monthly"])
613
704
  p.add_argument("--count", type=int, default=120)
705
+ p.add_argument(
706
+ "--periods", default=None, help="Comma-separated periods for multi-period resonance, e.g. daily,weekly"
707
+ )
614
708
 
615
709
  p_ma = sub.add_parser("calculate_ma")
616
710
  p_ma.add_argument("symbol")
@@ -624,7 +718,13 @@ def main():
624
718
  sys.exit(1)
625
719
 
626
720
  if args.command == "analyze":
627
- result = analyze(args.symbol, args.period, args.count)
721
+ periods = parse_periods_arg(args.periods) if args.periods is not None else None
722
+ if isinstance(periods, dict):
723
+ result = periods
724
+ elif periods:
725
+ result = analyze_multi(args.symbol, args.period, args.count, periods)
726
+ else:
727
+ result = analyze(args.symbol, args.period, args.count)
628
728
  elif args.command == "calculate_ma":
629
729
  periods = [int(x.strip()) for x in args.periods.split(",")]
630
730
  result = calculate_ma_standalone(args.symbol, periods, args.period, args.count)
@@ -634,9 +734,5 @@ def main():
634
734
 
635
735
 
636
736
  if __name__ == "__main__":
637
- # Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
638
- # Chinese text these tools emit — force UTF-8 so stdout never crashes there.
639
- for _s in (sys.stdout, sys.stderr):
640
- if hasattr(_s, "reconfigure"):
641
- _s.reconfigure(encoding="utf-8")
737
+ utf8_stdio()
642
738
  main()
@@ -5,6 +5,10 @@ import argparse
5
5
  import json
6
6
  import sys
7
7
  from datetime import datetime, timedelta
8
+ from pathlib import Path
9
+
10
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
11
+ from _subproc import socket_timeout, utf8_stdio
8
12
 
9
13
  # Supported markets. argparse uses type=str.upper so lowercase input is accepted too.
10
14
  MARKETS = ["CN", "HK", "US", "JP", "KR", "TW"]
@@ -32,7 +36,8 @@ def cn_trade_dates(year: int) -> set[str]:
32
36
  try:
33
37
  import akshare as ak
34
38
 
35
- df = ak.tool_trade_date_hist_sina()
39
+ with socket_timeout(25):
40
+ df = ak.tool_trade_date_hist_sina()
36
41
  dates = set()
37
42
  for _, row in df.iterrows():
38
43
  val = row.iloc[0]
@@ -55,6 +60,76 @@ def _is_exchange_trading_day(exchange_code: str, date_str: str) -> bool:
55
60
  return cal.is_session(d)
56
61
 
57
62
 
63
+ # --------------- US holiday rules (fallback when exchange-calendars is unavailable) ---------------
64
+
65
+
66
+ def _easter_sunday(year: int) -> datetime:
67
+ """Easter Sunday via the Anonymous Gregorian algorithm (valid for any year ≥ 1583)."""
68
+ a = year % 19
69
+ b, c = divmod(year, 100)
70
+ d, e = divmod(b, 4)
71
+ f = (b + 8) // 25
72
+ g = (b - f + 1) // 3
73
+ h = (19 * a + b - d - g + 15) % 30
74
+ i, k = divmod(c, 4)
75
+ l = (32 + 2 * e + 2 * i - h - k) % 7 # noqa: E741
76
+ m = (a + 11 * h + 22 * l) // 451
77
+ month, day = divmod(h + l - 7 * m + 114, 31)
78
+ return datetime(year, month, day + 1)
79
+
80
+
81
+ def _nth_weekday(year: int, month: int, weekday: int, n: int) -> datetime:
82
+ """The n-th `weekday` (Mon=0) of the month, e.g. MLK = _nth_weekday(y, 1, 0, 3)."""
83
+ d = datetime(year, month, 1)
84
+ d += timedelta(days=(weekday - d.weekday()) % 7)
85
+ return d + timedelta(weeks=n - 1)
86
+
87
+
88
+ def _last_weekday(year: int, month: int, weekday: int) -> datetime:
89
+ """The last `weekday` of the month, e.g. Memorial Day = _last_weekday(y, 5, 0)."""
90
+ d = datetime(year, month + 1, 1) - timedelta(days=1) if month < 12 else datetime(year, 12, 31)
91
+ return d - timedelta(days=(d.weekday() - weekday) % 7)
92
+
93
+
94
+ def _observed(d: datetime) -> datetime:
95
+ """NYSE observed-date rule: a Saturday holiday is observed the Friday before,
96
+ a Sunday holiday the Monday after."""
97
+ if d.weekday() == 5:
98
+ return d - timedelta(days=1)
99
+ if d.weekday() == 6:
100
+ return d + timedelta(days=1)
101
+ return d
102
+
103
+
104
+ def _us_holidays(year: int) -> set[tuple[int, int]]:
105
+ """US (XNYS) full-day closure dates for `year` as observed (month, day) pairs —
106
+ rule-computed so every year is correct, not just one hardcoded calendar.
107
+
108
+ Fixed-date holidays shift per _observed, except New Year's Day: NYSE stays open
109
+ on Dec 31 when Jan 1 falls on a Saturday (a Sunday New Year is observed Monday).
110
+ Good Friday comes from the Easter algorithm. NYSE closes for Juneteenth from 2022."""
111
+ holidays = set()
112
+
113
+ def add(d: datetime):
114
+ if d.year == year:
115
+ holidays.add((d.month, d.day))
116
+
117
+ new_year = datetime(year, 1, 1)
118
+ if new_year.weekday() != 5: # Saturday New Year: no closure, not even Dec 31 prior
119
+ add(_observed(new_year)) # New Year's Day
120
+ add(_nth_weekday(year, 1, 0, 3)) # Martin Luther King Jr. Day — 3rd Monday of January
121
+ add(_nth_weekday(year, 2, 0, 3)) # Washington's Birthday — 3rd Monday of February
122
+ add(_easter_sunday(year) - timedelta(days=2)) # Good Friday
123
+ add(_last_weekday(year, 5, 0)) # Memorial Day — last Monday of May
124
+ if year >= 2022:
125
+ add(_observed(datetime(year, 6, 19))) # Juneteenth (NYSE closes from 2022)
126
+ add(_observed(datetime(year, 7, 4))) # Independence Day
127
+ add(_nth_weekday(year, 9, 0, 1)) # Labor Day — 1st Monday of September
128
+ add(_nth_weekday(year, 11, 3, 4)) # Thanksgiving — 4th Thursday of November
129
+ add(_observed(datetime(year, 12, 25))) # Christmas Day
130
+ return holidays
131
+
132
+
58
133
  def is_trading_day(market: str, date_str: str = None) -> dict:
59
134
  if date_str:
60
135
  d = datetime.strptime(date_str, "%Y-%m-%d")
@@ -119,18 +194,7 @@ def is_trading_day(market: str, date_str: str = None) -> dict:
119
194
  }
120
195
  except Exception:
121
196
  pass
122
- us_holidays = {
123
- (1, 1),
124
- (1, 20),
125
- (2, 17),
126
- (5, 26),
127
- (6, 19),
128
- (7, 4),
129
- (9, 1),
130
- (11, 27),
131
- (12, 25),
132
- }
133
- if (d.month, d.day) in us_holidays:
197
+ if (d.month, d.day) in _us_holidays(d.year):
134
198
  return {"date": date_str, "market": market, "is_trading_day": False, "reason": "US_holiday"}
135
199
  return {"date": date_str, "market": market, "is_trading_day": True, "reason": "trading_day"}
136
200
 
@@ -319,9 +383,5 @@ def main():
319
383
 
320
384
 
321
385
  if __name__ == "__main__":
322
- # Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
323
- # Chinese text these tools emit — force UTF-8 so stdout never crashes there.
324
- for _s in (sys.stdout, sys.stderr):
325
- if hasattr(_s, "reconfigure"):
326
- _s.reconfigure(encoding="utf-8")
386
+ utf8_stdio()
327
387
  main()
@@ -10,6 +10,7 @@ import numpy as np
10
10
 
11
11
  sys.path.insert(0, str(Path(__file__).resolve().parent))
12
12
 
13
+ from _subproc import utf8_stdio # noqa: E402
13
14
  from technical import fetch_kline, to_dataframe # noqa: E402
14
15
 
15
16
 
@@ -150,9 +151,5 @@ def main():
150
151
 
151
152
 
152
153
  if __name__ == "__main__":
153
- # Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
154
- # Chinese text these tools emit — force UTF-8 so stdout never crashes there.
155
- for _s in (sys.stdout, sys.stderr):
156
- if hasattr(_s, "reconfigure"):
157
- _s.reconfigure(encoding="utf-8")
154
+ utf8_stdio()
158
155
  main()
@@ -8,6 +8,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
8
8
  from pathlib import Path
9
9
 
10
10
  sys.path.insert(0, str(Path(__file__).resolve().parent))
11
+ from _subproc import utf8_stdio
11
12
  from gather import gather_analysis
12
13
 
13
14
 
@@ -58,9 +59,5 @@ def main():
58
59
 
59
60
 
60
61
  if __name__ == "__main__":
61
- # Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
62
- # Chinese text these tools emit — force UTF-8 so stdout never crashes there.
63
- for _s in (sys.stdout, sys.stderr):
64
- if hasattr(_s, "reconfigure"):
65
- _s.reconfigure(encoding="utf-8")
62
+ utf8_stdio()
66
63
  main()
@@ -14,6 +14,7 @@ from pathlib import Path
14
14
 
15
15
  sys.path.insert(0, str(Path(__file__).resolve().parent))
16
16
  from _subproc import run_tool as _run_json # noqa: E402
17
+ from _subproc import utf8_stdio
17
18
  from stock_data import detect_market # noqa: E402
18
19
  from watchlist import analyze_watchlist # noqa: E402
19
20
 
@@ -150,9 +151,5 @@ def main():
150
151
 
151
152
 
152
153
  if __name__ == "__main__":
153
- # Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
154
- # Chinese text these tools emit — force UTF-8 so stdout never crashes there.
155
- for _s in (sys.stdout, sys.stderr):
156
- if hasattr(_s, "reconfigure"):
157
- _s.reconfigure(encoding="utf-8")
154
+ utf8_stdio()
158
155
  main()