Skip to content

Commit 5d49403

Browse files
committed
added more clarity on the thresholds field
1 parent c53330c commit 5d49403

5 files changed

Lines changed: 70 additions & 40 deletions

File tree

MESSAGING.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ update. The agent extracts four things from your message:
2323
| --- | --- | --- |
2424
| `trackedKeywords` | Macro/news triggers to match headlines against | "alert me on CPI, FOMC, and Powell" |
2525
| `watchlist` | Explicit **stock tickers** you care about | "watch TSLA and NVDA for me" |
26-
| `sentimentThreshold` | Sensitivity, 0–1 (lower = more alerts) | "only the big stuff, threshold 0.8" |
26+
| `severityThreshold` | Minimum **market impact** to alert, 0–1 (lower = more alerts) | "only the big stuff, threshold 0.8" |
2727
| `sourceTrustThreshold` | Minimum publisher trustworthiness, 0–1 (higher = stricter) | "only alert me from reputable sources" |
2828

2929
You can combine them in one message, or send them across several — you don't
@@ -40,10 +40,28 @@ The agent replies with a confirmation echoing your **current** settings, e.g.:
4040
Got it — saved your macro preferences for this chat.
4141
Tracked keywords: CPI, FOMC
4242
Watchlist: TSLA, NVDA
43-
Sentiment threshold: 0.5
43+
Severity threshold: 0.5
44+
Alerts when a matching headline's Severity score is ≥ 0.5 (same "Severity" on each alert; not bullish/bearish Direction). Lower = more alerts.
4445
Source trust: any source
4546
```
4647

48+
### What “threshold” means (severity, not direction)
49+
50+
When you text `threshold 0.5`, you are setting your **severity threshold** — how
51+
**market-moving** a headline must be before you get pinged. After a headline matches your keywords or
52+
watchlist, Grok scores it on three separate 0–1 scales:
53+
54+
| Score on each alert | What it measures | Used to filter alerts? |
55+
| --- | --- | --- |
56+
| **Severity** | How market-moving the headline is (CPI surprise, FOMC shock, etc.) | **Yes** — compared to your **severity threshold** |
57+
| **Direction** | Bearish vs bullish tone | **No** — shown for context only |
58+
| **Source trust** | Publisher credibility (Reuters high, PR wire low) | **Yes** — if you set a source-trust minimum |
59+
60+
So **`threshold 0.5` sets your severity threshold** — “only alert me when severity ≥
61+
0.5.” It does **not** mean “only bearish news” or “only bullish news.” Lower the
62+
number for more alerts; raise it (e.g. `threshold 0.8`) for fewer, bigger
63+
headlines only.
64+
4765
**Updates are incremental.** Each message changes only what it mentions; the
4866
rest of your settings are kept. So this works as a conversation:
4967

@@ -68,7 +86,7 @@ start over:
6886
| **Replace a list** | `only watch TSLA`, `just track CPI and FOMC` | sets that one list to exactly what you named |
6987
| **Clear one list** | `clear my watchlist` | empties that list, keeps the rest |
7088
| **Reset everything** | `reset my settings`, `clear everything` | back to defaults (no keywords/tickers, threshold 0.6, any source) |
71-
| **Set threshold** | `threshold 0.5`, `only big alerts` | changes only the sensitivity |
89+
| **Set impact threshold** | `threshold 0.5`, `only big alerts` | changes how market-moving news must be |
7290
| **Filter by source** | `only reputable sources`, `any source is fine` | sets/clears the minimum source-trust level |
7391

7492
Add/remove are case-insensitive, so `untrack cpi` removes `CPI`. Replacing or
@@ -78,7 +96,7 @@ untouched.
7896
### What triggers a watchlist alert
7997

8098
A watched ticker behaves like an extra keyword: a headline alerts you if it
81-
mentions the ticker **and** the headline's severity is at or above your
99+
mentions the ticker **and** the headline's **market impact** is at or above your
82100
threshold. Tickers and tracked keywords are matched as a combined set, so you
83101
don't need to also list a ticker under keywords.
84102

@@ -99,7 +117,7 @@ each alert is labelled `low` / `medium` / `high`:
99117
Macro alert
100118
Fed raises rates by 25bps, signals higher-for-longer stance
101119
Source: Reuters · trust high (0.95)
102-
Severity: 0.90 | Sentiment: bearish (0.20)
120+
Severity: 0.90 | Direction: bearish (0.20)
103121
...
104122
```
105123

@@ -114,13 +132,13 @@ only want credible publishers, set a minimum:
114132
| `any source is fine` | turns the filter off (back to 0) |
115133

116134
The trust threshold is per chat and incremental like your other settings, and it
117-
stacks with your keyword/watchlist match and sentiment threshold — a headline
135+
stacks with your keyword/watchlist match and impact threshold — a headline
118136
must clear **all** of them to alert.
119137

120138
### Defaults
121139

122140
A brand-new chat starts at `trackedKeywords = []`, `watchlist = []`,
123-
`sentimentThreshold = 0.6`, `sourceTrustThreshold = 0` (any source). An empty
141+
`severityThreshold = 0.6`, `sourceTrustThreshold = 0` (any source). An empty
124142
keyword **and** watchlist set means "match every headline" (subject to the
125143
thresholds).
126144

ONBOARDING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ The agent replies with something like:
119119
Got it — saved your macro preferences for this chat.
120120
Tracked keywords: CPI, FOMC
121121
Watchlist: (none)
122-
Sentiment threshold: 0.5
122+
Severity threshold: 0.5
123+
Alerts when a matching headline's Severity score is ≥ 0.5 (same "Severity" on each alert; not bullish/bearish Direction). Lower = more alerts.
123124
Source trust: any source
124125
```
125126

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ Checklist:
187187

188188
Troubleshooting (preferences):
189189

190-
- If you get `Got it — saved...` but `Tracked keywords: (none)` and `Sentiment threshold: 0.6`, the agent fell back to defaults (most commonly because `XAI_API_KEY` is missing/blank, or the LLM output wasn't parseable).
190+
- If you get `Got it — saved...` but `Tracked keywords: (none)` and `Severity threshold: 0.6`, the agent fell back to defaults (most commonly because `XAI_API_KEY` is missing/blank, or the LLM output wasn't parseable).
191191
- If you get `Sorry — I couldn't update your preferences right now.`, the LLM call failed (network/API/model error). Check the agent console logs for the error.
192192
- If an alert arrives before your “Got it — saved…” reply, restart the agent after `npm run build` — the agent holds alerts while your settings message is being processed so confirmations should arrive first.
193193
- If you get multiple identical replies for a single text, you likely have multiple `npm start` processes running at once. Stop extras (Ctrl+C) so only one agent instance is connected.
@@ -198,8 +198,8 @@ Troubleshooting (preferences):
198198
After saving preferences (above), leave `npm start` running with `cpp_engine` publishing:
199199

200200
1. Watch the agent console for `[ZMQ] headline: ... [source: ...]` when a headline is received.
201-
2. If the headline matches your keywords **or watchlist tickers**, Grok’s **severity** is at or above your **sentiment threshold**, and the **source trust** Grok assigns the publisher is at or above your **source-trust threshold** (default 0 = any source), you should get a proactive iMessage (no new inbound message required). The alert names the source and its trust level, e.g. `Source: Reuters · trust high (0.95)`.
202-
3. Lower threshold → more alerts; higher threshold → fewer. Raise the source-trust threshold (e.g. "only reputable sources") to suppress low-credibility publishers — see [`MESSAGING.md`](MESSAGING.md).
201+
2. If the headline matches your keywords **or watchlist tickers**, Grok’s **severity** score is at or above your **severity threshold** (what you set with `threshold 0.5`, etc.), and the **source trust** Grok assigns the publisher is at or above your **source-trust threshold** (default 0 = any source), you should get a proactive iMessage (no new inbound message required). The alert names the source and its trust level, e.g. `Source: Reuters · trust high (0.95)`.
202+
3. Lower severity threshold → more alerts; higher → fewer. This filters on **how market-moving** the headline is — not bullish/bearish direction (direction is shown on the alert but not filtered). Raise the source-trust threshold (e.g. "only reputable sources") to suppress low-credibility publishers — see [`MESSAGING.md`](MESSAGING.md).
203203

204204
#### Testing the watchlist specifically
205205

TECHNICAL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ When a user sends a text message, `ts_agent` extracts macro trading preferences
136136

137137
- `userPreferences: Map<string, UserPreferences>`
138138
- Key: `space.id` (conversation id)
139-
- Value: `{ trackedKeywords: string[], watchlist: string[], sentimentThreshold: number, sourceTrustThreshold: number }`
139+
- Value: `{ trackedKeywords: string[], watchlist: string[], severityThreshold: number, sourceTrustThreshold: number }`
140140
- `spacesById: Map<string, Space>` — caches the Spectrum `space` handle for proactive outbound sends (populated on each inbound message)
141141
- `lastAlertBySpace: Map<string, AlertContext>` — headline + Grok analysis for conversational follow-ups (~30 minute TTL)
142142

@@ -212,7 +212,7 @@ User preferences (tracked keywords + watchlist tickers) live only in the agent,
212212
1. Parse JSON frame (including the `source` publisher); dedupe by `ts` + headline (or headline alone) for ~2 minutes.
213213
2. Call Grok (`analyzeHeadlineWithLlm`, passing the headline + source) → `{ sentiment, severity, summary, sourceTrust }`. `sourceTrust` (0–1) is Grok's credibility rating of the publisher; an absent/garbled rating defaults to ~0.3 (low).
214214
3. For each `userPreferences` entry, enqueue `spaceOutbound.run(spaceId, "alert", …)` (waits if that space has an active alert hold).
215-
4. Inside the alert task, re-check keywords, `severity >= sentimentThreshold`, **and** `sourceTrust >= sourceTrustThreshold` against current preferences, then `app.send(space, alertText)` and store `lastAlertBySpace`. The alert text and stored context include the source name and its `low`/`medium`/`high` trust label.
215+
4. Inside the alert task, re-check keywords, `severity >= severityThreshold`, **and** `sourceTrust >= sourceTrustThreshold` against current preferences, then `app.send(space, alertText)` and store `lastAlertBySpace`. The alert text and stored context include the source name and its `low`/`medium`/`high` trust label. (`severityThreshold` is the user-facing “threshold”; it gates on market impact, not bullish/bearish sentiment.)
216216

217217
If no user has messaged since startup, preferences are empty and headlines are logged but not alerted. If preferences exist but `spacesById` lacks that `space.id`, the agent logs that the user must message first (Spectrum needs a cached conversation handle for outbound iMessage).
218218

0 commit comments

Comments
 (0)