About
What it does
A stock's chart and its forecast, shipped as a Granite agent package. A call names a company or a ticker and how many sessions ahead; the package finds the stock, fetches its daily history from Yahoo Finance, fits the IMBHS indicator ensemble the Stoic app was built on, walks it forward one session at a time, and writes a craft-timeseries/1 payload: the closes, and the forecast with its band. A host that recognizes the payload draws it as an interactive chart.
It is one of the Rao Craft Agents. The machinery is a library of its own, StoicCore (Foundation only, no Granite), with a stoic command beside it, so it can be lifted into anything else.
How an app finds it
StoicAgent is a GraniteAgentPackage, and it carries a record in its binary:
@used @section("__DATA_CONST,__granite")
let stoicRecord: GraniteRoster.Record = { GraniteRoster.record(StoicAgent.self) }In Craft, install it from the Agent Store or with craft agents add https://github.com/Rao-Craft-Agents/StoicAgent.git, then say $stoic in a request, and #canvas to watch the chart:
predict the next two weeks for microsoft with $stoic #canvasThe model writes {"query": "microsoft", "days": 10}; the call shows on Craft's agent map as stoic-1, writes stoic/MSFT.timeseries.json, and Canvas draws it: a year of closes, the forecast dashed after the last close, its band shaded, a readout under the pointer.
What a call takes and answers
| Field | ||
|---|---|---|
query | optional | the company or ticker as the person said it: microsoft, MSFT, alphabet |
symbol | optional | an exact ticker; skips the search |
days | optional | trading sessions to forecast: 10 is two weeks, at most 60; left out, the history alone |
through | optional | the last day to forecast, YYYY-MM-DD, instead of days |
context | optional | close (left out), low or high: the price forecast |
indicators | optional | two of smawa, emawa, macd, macdsignal, stochd, stochk, volchange; left out, the search pairs them |
window | optional | recent (left out), or tonal to also train on the past window that moved most like the present |
history | optional | how much past the chart shows: 6mo, 1y (left out), 2y, 5y, all |
output | optional | where the payload goes; stoic/<SYMBOL>.timeseries.json when left out |
directory | the host's | the folder the host works in; a host fills it and does not show it to a model |
The answer is a StoicResult: the payload (path, paths, absolute), the stock, the last session and its close, and the forecast in a few numbers (the last day, its value, its band, the change, how closely the models agree), with the nearest model's indicators and a sentence for each choice the call made. Never the series: the host charts the file.
A name it cannot find, a name several stocks answer, an unknown ticker, a history too short to model, three indicators or a hundred days is refused with the fix, and nothing is written.
The model
IMBHS is the user's "Improved Music Based Harmony Search": every model reads two chosen indicators (SMA- or EMA-weighted average, MACD, MACD signal, volume change, stochastic %K or %D), each over a look-back drawn at random from 4 to 28 sessions (the pitch adjustment), and four defaults (volatility, momentum, change, volume weighted average) over its sample count. It is an ε-SVR (a LIBSVM port: polynomial kernel of degree 3, gamma 0.3, cost 1,000) trained on 4 to 16 sessions to predict the next session's value.
| Step | What |
|---|---|
| Find | Yahoo's search, a ticker matching the query first; the bundled NASDAQ, NYSE and AMEX lists when Yahoo is out of reach |
| Fetch | v8/finance/chart/<symbol>, 2,400 days of daily sessions; a null or non-positive close drops its session |
| Search | nine iterations, each drawing a sample count, times the call's pair or all fifteen pairs of five indicators, each drawing two look-backs: 135 models |
| Judge | each model is fitted with the newest session held out and judged by how near it came to it; the nine nearest are kept and fitted again with it in |
| Walk | each kept model predicts the next session from the indicators at the last, the prediction becomes that session's bar, and the walk goes on; a step further than three daily deviations is held there |
| Band | each session's forecast is the nine models' median, its band their 10th to 90th percentile |
What changed from the app, and why:
- A row learns the session after the one it reads. The app labelled each training row with the same session its indicators had just read, so its "next day" prediction re-estimated a close the model could already see. The backend's framing (features through t − 1, label t) is the one lifted.
- Bars are read newest first everywhere. The app's indicators had moved to oldest first in some functions and not others, which inverted momentum and change.
- The exchange's calendar. Forecast days skip the New York Stock Exchange's holidays (Good Friday and Juneteenth among them), not the app's list (which closed the market on Halloween).
- A name finds a company whatever its ticker's letter. The bundled lists were filed by the ticker's first letter only, so "Alphabet" never found GOOGL.
- Seeded. The same call on the same day makes the same forecast.
Judging nine models on one held-out session is noisy, and a polynomial kernel extrapolates fast: the band and the "confidence" (how closely the models agree) describe the ensemble, not how right it is. It is a model's estimate from past prices, not financial advice.
The payload
`Schema/TimeSeries.md` is the standard, `Schema/timeseries.schema.json` its JSON Schema, and `Schema/examples/MSFT.timeseries.json` a real one. A host recognizes a payload by its name (.timeseries.json) and its schema; a chart is a forecast when a line's role is forecast or a point falls after asOf.
The command
stoic search alphabet
stoic chart MSFT --history 2y
stoic predict microsoft --days 10 --out charts/STOIC_QUOTES_DIR=<folder> reads recorded answers (<SYMBOL>.chart.json, <query>.search.json) instead of Yahoo, for tests and for a Mac without a network; the agent reads it too.
Testing
swift test # the calendar, Yahoo's answers, search, indicators, the model, the payload, the agent
STOIC_BUILD=1 swift test --filter StoicBuildTests # installed as Craft installs it, called over the wireEvery test reads answers recorded from Yahoo on 2026-11-03 (Tests/Fixtures/quotes), never the live service.
MIT licensed. The SVM is Kevin Coble's AIToolbox port of LIBSVM (Copyright (c) 2000-2014 Chih-Chung Chang and Chih-Jen Lin); the NASDAQ, NYSE and AMEX listings are the exchanges' public lists as of June 2023.
Distribution
The package
- Repository
- github.com/Rao-Craft-Agents/StoicAgent · verified on GitHub
- Product
- StoicAgent in StoicAgent
- Pinned to
- f618df8
- Granite
- deb1914
Creator
@rao · rao.nyc · 0 followers · More by @rao
Ambient, Craft and Veil. New York.
Stoic
1 Cr/call