Skip to content
akmal523Public

About

Daily portfolio manager for one EUR investor on Trade Republic: explained scores, one to-do list, Telegram bot and morning digest. Local, no auto-trading.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Latest commit

 

History

164 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quant-AI

CI Docs Python 3.11+ License: MIT

A daily portfolio manager for one EUR-based investor on Trade Republic.

You enter what you own. Every trading day Quant-AI refreshes prices, scores each holding, and tells you in plain language what to buy, sell, swap or leave alone, through a local browser app and a Telegram bot. You place the orders yourself in the broker app; Quant-AI never trades and never connects to your broker account.

Quant-AI is a personal tool, not financial advice. It applies fixed, documented rules to your own numbers. Check every suggestion before you act.

Contents

Features

  • A monthly plan you can read. Income flows down a waterfall: spending, cash goal, savings plan, then free money to the pot furthest below target. The plan is shown as plain sentences with dates, so you can check that the program understood you.
  • One to-do list. Every rule feeds one list, grouped into Today and This month. Each item is one action with one reason and a euro amount.
  • Explained scores. Price trend (momentum and the 200-day average), five fundamentals for stocks, and the tone of recent news headlines (FinBERT, optional). A part without data is left out and the confidence drops; it is never guessed.
  • Classes and targets. Each holding is core (long-term, bought through the savings plan), active or speculative, with a target share of the portfolio.
  • Swaps with a hurdle. An active holding is only swapped when a better idea clearly beats it after fees, tax and score noise.
  • Telegram bot. Update holdings, log buys and sells, see the list and what the rules are watching, from your phone.
  • Morning digest. One Telegram message per trading day: value, day change, market trend, what to do, what is being watched, news, upcoming birthdays.
  • Savings plan aware. Knows the broker buys your plan automatically and reminds you to record it.
  • Birthdays and gift budgets, optionally read from your Google, Outlook or Apple calendar.
  • Local and private. All data stays in a folder on your computer.

Quick start

Requirements: Python 3.11 or newer on Linux, macOS or Windows. The daily timer and the background bot use systemd (Linux).

Step Linux / macOS Windows
Install ./install.sh install.bat
Start the app ./start.sh start.bat
Update ./update.sh update.bat

start opens the app in your browser. update backs up your data first, pulls the new version, reinstalls and migrates the database.

For news sentiment (optional, about 1 GB):

.venv/bin/pip install -e ".[news]" --extra-index-url https://download.pytorch.org/whl/cpu

First-time setup

The app has three pages: Portfolio (value, your plan, what to do), Holdings (update what you own; history) and Settings. Turn on Settings -> Advanced for the Full analysis page (scores, research ideas, market trend, pipeline health).

  1. Answer the plan questions on Portfolio: income, spending budget, cash goal, share of the rest that goes to cash, and how invested money is split into pots. Every answer has a default.
  2. Enter your holdings. Open Holdings and type each position from the broker app: current value, profit, and average cost per share. Fill Plan_EUR_month for a holding bought through a savings plan. Confirm to save; saving is the only way data enters.
  3. Set classes and targets. Under Holdings -> Class and target (or /set PSX active 20) give each holding a class (pot). With a plan set, the pot split is the one source of truth: a holding's target is only its weight inside its pot (core 60% with EUNL 50 and 5J50 10 gives EUNL 50% and 5J50 10%). A pot whose holdings have no target is split equally between them; inside a pot with targets, a holding without one gets alerts and swap checks but no "buy more" or "sell part" advice.
  4. Set cash and the savings-plan day in Settings.
  5. Run analysis once (Settings -> Run analysis). It fetches prices, fundamentals and news, and scores everything.
  6. Optional: Telegram. Settings -> Set up Telegram, then Run the bot in the background. See Telegram bot.
  7. Optional: the daily timer. quant schedule refreshes prices and sends the digest every trading day (Linux).

Your monthly plan

Each month money flows down a waterfall; each step fills before the next one gets anything:

income
  -> spending budget              (what you live on)
  -> cash goal                    (a share of the rest, until the goal is reached)
  -> savings plan                 (what the broker buys automatically)
  -> free money                   (to the pot furthest below its target;
                                   under 25 EUR it is saved for next month)

Invested money is split into three pots with targets you set:

Pot Rule
Core broad world funds bought by the savings plan; never sold, drift is fixed by changing the plan
Active single stocks and themes; bought and sold on alerts and swaps
Speculative small bets up to a cap you choose; stop-loss and take-profit

Core funds are not picked by scores. A built-in shortlist of broad, cheap, accumulating ETFs (FTSE All-World, MSCI ACWI, MSCI World, Emerging Markets, S&P 500, Europe) with their yearly cost. With no core fund the plan recommends one fund that owns the whole world. With core funds it checks three things: a sector or theme fund in core (it belongs in active), two funds where one index contains the other (one is enough), and a fund that tracks the same market for at least 0.10% a year less (switch the savings plan, never sell). /plan funds lists the shortlist; /plan fund add SYMBOL INDEX TER [NAME] adds your own (stored in core_funds_user.csv in the data folder).

Setup and checking. The first /plan in Telegram asks five questions, one at a time, each with a default (ok takes it); the browser asks the same on Portfolio. Afterwards the plan is shown back as sentences, so you can see what the program understood. The day after the savings plan runs, the morning digest adds a This month statement: the plan buy recorded or missing, other buys and sales, and what happens next month (/plan month shows it any time).

/plan (or Home) shows the plan as sentences, for example "100 EUR a month to cash until 10,000 EUR (now 8,800 EUR, about December 2027)". Change one line with /plan income 650; the reply lists exactly what changed. Fields: income, spending, cash, share, invest, core, active, spec, cap.

How the advice works

Every rule is in quant/engine/action_taxonomy.py and every threshold in quant/config.py.

Action When Applies to
Buy more than 5 percentage points below the target share; paid from the month's free money (with a plan) holdings with a target
Sell part more than 10 percentage points above the target share (smaller drift is fixed with new money) holdings with a target
Reinvest money from sales not yet spent (25 EUR or more, last 45 days) goes to the pot furthest below its target the neediest pot
Review: loss 20% or more below what you paid active and speculative
Review: crash a fall of 15% or more within 7 days all
Review: score score below 40 (medium or high confidence) active and speculative
Stop-loss / take-profit -50% / +100% from what you paid speculative only
Review: risk the speculative part above its cap the speculative part
Review: market the market trend turns down active part, no new buys
Swap a high-confidence idea scores more than 5 points above the holding, the holding's score is medium or high confidence, and the two order fees are under 1% of the position active and speculative

Sells round down to 5 EUR and are never under 25 EUR; buys round to 10 EUR. When nothing crosses a limit the list says "Nothing to do", and /watch shows how close each holding is.

Telegram bot

Set up Telegram first (Settings -> Set up Telegram, or quant notify-setup). Then run the bot on the computer that holds your data:

  • Settings -> Telegram bot -> Run the bot in the background, or quant bot --install: a systemd user service that starts with the computer and restarts after an error. quant bot --off removes it.
  • quant bot in a terminal for a try-out (Ctrl+C stops it).

quant bot --status and quant bot --restart manage it; quant upgrade restarts it for you. Log: journalctl --user -u quant-bot. Only the chat id saved in Settings is answered.

Command What it does
/plan, /plan FIELD VALUE your monthly plan; change one line, e.g. /plan spending 320
/plan funds, /plan fund add SYMBOL INDEX TER [NAME] the core fund shortlist; add your own fund
/plan setup, /plan month answer the plan questions again; last month's statement
/todo, /done N the to-do list, numbered; mark item N done
/buy SYMBOL EUR [PRICE] record a buy; the price defaults to the latest close
/sell SYMBOL EUR|all [PRICE] record a sell
/set SYMBOL VALUE PROFIT [COST] the broker numbers for one holding (COST is needed for a new one)
/set SYMBOL core|active|spec [WEIGHT] a holding's pot and its weight inside the pot, e.g. /set NVDA active 10
/watch per holding: score, distance to the loss alert, best swap candidate and the score it needs
/dates birthdays and holidays in the next 60 days, with budgets
/gift the year of occasions and the monthly gift pot
/gift add NAME DD.MM [BUDGET] add an occasion, e.g. /gift add "Aunt Clara" 29.12 20
/gift remove NAME, /gift pot EUR, /gift import [BUDGET] remove one; set the pot; import yearly events from your calendar
/calendar, /calendar LINK, /calendar off calendar status; connect (your message is deleted); disconnect
/help every command with examples

Also answered, but not in the menu: /portfolio (holdings and profit), /history, /class (every pot and target), /confirm and /cancel (the buttons under a pending change do the same).

Portfolio changes (/set, /buy, /sell) are shown as a review with Confirm and Cancel buttons and saved only on Confirm. /plan, pot and target changes, /gift and /calendar apply at once. Decimals may use a comma (12,5).

While the computer is off or asleep, Telegram keeps your messages for up to 24 hours, and the bot answers them in order when it starts. For an always-on bot, run Quant-AI on a machine that stays on.

Savings plan, birthdays and calendar

Savings plan. The broker runs the plan by itself, so it is never a to-do. The day before and on the day, the digest and /todo say "savings plan buys 200 EUR ... automatically - nothing to do". If no buy is recorded afterwards, they tell you which /buy to send.

Birthdays and gifts. Keep a list of occasions (name, date, budget) and a monthly gift pot; Easter is computed every year. The digest shows Coming up a week ahead. Edit the list with /gift, in Settings -> Birthdays & calendar, or by hand in occasions.yaml (see examples/occasions.example.yaml).

Connect a calendar (optional). Any calendar with an iCal (.ics) link works. For Google Calendar:

  1. Open Google Calendar in a browser, then the gear icon -> Settings.
  2. Under Settings for my calendars, click your calendar.
  3. In Integrate calendar, copy Secret address in iCal format.
  4. Give it to Quant-AI: send /calendar <link> in Telegram, paste it in Settings -> Birthdays & calendar -> Save link, or run quant calendar --set.

The link is stored only in .env.local next to your data folder (mode 600) and is never logged or shown. The calendar is read at most once a day. Treat the link like a password; if it leaks, reset it on the same Google settings page.

Your data and privacy

  • Your positions, settings, database and backups live in your per-user data folder (on Linux ~/.local/share/quant-ai), never in the repository. Set QUANT_DATA_DIR to use another folder.
  • Secrets (the Telegram token, the calendar link) live in local files with mode 600.
  • Network access, all outgoing: prices, fundamentals and headlines from Yahoo Finance; exchange rates from frankfurter.dev; index member lists from Wikipedia; the FinBERT model from Hugging Face (once, with the news extra); Telegram; and your calendar link if you set one. Your holdings are never sent anywhere except to your own Telegram chat.
  • Back up with Settings -> Back up now or quant backup. See docs/backup.md.

Command line

The app needs no terminal. For scripting:

.venv/bin/quant <command>        # Windows: .venv\Scripts\quant <command>
Command What it does
dash start the browser app
refresh fetch market data and analyse your holdings
daily the daily check (used by the timer)
schedule [--off|--status] install, remove or report the daily timer
bot [--install|--off|--status|--restart] the Telegram bot
notify-setup set up Telegram in the terminal
calendar [--set|--off|--import] calendar status, connect, disconnect, import
backup archive your data (tar.gz)
upgrade update to the latest version
doctor read-only diagnosis, safe to paste into an issue

Project structure

quant/
  dashboard.py        Streamlit entry point
  pages/              the five app pages (Portfolio, Update, Analysis, History, Settings)
  ui/                 copy, formatting, tables and cards for the pages
  engine/             the decision engine
    action_taxonomy.py       every buy / sell / review / swap rule
    score_model.py           trend, fundamentals and news scores
    today_list.py            builds the one to-do list
    daily.py, scheduler.py   the daily run and the systemd timer
    notify.py                the morning Telegram digest
    telegram_bot.py          the Telegram bot
    occasions.py, reminders.py   birthdays, calendar, savings plan
    ledger.py, confirm.py, mtm.py   trades, saving, portfolio value
  data/               market data, fundamentals, news, the DuckDB store
  portfolio/          holdings, account, classes and targets, tax
  reporting/          stored analysis results
  cli/                the `quant` command
  config.py           every threshold and setting
  paths.py            where data lives
tests/                pytest suite
scripts/              CI audits (no silent fallbacks, no user data in git)
docs/                 backup, performance, API reference (built with MkDocs)
examples/             example data files
data/                 shipped reference data (no user data)

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,dashboard]"
pytest -n auto                  # the test suite
ruff check quant tests          # lint
python scripts/audit_stubs.py   # no silent fallbacks

CI runs the same checks on every push. See CONTRIBUTING.md for style and the pull-request process, and SECURITY.md to report a vulnerability.

Documentation

License

MIT. Not financial advice; use at your own risk.

About

Daily portfolio manager for one EUR investor on Trade Republic: explained scores, one to-do list, Telegram bot and morning digest. Local, no auto-trading.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages