weight_by_1_slash_signal#

API documentation for tradeexecutor.strategy.weighting.weight_by_1_slash_signal Python function.

weight_by_1_slash_signal(alpha_signals)[source]#

Use 1/signal weighting system to generate portfolio weightings from the raw alpha signals.

  • All signals are weighted 1/signal

  • Higher the signal, smaller the weight

  • E.g. volatility weighted (more volatility, less alloaction)

Example:

alpha_model = AlphaModel(timestamp)

available_pairs = get_included_pairs_per_month(input)
top_pairs = available_pairs[0:parameters.max_pairs_per_month]

assets_chosen_count = 0

for pair in top_pairs:

    volatility = indicators.get_indicator_value("volatility", pair=pair)
    if volatility is None:
        # Back buffer has not filled up yet with enough data,
        # skip to the next pair
        continue

    if volatility >= parameters.minimum_volatility_threshold:
        # Include this pair for the ranking for each tick
        alpha_model.set_signal(
            pair,
            volatility,
        )
        assets_chosen_count += 1
Parameters:

alpha_signals (Dict[int, float]) –

Return type:

Dict[int, float]