Signal

class qf_lib.backtesting.signals.signal.Signal(ticker: Ticker, suggested_exposure: Exposure, fraction_at_risk: float, last_available_price: float, creation_time: datetime, confidence: float = 1.0, expected_move: Optional[float] = None, symbol: Optional[str] = None, alpha_model=None)[source]

Bases: object

Objects of this class are used in the portfolio construction process. They are returned by AlphaModels to determine the suggested trend direction as well as its strength

Parameters:
  • ticker (Ticker) – Ticker for which the signal was generated

  • suggested_exposure (Exposure) – A value of type Exposure which describes the move suggested by a specific AlphaModel - SHORT, LONG or OUT

  • fraction_at_risk (float) – A percentage value which determines the risk factor for an AlphaModel and a specified Ticker, may be used to calculate the position size. For example: Value of 0.02 means that we should place a Stop Loss 2% below the latest available price of the instrument. This value should always be positive

  • last_available_price (Optional[float]) – The last price that was available at the time of generating the signal

  • creation_time (datetime) – time when the signal was created

  • confidence (float) – A float value in range [0;1] which describes the trust level for the AlphaModel in a current situation. By default set to 1.0 (maximum)

  • expected_move (float) – A percentage value which determines an expected price change for the upcoming period, may by positive (uptrend) or negative (downtrend) and the range is unlimited

  • symbol (Optional[str]) – Symbol of the ticker (if None, the default value would be computed as the property ticker of the ticker). E.g. for BloombergTicker(“Example Equity”) the symbol should be simply equal to “Example Equity” (so there is no need to provide it). However, in case of e.g. BloombergFutureTicker(“Example”, “Example{} Equity”, 1, 1) the symbol should point to the specific ticker that was used to generate the signal, e.g. “ExampleZ9 Equity”. With ticker + symbol fields we are always able to track the exact ticker and contract that were used to generate a signal.

  • alpha_model ("AlphaModel") – reference to the alpha model that generated the signal