Signal template

Signal templates allows users to create reusable signal expressions using lambda functions. The lambda expression can take any number of arguments and must return a Signal.

Examples

Create a signal with label add_one that adds 1 to any signal with the expression:

lambda x: x + 1

Use the template to add 1 to close_price:

add_one(close_price)

Create a signal with label filter_signal that filters a signal to only return data points within a certain range with the expression:

lambda s, min=0, max=100: df_function(lambda df: df.where(df > min).where(df < max))(s)

Use the template to only return close_price between 50 and 100:

filter_signal(close_price, min=50)