Ghid · Python 3.9+
Raport zilnic al riscului de război
Satelit recalculează la 10 minute, din știri, probabilitatea a șase scenarii pentru Moldova pe următoarele 12 luni. În fiecare dimineață scriptul scrie un raport cu fiecare scenariu, linia lui de bază și cât s-a mișcat de ieri, și te anunță doar când contează.
- Rulează pe
- Python 3.9+
- O rulare
- 2 credite
- Pe lună
- 60 de credite
- Pornit în
- 5 min
$ MOVE_PP=2 ABOVE=25 python3 war_brief.pywar-brief-2026-11-20.md: index 19.3%, 1 scenario moved, 2 creditsCum funcționează
- Citește indicele și cele șase scenarii din
/v1/war: probabilitatea acum, linia de bază și dacă e o escaladare militară. - Citește ultimele 30 de zile ale indicelui din
/v1/war/history?scenario=index. - Compară cu raportul de ieri din
war-state.jsonși scriewar-brief-AAAA-LL-ZZ.md. - Trimite o alertă când un scenariu s-a mișcat cu
MOVE_PPpuncte sau mai mult, ori când indicele trece deABOVEprocente.
Cât costă: 1 credit pentru scenarii și 1 pentru istoric: 2 credite pe zi, 60 pe lună. Încape în planul Start.
Cum îl rulezi
export SATELIT_KEY=sat_live_...
MOVE_PP=2 ABOVE=25 python3 war_brief.pyCe scoate
war-brief-2026-11-20.md: index 19.3%, 1 scenario moved, 2 creditsScriptul complet
#!/usr/bin/env python3
"""War risk brief: Moldova's six war scenarios each morning, a Markdown brief and an alert when one moves.
SATELIT_KEY=sat_live_... MOVE_PP=2 ABOVE=25 python3 war_brief.py
Writes war-brief-YYYY-MM-DD.md: the index and every scenario now, its baseline, its move since the last brief and the
index's last 30 days. Alerts (ALERT_URL, a Slack-style incoming webhook; empty prints them) when a scenario moved MOVE_PP
percentage points or more since the last brief, or when the index is above ABOVE percent. BRIEF_LANG: ro, ru, en or uk.
Standard library only. Put it in cron: 0 8 * * * python3 /path/war_brief.py
"""
import json
import os
import sys
import time
import urllib.error
import urllib.parse
import urllib.request
from datetime import date
from pathlib import Path
sys.stdout.reconfigure(encoding="utf-8") # names hold ă, ș, ț whatever the console's code page
BASE = os.environ.get("SATELIT_BASE", "https://api.satelit.md/v1")
KEY = os.environ["SATELIT_KEY"]
LANG = os.environ.get("BRIEF_LANG", "ro")
MOVE_PP = float(os.environ.get("MOVE_PP", "2"))
ABOVE = float(os.environ.get("ABOVE", "25"))
ALERT_URL = os.environ.get("ALERT_URL", "")
STATE = Path(os.environ.get("STATE_FILE", "war-state.json"))
credits_used = 0
def api(path, **params):
global credits_used
query = urllib.parse.urlencode({"lang": LANG, **params})
req = urllib.request.Request(f"{BASE}{path}?{query}", headers={"Authorization": f"Bearer {KEY}"})
for attempt in range(3):
try:
with urllib.request.urlopen(req, timeout=20) as res:
body = json.load(res)
credits_used += body["meta"].get("credits", 0)
return body["data"]
except urllib.error.HTTPError as err:
retry = err.headers.get("Retry-After")
if err.code in (429, 503) and retry and attempt < 2:
time.sleep(int(retry))
continue
raise SystemExit(f"{path}: {err.code} {err.read().decode()}")
def alert(text):
print(text)
if ALERT_URL:
req = urllib.request.Request(ALERT_URL, json.dumps({"text": text}).encode(), {"Content-Type": "application/json"})
urllib.request.urlopen(req, timeout=10).close()
def pct(p):
return f"{p * 100:.1f}%"
def pp(x):
return f"{x:+.1f} pp"
def main():
now = api("/war")
days = api("/war/history", scenario="index", days=30)
rows = [now["index"], *now["scenarios"]]
last = json.loads(STATE.read_text("utf-8")) if STATE.exists() else {}
moved = []
lines = [f"# War risk for Moldova, {date.today().isoformat()}", "",
f"Probability over the next {now['horizon_months']} months. Change: since the last brief.", "",
"| Scenario | Now | Baseline | Change |", "|---|---:|---:|---:|"]
for r in rows:
before = last.get(r["scenario"])
change = (r["probability"] - before) * 100 if before is not None else 0.0
if r["scenario"] != "index" and before is not None and abs(change) >= MOVE_PP:
moved.append(f"{r['name']}: {pct(r['probability'])} ({pp(change)})")
lines.append(f"| {r['name']} | {pct(r['probability'])} | {pct(r['prior'])} | {pp(change) if before is not None else 'new'} |")
points = [d["probability"] for d in days]
if points:
lines += ["", f"Index, last {len(points)} days: from {pct(min(points))} to {pct(max(points))}, now {pct(points[-1])}."]
lines += ["", "Estimates: Satelit (satelit.md). Not an official forecast."]
out = Path(f"war-brief-{date.today().isoformat()}.md")
out.write_text("\n".join(lines) + "\n", "utf-8")
STATE.write_text(json.dumps({r["scenario"]: r["probability"] for r in rows}), "utf-8")
index = now["index"]["probability"] * 100
if moved:
alert("War risk moved: " + "; ".join(moved) + ". Satelit's estimate.")
if index > ABOVE:
alert(f"War risk index at {index:.1f}%, above {ABOVE:g}%. Satelit's estimate.")
print(f"{out}: index {pct(now['index']['probability'])}, {len(moved)} scenarios moved, {credits_used} credits")
if __name__ == "__main__":
main()
Rutele folosite
Întrebări despre acest ghid
De unde vin probabilitățile?
Sunt estimările Satelit din știrile despre război din Moldova și din regiune, recalculate la 10 minute. Nu sunt o prognoză oficială și nu se bazează pe surse secrete.
Pot vedea știrile care au mișcat un scenariu?
Da, /v1/war/signals dă fiecare știre cu punctele cu care a mișcat fiecare scenariu, pe planurile Pro și mai mari. Webhook-urile war.news și war.risk sunt pe orice plan cu webhook-uri.
Pot primi alerta în timp real, nu dimineața?
Da: webhook-ul war.level vine când un scenariu trece de un prag al tău, de exemplu {"scenario": "transnistria", "above": 15}. Scriptul acesta e pentru raportul de zi.