LLM-oriented narration and compression for time series data
Project description
narrata
narrata turns OHLCV price series into compact, deterministic text summaries optimized for LLM context.
Installation
pip install narrata
Install optional backends:
pip install "narrata[all]"
Requires Python 3.11+ and pandas 2.0+.
Quickstart
narrate(...) takes a pandas OHLCV DataFrame with a datetime index.
import yfinance as yf
from narrata import narrate
df = yf.download("AAPL", period="1y", multi_level_index=False)
print(narrate(df, ticker="AAPL"))
Example output:
AAPL (251 pts, daily): ▅▄▃▁▂▁▁▂▂▂▄▄▆▇▇██▆▆▆
Date range: 2025-02-14 to 2026-02-13
Range: [$171.67, $285.92] Mean: $235.06 Std: $28.36
Start: $243.54 End: $255.78 Change: +5.03%
Regime: Uptrend since 2025-05-07 (low volatility)
RSI(14): 39.6 (neutral-bearish) MACD: bearish crossover 0 days ago
BB: lower half
SMA 50/200: golden cross
Volume: 0.94x 20-day avg (average)
Volatility: 84th percentile (high)
SAX(16): ecabbabbdegghhhg
Patterns: none detected
Candlestick: Inside Bar on 2026-02-10
Support: $201.77 (26 touches), $208.38 (23 touches) Resistance: $270.88 (24 touches), $257.57 (22 touches)
Fallback vs extras (same input)
Using the same static real-market MSFT dataset (251 daily points, yfinance fixture):
Fallback-only (pip install narrata):
MSFT (251 pts, daily): ▂▁▁▁▃▄▅▇▇█▇███▇▆▅▆▆▂
Date range: 2025-02-14 to 2026-02-13
Range: [$354.56, $542.07] Mean: $466.98 Std: $49.62
Start: $408.43 End: $401.32 Change: -1.74%
Regime: Downtrend since 2026-01-29 (high volatility)
RSI(14): 32.4 (neutral-bearish) MACD: bearish crossover 11 days ago
BB: lower half
SMA 50/200: death cross 17 days ago
Volume: 0.74x 20-day avg (below average)
Volatility: 94th percentile (extremely high)
SAX(16): aaabdfggggggffdb
Patterns: none detected
Candlestick: Inside Bar on 2026-02-13
Support: $393.67 (15 touches), $378.77 (8 touches) Resistance: $510.83 (34 touches), $481.63 (21 touches)
With extras (pip install "narrata[all]"):
MSFT (251 pts, daily): ▂▁▁▁▃▄▅▇▇█▇███▇▆▅▆▆▂
Date range: 2025-02-14 to 2026-02-13
Range: [$354.56, $542.07] Mean: $466.98 Std: $49.62
Start: $408.43 End: $401.32 Change: -1.74%
Regime: Ranging since 2025-02-18 (low volatility)
RSI(14): 32.4 (neutral-bearish) MACD: bearish crossover 11 days ago
BB: lower half
SMA 50/200: death cross 17 days ago
Volume: 0.74x 20-day avg (below average)
Volatility: 94th percentile (extremely high)
SAX(16): aaabdefggggggfed
Patterns: none detected
Candlestick: Inside Bar on 2026-02-13
Support: $393.67 (15 touches), $378.77 (8 touches) Resistance: $510.83 (34 touches), $481.63 (21 touches)
Digit Splitting for LLM Robustness
digit_tokenize(...) can help when your downstream model is sensitive to dense numeric strings.
Use it when you have many prices, percentages, or long decimals in prompt context.
from narrata import digit_tokenize
print(digit_tokenize("Price 171.24, move +3.2%"))
# <digits-split>
# Price 1 7 1 . 2 4 , move + 3 . 2 %
Features
- Input validation for OHLCV DataFrames
- Summary analysis with date range context
- Regime classification (
Uptrend/Downtrend/Ranging) - RSI and MACD interpretation
- Bollinger Band and moving average crossover descriptions
- Volatility and volume context
- SAX symbolic encoding
- ASTRIDE adaptive symbolic encoding (with
ruptures) - Pattern and candlestick detection
- Support/resistance extraction
- Sparkline generation
- Output formatting (
plain,markdown_kv,toon)
FAQ
Is narrata redundant if I already use OpenBB, yfinance, or another data SDK?
No. narrata is complementary. It sits on top of your data access layer and converts OHLCV data into concise, LLM-ready narrative text.
Does narrata call an LLM or provide LLM endpoints?
No. narrata is a pure Python library with deterministic, programmatic analysis and narration. It does not call LLM APIs.
Citation
If you use narrata in research or public projects, cite this package using CITATION.cff.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file narrata-0.1.2.tar.gz.
File metadata
- Download URL: narrata-0.1.2.tar.gz
- Upload date:
- Size: 46.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89bb3f858846a965522e2262792e69ca35e2079d614be54972746c7f7cddc6b8
|
|
| MD5 |
1933a1d6b0606d992220913e7d84df65
|
|
| BLAKE2b-256 |
a46b3f8a7b5f343b61d629dfad891f91c717161dc24e196bbae4d900d4435443
|
Provenance
The following attestation bundles were made for narrata-0.1.2.tar.gz:
Publisher:
release.yml on marcinmiklitz/narrata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
narrata-0.1.2.tar.gz -
Subject digest:
89bb3f858846a965522e2262792e69ca35e2079d614be54972746c7f7cddc6b8 - Sigstore transparency entry: 953576471
- Sigstore integration time:
-
Permalink:
marcinmiklitz/narrata@f9357d509449c2503e68456feec5e0487c0d403d -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/marcinmiklitz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9357d509449c2503e68456feec5e0487c0d403d -
Trigger Event:
push
-
Statement type:
File details
Details for the file narrata-0.1.2-py3-none-any.whl.
File metadata
- Download URL: narrata-0.1.2-py3-none-any.whl
- Upload date:
- Size: 30.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4cfd20379bb9f8e33982a3d95029291302b80592ba060df3b2157ea62da2d96
|
|
| MD5 |
ed03403eeb31396baab94f8de0b1fe75
|
|
| BLAKE2b-256 |
05616ca621d822ca2380abe3cae014ffcf6fb9c33881a78e18052668ceec63b9
|
Provenance
The following attestation bundles were made for narrata-0.1.2-py3-none-any.whl:
Publisher:
release.yml on marcinmiklitz/narrata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
narrata-0.1.2-py3-none-any.whl -
Subject digest:
c4cfd20379bb9f8e33982a3d95029291302b80592ba060df3b2157ea62da2d96 - Sigstore transparency entry: 953576472
- Sigstore integration time:
-
Permalink:
marcinmiklitz/narrata@f9357d509449c2503e68456feec5e0487c0d403d -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/marcinmiklitz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f9357d509449c2503e68456feec5e0487c0d403d -
Trigger Event:
push
-
Statement type: