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.

For practical hands-on tutorials on how you can use Workbench, check out the following dashboards:

Functions Guide

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

Input Values

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 FunctionSyntaxFunction 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) orcumsum(m1,since)

Calculates an expanding sum using all data from time since up to each datapoint. (See Note 1)

Cumulative Mean

cummean(m1) orcummean(m1,since)

Calculates an expanding mean using all data from time since up to each datapoint. (See Note 1)

Cumulative Standard Deviation

cumstd(m1)orcumstd(m1,since)

Calculates an expanding standard deviation using all data from time since up to each datapoint. (See Note 1)

Cumulative Max

cummax(m1) orcummax(m1, period)

Returns a cumulative maximum of dataset m1 with a period length specified.

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 at a specific date as a horizontal line.

Subset

subset(m1, since?, end?)

Returns a subset slice of m1 between timestamp since and end.

Round

round(m1, digits, mode?)

Rounds m1 to a specified number of significant figures (digits). The digits parameter can be positive for decimals (2 = nearest 0.01) or negative (-2 = nearest 100). There are three rounding modes available; nearest mode=0 (default), rounddown mode=-1, and roundup mode=1.

Upper

upper(m1, m2, ...)

Returns the highest value from all input traces at each x-ordinate.

Lower

lower(m1, m2, ...)

Returns the lowest value from all input traces at each x-ordinate.

Drawdown

drawdown(m1)

Returns the relative drawdown from the all-time high of m1.

Mean Return

mean_return(m1, period)

Returns the annualized rolling mean return of m1 over period.

Realized Volatility

realized_vol(m1, period)

Returns the annualized realized volatility of m1 over period.

Sharpe Ratio

sharpe_ratio(m1, period)

Returns the annualized Sharpe ratio of m1 over period.

Backtest

backtest(m1, f1, since, initial_capital_usd, rel_trading_costs)

Returns the net asset value (NAV) curve of a trading strategy defined by the trading signal f1 on asset price series m1 with an inital capital of initial_capital_usd from since to present. Relative trading costs are given by rel_trading_costs. The time-dependent trading signal f1 is expected to return values in the range [-1, 1], where 1 corresponds to a 100% long position in m1, -1 to a 100% short position in m1, and 0 to no position in m1.

Dollar Cost Averaging

dca(m1, f1, since)

Returns the net asset value (NAV) curve of the aggregated position in asset m1. f1 defines the daily DCA installments over time and since defines the starting timestamp of DCA. The function calculates cumsum(f1/m1, since)*m1.

Dollar Cost Averaging Installments

dca_installments(m1, since, total_invest_usd, numb_installments)

A helper function that simulates daily DCA (dollar cost averaging) installments. The parameters are: a price series m1, a timestamp when DCA begins: since, the total target investment in USD: total_invest_usd, how many installments in total: numb_installments. The function returns a step function visualizing the daily installments (in USD). This serves as possible input f1 to the dca function.

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".

  2. Example for backtest: the function backtest(m1, if(sma(m1, 20), ">", sma(m1, 50), 1, 0), "2020-01-01", 1000, 0.001) simulates the simple moving average cross-over strategy for an investment of $1000 from "2020-01-01" until present. The trading costs are approximated with 0.1% of the volume per trade.

  3. Example for dca: dca(m1, f1, "2020-01-01") with f1 defined as dca_installments(m1, "2020-01-01", 1230, 1000). This simulates the dollar cost averaging of a total investment of $1230 over 1000 days, starting from "2020-01-01".

Workbench Video Tutorial

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.

Backtesting in Workbench Guide

Discover Workbench's new backtesting suite and take your investment strategy to the next level. Test and compare trading hypotheses, and evaluate risk and performance with metrics like drawdown and Sharpe ratio. Explore basic and advanced trading strategy examples, including on-chain indicators.

Read the full article: http://insights.glassnode.com/backtesting-in-workbench/

Last updated