Fallback

A signal may not have any data for an entity. The fallback function allows users to specify a fallback signal to use if the main signal does not contain any data for an entity.

The signals given to the fallback function are evaluated in order, and for each entity, the first signal that has a non-NaN value for the entity is selected.

To determine if a signal has values for an entity, the evaluation period is pre- and post-extended with 10 years by default.

fallback(signals, pre_extend, post_extend)

Get the first signal with values for each entity.

Parameters:
  • signals (List[Signal]) – A List of signals. The signals are evaluated in order, and for each entity, the first signal that has a non-NaN value for the entity is selected.

  • pre_extend (int) – Number of days to pre-extend the evaluation period with, to determine if an entity has a value for a signal. Default value is 10*365.

  • post_extend (int) – Number of days to post-extend the evaluation period with, to determine if an entity has a value for a signal. Default value is 10*365.

Examples

A signal that when evaluated for a company returns quarterly fundamental sales if it exists, and if not, semi-annual fundamental sales:

fallback([fundamental('sales', period='q'), fundamental('sales', period='s')])