Skip to content

How to Use Logic and Trees in Rose

Another feature of Rose is the ability to always check the underlying reasoning and data for any chart or map you have access to by way of a concept we call Logic.

In this tutorial we will demonstrate how Trees and Logic work by building a yield curve on Rose.

The yield curve is an indicator for the health of the economy. Yet, despite the importance of the yield curve, it can be difficult to find online.

Every Project Starts with a Raw Dataset

If you are making a yield curve, you will need data for two-year US bond rates and ten-year US bond rates.

The rosecodes for the two-year and ten-year bonds rates are DGS2 and DGS10, sourced from FRED.

Renaming Objects

DGS2 and DGS10 are not good names. Just from a glance, you cannot tell what they represent and to find them again, you would have to remember the exact spelling.

So, let's rename them!

Logic

On Rose, you can use Logic to rename any rosecode.

In a code module <>, type new.rosecode = old.rosecode

The old.rosecode can be more than just a single dataset; it can be a dataset with functions applied to it or even other logic objects (which in turn can have functions applied to them).

The new object then keeps track of all the underlying data and transformations that just got renamed and stores them in the Logic Tree for that rosecode.

The Code

When you run the module renaming a rosecode, the old.rosecode disappears, signifying that you have successfully pushed logic.

These new.rosecodes will point to the old.rosecodes, so that if DGS2 or DGS10 are updated, the new versions will also be updated.

usa.2y.bonds.rate.test = DGS2
usa.10y.bonds.rate.test = DGS10

Try copy and pasting the above logic pushes into a code module <> on Rose.

So, Where do Trees Fit In?

On Rose, click on the Explore Tree button for usa.2y.bonds.rate.test. Once you do that, there should be two side-by-side nodes. That is the tree. It is a visualization of where the logic object you just created came from.

Trees move right-to-left, which means that the rightmost node in a tree is the original dataset everything is built on. Each box represents a different step in the creation of the rosecode.

In this example, DGS2 is the raw data and usa.2y.bonds.rate.test is the renamed version.

Making the Curve

The formula for creating a yield curve is ten-year US bond rates - two-year US bond rates.

So we are going to perform that operation and store the result as a new logic object yield.curve.test

Try running the following snippet in a code module <> on Rose.

yield.curve.test = usa.10y.bonds.rate.test:sub(usa.2y.bonds.rate.test)

Benefits of Logic

  1. Help users trace how a timeseries/map is built
  2. Keep a rosecode updated as long as the underlying data is updated
  3. Make it easier to pull data by simplifying names
  4. Stitch data together from different providers