Retrieving companies

When evaluating signals in the signal explorer, or using them in dashboards or portfolio strategies, the app provides the companies or entities to evaluate the signals for. This document describes ways of looking up companies within DSL expressions.

Companies can be retrieved in two ways:

  1. Directly, by specifying company or tag identifiers.

  2. Indirectly, through company relationships.

After retrieving companies you have a CompanyGroup. To get one or more time series, another function has to be called on this object in order to retrieve a signal for each of the companies. See the examples below for various use cases.

class CompanyGroup
sum(signal, cap, has_values)

Evaluates the signal for each of the companies in the group and returns the sum.

Parameters
  • signal – The signal to evaluate for each of the companies in the group.

  • cap (int) – The maximal number of companies to sum this signal over.

  • has_values (bool/float) – Whether to require the signal to have values for the companies we sum over. This can either be a boolean to indicate whether we require at least one value, or a number between 0 and 1 to indicate the ratio of points in the period which must have values.

Returns

The sum of the given signal, evaluated for each of the companies in the group

mean(signal, cap, has_values)

Evaluates the signal for each of the companies in the group and returns the mean.

Parameters
  • signal – The signal to evaluate for each of the companies in the group.

  • cap (int) – The maximal number of companies to average this signal over.

  • has_values (bool/float) – Whether to filter out companies without values, same as in the sum function.

Returns

The arithmetic mean of the given signal, evaluated for each of the companies in the group.

retrieve(signal, cap, has_values)

Retrieves the given signal for each of the companies in the group. The time series are not aggregated, so that the individual time series can be displayed.

Parameters
  • signal – The signal to evaluate for each of the companies in the group.

  • cap (int) – The maximal number of companies to retrieve this signal for.

  • has_values (bool/float) – Whether to filter out companies without values, same as in the sum function.

Returns

One time series for each company in the group, containing the given signal evaluated for that company.

Direct lookup

Usage

company(*company_id)

Retrieves a company by a unique company identifier. Specify multiple company identifiers to retrieve multiple companies.

Parameters

company_id (str) – Unique identifier for a company. This can be either company name, ISIN or ticker code.

tag(*tag_id)

Retrieves companies by tag id. If you specify multiple identifiers, you only get those companies that have all of the given tags.

param str tag_id

Unique identifier for a tag. This can be either a tag name or a tag id.

Examples

To get the stock price of Microsoft and Alphabet, use:

company("microsoft", "alphabet").retrieve(close_price)

To get the stock price for companies on Nasdaq within the ‘automotive services’ RBICS sector, use:

tag("nasdaq", "automotive services").retrieve(close_price)

To get the stock price for companies in a tag you created yourself, use:

tag("your tag name").retrieve(close_price)

Company set operations

Standard set operations are provided through the keywords union, intersection and subtract for building new company sets.

Usage

union(company_set_1, company_set_2, ..., company_set_n)

Gives the set of companies where each company is in any of the sets company_set_1, company_set_2, …, company_set_2.

intersection(company_set_1, company_set_2, ..., company_set_n)

Gives the set of companies where each company is in all the sets company_set_1, company_set_2, …, company_set_n.

subtract(company_set_1, company_set_2)

Gives the set of companies where each company is in company_set_1 but not in company_set_2.

Examples

To get the stock price for both Microsoft and the companies on Nasdaq within the ‘automotive services’ RBICS sector, use:

union(company("microsoft"), tag("nasdaq", "automotive services")).retrieve(close_price)

To get the stock price for companies in “auto retail” which are not listed on NASDAQ, use:

subtract(tag("auto retail"), tag("NASDAQ")).retrieve(close_price)

To get the stock prices of “auto retail” in the Oslo, Stockholm or Copenhagen exchanges, use:

intersection(tag("auto retail"), union(tag("Oslo Exchange"), tag("NASDAQ OMX Stockholm"), tag("NASDAQ OMX Copenhagen"))).retrieve(close_price)

Company set transformations

Various indices and normalizations can be computed on a set of companies.

CompanyGroup.equal_weight_return_index(signal, return_days)

For all the companies in the CompanyGroup compute an equal weighted return index when the signal is a price.

param signal

The, typically, price signal used to compute the returns

param return_days

Number of days to compute the return over.

CompanyGroup.weighted_return_index(signal, weight_signal = MarketCap, return_days)

For all the companies in the CompanyGroup compute a weighted return index when the signal is a price.

Parameters

signal – The, typically, price signal used to compute the returns

CompanyGroup.equal_betsize_returns(signal, return_days)
national_weighted_total_return_index(signal)
weighted_total_return_index(signal)