Skip to main content
Version: v4

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.

TagDescriptionExample
share_nameDisplay nameApple
share_symbolYahoo! Finance tickerAAPL
share_currencyCurrencyUSD
share_exchangeExchangeNMS, PAR
quote_typeInstrument typeEQUITY, ETF
note

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.

Fields

FieldDescription
share_priceCurrent or historical price (Close)
price_openOpen price (OHLC, for candlestick panels)
price_highHigh price (OHLC)
price_lowLow price (OHLC)
purchased_quantityQuantity bought
purchased_priceWeighted average cost price
purchased_feeTotal fees
owned_quantityQuantity currently owned
received_dividendTotal dividends received
dividend_yieldDividend yield (percentage)
pe_ratioPrice-to-Earnings ratio
market_capMarket capitalization
volumeTrading volume
note

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.

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:

VariableDefaultDescription
INFLUXDB_HOSThttp://influxdb:8181InfluxDB 3 host URL
INFLUXDB_TOKEN(required)InfluxDB API token
INFLUXDB_DATABASEsuivi_bourseDatabase 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.

Development token

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.