A Telegram bot that ranks configurable stock universes by three scientifically grounded momentum metrics and delivers clear buy and sell signals on your schedule. You decide what to do with them.
FinanzUnity Momentum is a self-hosted Telegram bot that applies a scientifically grounded strategy automatically. Instead of analysing hundreds of stocks by hand every week, the bot does the work: it fetches current prices, computes three momentum metrics, builds a ranking, and sends you concrete buy and sell signals to your phone.
The strategy rests on the research of Jegadeesh and Titman (1993) — one of the most cited papers in quantitative finance. What is scientifically established usually fails in practice for one reason only: discipline. That is exactly what the bot supplies.
Three core capabilities — all controlled directly from Telegram. No SSH, no web interface, no cloud dependency.
The bot combines three independent momentum indicators. Each measures a different facet of "strength" — together they give a more robust picture than any single indicator alone. The formulas below appear verbatim in the source code (shared.py, function compute_ticker_metrics).
Trend strength
sma_ratio =
((sma20 / sma200) - 1) * 100
How far does the 20-day average sit above the 200-day average? The higher, the stronger the current upward momentum.
Trend acceleration
delta_sma =
((sma200 / sma200_prev20) - 1) * 100
Is the long-term trend itself still rising? When the 200-day line has already turned down, that is an early warning signal.
Relative strength
ratio_52whtr =
((P/high - 1) +
(P/low - 1) * 0.25) * 100
How close is the stock to its 52-week high and how far above the low? Clearly favours proximity to the high — an established signal.
For each stock the three metrics are computed, ranked separately within the universe (Rank 1 = best value), and the average of the three ranks forms the Final Rank:
Final Rank = (Rank_SMA + Rank_Delta + Rank_HTR) / 3
The portfolio then holds the Top N per universe — N is freely configurable per universe. Defaults are top_n=8 for CDAX and top_n=7 for NASDAQ. Stocks that fall out of the Top N are sold, climbers are bought.
After every scheduled run you get a Telegram message with the top positions and concrete buy/sell recommendations. Out of the box, CDAX and NASDAQ-100 are active. Thirteen further indices — DAX, MDAX, SDAX, TecDAX, Euro Stoxx 50, Stoxx Europe 600, CAC 40, ATX, SMI, FTSE 100, Dow Jones, S&P 500, Nikkei 225 — are pre-configured and activatable via copy-paste.
Full source code, commented configuration, German and English documentation, service scripts for every OS, 184 unit tests, backtest engine with German tax handling.
./check_install.sh verifies Python, dependencies, Telegram and Yahoo reachability in ~10 seconds.python demo.py runs live + 5-year backtest without Telegram setup.Activate whatever you want to track via copy-paste. Custom indices from OnVista can be added with just one ID.
What you need: a machine (Linux, macOS or Windows), Python 3.10+, a Telegram account and a few minutes. Runs on Raspberry Pi, MacBook, desktop PC, VPS — anything works.
Requires Python 3.10+. A virtual environment (venv) is recommended — keeps the bot's dependencies cleanly isolated from system Python.
tar -xzf finanzunity-momentum-1.0.0.tar.gz
cd finanzunity-momentum-1.0.0
python3 -m venv venv
source venv/bin/activate # macOS/Linux
# or on Windows:
# venv\Scripts\activate
pip install -r requirements.txt
Verify the install — checks Python version, dependencies and Telegram + Yahoo Finance reachability in ~10 seconds:
./check_install.sh
From here (venv active, dependencies installed) python demo.py is enough — runs a live analysis and a 5-year backtest against CDAX + NASDAQ 100 and prints everything to the console. No token, no chat ID, no commitment. Sample outputs are also available in the examples/ folder as text files. Anyone who wants the bot in Telegram continues with step 2.
In Telegram, search for @BotFather, send /newbot and follow the instructions — pick a name and handle. BotFather sends you a bot token (looks like 123456789:ABCdef-...) — keep it safe.
You can also invite the bot to a Telegram group; find_chat_id.py in the next step will then return the group chat ID (a negative number like -1001234567890). All bot output then goes to the group instead of the private chat — handy for family setups.
Now — with the venv active — run the helper script:
python find_chat_id.py
Enter the token, then send any message to your bot in Telegram ("hi" will do). The script prints the chat ID and user ID right away — ready to drop into config.json.
In four steps (token → chat ID → universes → schedule) instances/default/config.json is created for you:
python setup_wizard.py
Validates token format and chat ID before saving. Alternative for JSON pros:
python bot.py # creates config.example.json
cp instances/default/config.example.json instances/default/config.json
nano instances/default/config.json # set token + chat ID
python bot.py
Done. The bot is running. On the very first start the language picker appears in Telegram automatically — pick your language, and from then on every reply will be in it. /ping gives you a "Pong" response with diagnostic info anytime.
sudo bash install_service.sh (Linux/systemd) · bash install_service_mac.command (macOS/launchd) · install_service_windows.bat (Windows/Task Scheduler). Auto-start at boot/login, auto-restart on crashes.
Before you invest real money, you can replay the strategy across any historical period — directly from the Telegram bot.
/backtest 2020-01-01 2024-12-31 100000
After a few minutes you get back:
Backtest results are useful to check the plausibility of a strategy — they are not a guarantee of future returns. Past performance was attractive for thousands of strategies that later failed. Backtests show how the strategy would have run in the past. No more than that.
By default the backtest uses the current composition of the universes — survivorship bias is therefore baked in. Starting with version 1.0, the bot automatically builds a historical index database. After some months of operation, with USE_HISTORICAL_UNIVERSES: true, the historically correct composition can be used — that reduces the bias substantially.
The bot is built from the ground up so that you stay in control. No account, no activation, no hidden storage paths.
The bot stores no login credentials for banks or brokers and executes no real orders. You get the signals — the trading is on you.
Only your own Telegram user may control the bot. Other users see only a "not authorised" message with their user ID.
Portfolio, price data, logs all live on your server. Nothing is sent to external services other than Yahoo Finance, Telegram and OnVista.
The bot reports no installations, no usage, no errors and no crash dumps back to FinanzUnity. No account, no activation, no "phone home".
A privacy notice is shown in plain text on first start. Full documentation in PRIVACY.md. Deleting data = deleting the directory.
The entire Python source code lies open. You can trace what happens, when, at any time. Bot tokens are protected against accidental Telegram leakage.
docs/UNIVERSES.md. Any other OnVista-listed index works with a single ID — no code changes needed.instances/ directory over, swap directories — done. Your config, portfolio and price cache survive the upgrade unchanged.LICENSE.docs/ and the 184 unit tests are designed to let most questions be solved without external help.Full package, full source code, commented configuration, German and English documentation, service scripts for every platform, 184 unit tests, backtest engine with German tax handling.