Skip to main content
The code shown on this page comes directly from the sample application, so it always matches the project. Before starting, set up the development environment described in Install.

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.
  1. Build the project. Run the following command from the project root directory.
  2. Run the com.activeviam.sample.datastore.AtotiLauncher main class.
  3. Open http://localhost:9090/ui in a browser. The Atoti UI login page appears.
The application exposes two interfaces on port 9090. 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 its pom.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.
The following dependency declarations come from the sample pom.xml file.
The Spring Boot version must match the version that the Atoti Java SDK requires. For the supported versions, see dependencies. For details about the main starter, see The Atoti Server Starter.

Which data does the application load?

The application loads three CSV files at startup. The files are packaged as classpath resources:
  • trades.csv holds one P&L value per trade, risk factor, sensitivity and as-of date.
  • books.csv describes the organization that each book belongs to.
  • fx_rates.csv holds the daily rate to convert each currency to EUR.
The data is a small extract of a historical value-at-risk dataset. It contains 100 trades across 5 books. The FX rates are illustrative, not market data. The 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. The DatastoreConfig class defines three stores and one reference.
  • The Trades and Books stores are linked by a reference.
  • The FxRates store is isolated: no reference links it to the other stores.
Each store definition lists its fields and their types, and marks which fields form the store key.

What does the Trades store hold?

  • The Trades store 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, RiskFactor and Sensitivity.
  • The Currency field holds the trade currency. The PnL field holds the P&L in that currency.

What does the Books store hold?

The Books 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?

The TradesToBooks 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?

The FxRates 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.
No reference links the 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?

The PivotManagerConfig 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 the Trades 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.
The 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 are AsOfDate, TradeId, Currency and Sensitivity. Each one contains one level with the same name. The two multi-level hierarchies are:
  • The Booking hierarchy, in the Organization dimension. Its levels are BusinessUnit, SubBusinessUnit, TradingDesk and Book, from top to bottom.
  • The Risk factor hierarchy, in the Risk dimension. Its levels are RiskClass and RiskFactor, from top to bottom.
The following code defines these dimensions.
For more on dimensions and hierarchies, see Dimension and hierarchy configuration.

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?

The PnL.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.
This guide converts the P&L to EUR, because the goal is a total P&L across all currencies. 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?

The FX rate to EUR measure reads the RateToEUR field from the isolated FxRates store. The following code does this in two steps.
  1. It joins the FxRates store to the cube. The AsOfDate and Currency fields of FxRates map to the AsOfDate and Currency levels.
  2. A lookup measure returns the rate that matches the AsOfDate and Currency of each queried location. The measure is placed in the FX folder.
For more on joining isolated stores, see Joining isolated stores in Copper.

How is the P&L converted to EUR?

The PnL (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.
Unlike 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 the datastore folder of the atoti-java-sdk-install-and-start repository on GitHub. To learn more about the components used on this page, see: