InfluxDB data model
SuiviBourse writes everything — live scrapes and backfilled history — to a
single InfluxDB 3 Core measurement: portfolio_metrics. Data is written
with second precision.
Tags
Tags identify the series and are used to filter/group in Grafana.
| Tag | Description | Example |
|---|---|---|
share_name | Display name | Apple |
share_symbol | Yahoo! Finance ticker | AAPL |
account | Account bucket (default unless accounts are declared) | PEA, default |
share_currency | Currency | USD |
share_exchange | Exchange | NMS, PAR |
quote_type | Instrument type | EQUITY, ETF |
share_name and share_symbol are always set. The currency/exchange/quote-type
tags are only written when the ticker info was successfully fetched, so that
historical and live points share the same series identity.
account tag is on v4.1+ writes only, not on historyThe account tag is carried by 100% of the points written from v4.1 onwards —
not by points written before the upgrade, which have no tag and are exposed
as NULL. Always read it with COALESCE(account, 'default') and never with a
bare WHERE account = '…' (which would silently drop the pre-v4.1 points). See
Upgrading to accounts for the full picture.
Fields
| Field | Description |
|---|---|
share_price | Current or historical price (Close) |
price_open | Open price (OHLC, for candlestick panels) |
price_high | High price (OHLC) |
price_low | Low price (OHLC) |
purchased_quantity | Quantity bought |
purchased_price | Weighted average cost price |
purchased_fee | Total fees |
owned_quantity | Quantity currently owned |
received_dividend | Total dividends received |
dividend_yield | Dividend yield (percentage) |
pe_ratio | Price-to-Earnings ratio |
market_cap | Market capitalization |
volume | Trading volume |
Market fields such as dividend_yield, pe_ratio and market_cap may be
missing for some instruments (e.g. ETFs or crypto). Fields are only written when
a value is available.
For opt-in accounts,
SuiviBourse also writes two daily measurements: account_metrics (tags
account / account_type / account_currency; fields cash_balance,
holdings_value, total_value, net_contributed, xirr, gain_absolu,
twr_index) and portfolio_totals — the same performance fields at the
global level, written with no tag (a synthetic account tag would double every
SUM()), only when all accounts share one currency.
Querying with SQL
InfluxDB 3 is queried with SQL. Grafana uses its InfluxDB datasource in SQL
query mode (POST, database suivi_bourse). A simple query:
SELECT time, share_price
FROM portfolio_metrics
WHERE share_symbol = 'AAPL'
ORDER BY time
Compute the current market value of a position:
SELECT time, share_price * owned_quantity AS position_value
FROM portfolio_metrics
WHERE share_symbol = 'AAPL'
ORDER BY time
Connection
The writer is configured through environment variables:
| Variable | Default | Description |
|---|---|---|
INFLUXDB_HOST | http://influxdb:8181 | InfluxDB 3 host URL |
INFLUXDB_TOKEN | (required) | InfluxDB API token |
INFLUXDB_DATABASE | suivi_bourse | Database name |
In the Docker Compose stack, the database is
created automatically by influxdb3-init.sh and the token is provisioned into
both InfluxDB and the Grafana datasource.
The provisioned token is a development value shipped for zero-config local use. Change it before any non-local deployment — see the token note in the Docker Compose guide.
Long-running deployments & Parquet files
InfluxDB 3 Core does not auto-compact: every write batch lands new Parquet files that are never merged. SuiviBourse keeps this in check by writing the account performance series incrementally — a steady scrape cycle rewrites only today's point instead of the whole daily history — so file growth stays bounded in normal operation.
If a query still hits Core's per-query file cap (default 432), for example after a very long uptime or a large backfill, you'll see errors like:
Query would scan N Parquet files, exceeding the file limit.
Raise the cap on the InfluxDB container:
environment:
- INFLUXDB3_QUERY_FILE_LIMIT=20000 # default is 432
For heavy, always-on workloads, InfluxDB 3 Enterprise adds automatic compaction, which removes the fragmentation entirely.