What does the sample application do?
The application analyzes the profit and loss (P&L) of a small trading portfolio over one working week. The week runs from Monday 13 to Friday 17 October 2025. Each trade has a P&L in its own currency. The application converts these values to EUR with daily FX rates. The application has four parts:- Dependencies: Spring Boot starters that provide Atoti Server, Atoti UI and Atoti Admin UI.
- Data: three CSV files, loaded into the datastore at startup.
- Database: three stores that hold trades, books and FX rates.
- Cube: dimensions and measures that turn the stored data into P&L figures.
How to build and run the application
The application is a Spring Boot project. The development environment from Install must be configured first.-
Build the project. Run the following command from the project root directory.
-
Run the
com.activeviam.sample.datastore.AtotiLaunchermain class. -
Open
http://localhost:9090/uiin a browser. The Atoti UI login page appears.
The application defines two users by default.
Which dependencies does the application need?
An Atoti Server application is a Spring Boot application. The sample application declares Atoti starters as Maven dependencies in itspom.xml file.
The sample application uses three starters:
atoti-server-starter: required. It provides the API to define the Atoti Datastore and cubes.atoti-ui-starter: embeds Atoti UI in the running application.atoti-admin-ui-starter: embeds Atoti Admin UI in the running application.
pom.xml file.
Which data does the application load?
The application loads three CSV files at startup. The files are packaged as classpath resources:trades.csvholds one P&L value per trade, risk factor, sensitivity and as-of date.books.csvdescribes the organization that each book belongs to.fx_rates.csvholds the daily rate to convert each currency to EUR.
SourceConfig class defines the file locations as constants, as follows.
SourceConfig creates one CSV topic per store from these locations.
For more on CSV loading, see CSV source.
How is the database defined?
The database is the Atoti in-memory Datastore. TheDatastoreConfig class defines three stores and one reference.
- The
TradesandBooksstores are linked by a reference. - The
FxRatesstore is isolated: no reference links it to the other stores.
What does the Trades store hold?
- The
Tradesstore is the fact table. Each record holds the P&L of one trade for one risk factor, sensitivity and as-of date. - The key fields are
AsOfDate,TradeId,RiskFactorandSensitivity. - The
Currencyfield holds the trade currency. ThePnLfield holds the P&L in that currency.
What does the Books store hold?
TheBooks store describes the organization of each book. Its key field is BookId.
The other fields place each book in a trading desk, a sub business unit and a business unit.
How are trades joined to books?
TheTradesToBooks reference joins the Trades store to the Books store on the BookId field.
Through this reference, the cube can read book attributes for each trade.
How are FX rates stored?
TheFxRates store holds the rate to convert one unit of each currency to EUR, for each as-of date.
Its key fields are AsOfDate and Currency. The RateToEUR field holds the rate.
FxRates store to the Trades store. The cube reads the rates through a lookup measure instead.
The section “How does the cube read FX rates?” on this page describes that measure.
For more on store definitions, see Datastore configuration.
How is the cube built?
ThePivotManagerConfig class defines one cube named Trades. The cube definition has three parts: a selection, dimensions and measures.
Which data does the cube read?
The selection defines which store fields the cube can use. The sample selection starts from theTrades store.
The selection includes every field that the Trades store can reach through references.
The Books fields are therefore part of the selection, through the TradesToBooks reference.
FxRates store is not part of the selection, because no reference reaches it from the Trades store.
Which dimensions does the cube expose?
The cube exposes four single-level hierarchies and two multi-level hierarchies. The single-level hierarchies areAsOfDate, TradeId, Currency and Sensitivity.
Each one contains one level with the same name.
The two multi-level hierarchies are:
- The
Bookinghierarchy, in theOrganizationdimension. Its levels areBusinessUnit,SubBusinessUnit,TradingDeskandBook, from top to bottom. - The
Risk factorhierarchy, in theRiskdimension. Its levels areRiskClassandRiskFactor, from top to bottom.
How are the measures defined?
The cube defines three measures with the Copper API. The goal is a P&L in EUR:PnL.SUM and FX rate to EUR
are the building blocks of PnL (EUR).
How is the P&L summed?
ThePnL.SUM measure sums the PnL field of the Trades store. The measure is placed in the P&L folder.
PnL.SUM does not convert currencies: it adds the PnL values as they are, each in the currency of its trade.
Amounts in different currencies, such as USD and CHF, cannot be added as they are.How should the cube handle several currencies?
Two designs avoid adding amounts in different currencies. Each one changes what the users of the cube see.
Slicing means making
Currency a slicing hierarchy.
The cube then shows one currency at a time, so PnL.SUM never adds currencies together.
If the user does not choose a currency, the cube shows a default one.
The choice depends on what the user needs to understand:
- Convert when the user needs totals across currencies, as in most P&L and risk reporting.
- Slice when the user only needs to see the amounts in one currency at a time.
Currency is therefore an ordinary hierarchy, not a slicing one: users can still filter or expand on a currency, but nothing forces them to choose one.
Larger cubes often offer both: measures in the trade currency next to converted measures, and sometimes a slicing hierarchy that lets users choose the target currency.
To convert amounts to EUR, the cube needs the FX rates.
How does the cube read FX rates?
TheFX rate to EUR measure reads the RateToEUR field from the isolated FxRates store. The following code does this in two steps.
- It joins the
FxRatesstore to the cube. TheAsOfDateandCurrencyfields ofFxRatesmap to theAsOfDateandCurrencylevels. - A lookup measure returns the rate that matches the
AsOfDateandCurrencyof each queried location. The measure is placed in theFXfolder.
How is the P&L converted to EUR?
ThePnL (EUR) measure gives the same result as converting each trade to EUR and then adding them up.
Because all trades with the same AsOfDate and Currency use the same rate, it first sums their PnL with
PnL.SUM, then multiplies that sum by the FX rate to EUR measure. It then adds these converted values
across all dates and currencies in the queried location.
PnL.SUM, the PnL (EUR) measure is meaningful at any level, because all its values are in EUR.
For more on Copper measures, see Creating and publishing measures.
Next steps
The finished project is in thedatastore folder of the atoti-java-sdk-install-and-start repository on GitHub.
To learn more about the components used on this page, see: