# Workbench Guide

A guide to functions available in the Workbench product on Glassnode.

Workbench is a powerful tool in Glassnode studio enabling analysts to compare, assess and create a variety of metrics available on the platform.

The table below provides a guide to the use of various workbench functions available to analyse datasets.

`m1, m2`

etc. refer to a particular dataset added to the chart.`n`

is a float value.`period`

is an integer value defining the number of trailing data-points considered by the function, applied to the data resolution specified (i.e. a simple moving average with period 30 will consider 30-days for daily resolution data, and 30-weeks for weekly resolution data).`since`

is a timestamp in format `"YYYY-MM-DD HH:mm:ss"`

(quotations required in syntax). Timestamps can be shortened from left to right, for example `"2010"`

will resolve from 01-Jan-2010 onwards, and `"2010-06"`

will resolve from 01-June-2010 onwards.Functions may be nested, such that any input timeseries (i.e.

`m1`

) may be replaced by a function to be evaluated, for example `sma(m1, 7)`

.When timeseries of different resolutions are compared (i.e. subtracting a metric with resolution 1d from a metric with 1h resolution), workbench will perform the operation at the larger resolution (1d in this case), and use the 00:00 UTC timestamp of the smaller resolution.

`period`

resolution is defined by the largest resolution of the timeseries being compared.Workbench Function | Syntax | Function Description |
---|---|---|

Horizontal Line | float value e.g. `10.55` | Draws a horizontal line at the specified y-ordinate |

Simple Moving Average | `sma(m1,period)` | Returns a simple moving average of dataset m1 with a period length specified |

Exponential Moving Average | `ema(m1,period)` | Returns an exponential moving average of dataset m1 with a period length specified |

Moving Median | `median(m1,period)` | Returns a moving median of dataset m1 with a period length specified. |

Rolling Sum | `sum(m1,period)` | Returns a rolling sum of dataset m1 with a period length specified |

Standard Deviation | `std(m1,period)` | Returns a standard deviation of dataset m1 with a period length specified |

Cumulative Sum | `cumsum(m1)` or`cumsum(m1,since)` | Calculates an expanding sum using all data from time since up to each datapoint. (See Note 1) |

Cumulative Mean | `cummean(m1)` or`cummean(m1,since)` | Calculates an expanding mean using all data from time since up to each datapoint. (See Note 1) |

Cumulative Standard Deviation | `cumstd(m1)` or`cumstd(m1,since)` | Calculates an expanding standard deviation using all data from time since up to each datapoint. (See Note 1) |

Percent Change Over Period | `percent_change(m1,period)` | Returns the percentage change of m1 over the specified period. Values are returned as decimal (i.e. 0.20 indicates +20% growth over the specified 'period').
Note that `percent_change` replaced the original `returns` function. |

Difference Over Period | `diff(m1,period)` | Returns the absolute value change of m1 over the specified period. Calculated as the difference between each datapoint and data from the specified 'period' in the past. |

Absolute Value | `abs(m1)` | Returns the absolute value of all data in m1. |

Power | `pow(m1,n)` | Raises all data in m1 to the specified power 'n'. |

Logarithm | `log(m1)` | Takes the logarithm (base 10) of all data in m1. |

Relative Strength Index | `rsi(m1,period)` | Calculates the relative strength index for m1 using the specified input 'period' |

Range | `range(m1)` | Draws a line from y=0 to y=n, increasing in increments of 1 (where n is the number of datapoints in m1) |

Range (defined start/end) | `range(m1,start?,end?)` | Draws a line from y=start to y=end, changing in increments of (end-start)/n (where n is the number of datapoints in m1) |

Minimum | `min(m1, m2, ..., n)` | Returns the minimum value of all data in a dataset (or n) |

Maximum | `max(m1, m2, ..., n)` | Returns the maximum value of all data in a dataset (or n) |

Shift | `shift(m1, period)` | Shifts the dataset right (positive) or left (negative) by the number of timesteps in the defined period. For 1hr resolution data, a period of -24 will shift the data left by 24hrs, where as for 1d resolution data, it would shift it left by 24-days. |

If-Then Condition | `if(m1, "cond", m2, true, false)` | Establishes an if-then condition comparing the trace of m1 to m2 at each data point, returning the result `true` or `false` . This tool can accept nested functions in place of the inputs `m1` , `m2` , `true` and `false` , for example the input true result may be `sma(m1/m2,7)` .
The following conditions are available an inserted as a string:
`"=" equal to`
`"!=" not equal to`
`">" greater than`
`">=" greater than or equal to`
`"<" less than`
`"<=" less than or equal to` |

Pearson's Correlation | `corr(m1, m2, period)` | Calculates the Pearson's correlation factor between traces `m1` and `m2` over a defined trailing period. The correlation will be run at the resolution of the largest input trace resolution. |

Value At | `value_at(m1, date)` | Returns the value of a specific date as a horizontal line. |

**:**

*Notes*- 1.Example for cumulative sum/mean/std: the function cummean(m1,"2012-01-01") at date "2020-01-01" will return a mean of all data from 2012-01-01 to 2020-0-01, but not consider any data after this. These metrics will return zero for all periods prior to defined timestamp "since".

This workbench tutorial provides an introduction to the tool, and shows you how to build your first metrics and assess Bitcoin market cycles using Supply Last Active 1yr+.

Tutorial Workflow:

- Add base metrics and set correct scales and axes.
- Convert a Supply from % into BTC Volume.
- Calculate a new metric ‘Coins Younger than 1yr.
- Calculate a Supply Net Position Change metric using the diff function.