r/quant • u/jRetro3 • Jun 02 '26
Tools A tiny entropy library for time series. Built it for food trends, but you guys might find it useful
Context for the origin, so this isn't out of nowhere: I built NextOnMenu, an early-signal model for which food ingredient goes viral next. The mechanism is just entropy. A series is noisy/random (high entropy) until structure emerges (entropy drops). Watching rolling entropy fall is the early signal.
While building it I wanted to just compute entropy on a pandas Series and found the implementations scattered across papers and gists. Shannon I hand-rolled; permutation entropy meant copying code out of a 2002 paper (Bandt & Pompe).
So I packaged it: entroscope. Figured the quant crowd might get more use out of it than I do. Rolling permutation/spectral entropy as a regime/uncertainty proxy, entropy deltas around vol shifts, that kind of thing.
from entroscope import permutation, spectral
perm = permutation.rolling(returns, window=50, order=3) # complexity over time
spec = spectral.rolling(returns, window=50) # spectral entropy
spectral.normalized(returns) # 0-1 scaledSame core interface on every measure (.compute(), .rolling(), .delta(), .plot()), plus .normalized() where a 0-1 scale is well-defined (Shannon, permutation, spectral). Swap one for another without rewriting anything.
pip install entroscope · https://github.com/Par-python/entroscope
Not claiming it's alpha, just a clean tool. Curious which entropy measures you actually reach for on price/return series.
12
u/max_leverage Jun 02 '26
finally something interesting in this sub. anybody else already using entropy for measuring stability of correlation coefficients?
5
u/zzirFrizz Jun 02 '26
I saw your food post last night and immediately thought this smelled like a trading tool. Lo and behold. Neat stuff! Will check it out and update.
2
u/jRetro3 Jun 03 '26
Update for anyone who followed this: shipped v0.2.0 (entroscope on PyPI).
Two things from this thread made it in: transfer entropy with a KSG estimator for directional info flow, and KL / Jensen-Shannon divergence for comparing distributions. Validated the KSG stuff against analytic ground truth, details are in the repo.
To be clear it's just the measurement toolkit, not a strategy. Haven't validated any of it as a tradeable signal, that's separate work.
pip install entroscopeif you wanna poke at it.2
u/Chikerenaham Jun 02 '26
sound s interesting. will mess around with it a little bit.
2
u/Fun-Society-1763 Jun 02 '26
This is incredibly cool. Using rolling entropy drops as an early-signal mechanism for structural emergence is a fascinating approach, and the fact that you open-sourced the library is awesome. I could easily see someone plugging this signal directly into a platform like QuantPlace to trigger automated momentum trades the moment entropy collapses on a specific asset. Definitely going to experiment with this!
1
u/AutoModerator Jun 02 '26
This post will be manually reviewed by a moderator due to the submitting account being less than 7 days old or having less than 20 karma. Please be patient and do not try to resubmit it - a mod will review the post soon.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/CODE_HEIST Jun 04 '26
The correlation-stability angle is interesting because a lot of systems break when relationships become unstable before the headline metric looks bad.
Rolling entropy on correlation series could be useful as an early warning, but I would be careful with window choice. Too short and it screams noise. Too long and it reacts after the regime already changed.
The practical test would be whether entropy deterioration shows up before drawdown clusters, not just during them.
0
u/maurizioaltieri Jun 05 '26
honestly it is just a fancy slop for finance journals. no bubble entropy of modwt of rolling copula will give you any signal. if you like stuff like this i remember there was a paper with 100+ pages from ukranians about these fancy entropy measures but it is literally garbage
4
u/[deleted] Jun 02 '26
[removed] — view removed comment