---
title: "Key Concepts"
description: "The dividend yield refers to the rate of return an investor earns from holding a stock in the form of dividends."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/dividend-yield/key-concepts
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/dividend-yield/key-concepts.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/24%20Reality%20Modeling/11%20Dividend%20Yield/01%20Key%20Concepts
modified: 2026-11-01
index: https://www.quantconnect.com/llms.txt
---

# Key Concepts

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Reality Modeling > Dividend Yield > Key Concepts

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

Dividends are periodic payments a company makes to its shareholders out of its earnings. The dividend yield refers to the rate of return an investor earns in the form of dividends from holding a stock.

In the context of [Option pricing models](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/options-models/pricing.md), the dividend yield is a critical factor because it affects the value of the underlying stock. When calculating the theoretical price of an Option using these models, the dividend yield is factored into the equation.

## Set Models

To set the dividend yield model for an [Option indicator](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/equity-options/greeks-and-implied-volatility.md), pass a `DividendYieldProvider` as the `dividend_yield_model` parameter.

```python
def initialize(self) -> None:
    # Before creating the indicator, create the set dividend yield model
    # Using DividendYieldProvider will calculate the continuous dividend yield using all dividend payoffs in 1 year
    dividend_yield_model = DividendYieldProvider(symbol.underlying)
    self.iv = ImpliedVolatility(symbol, self.risk_free_interest_rate_model, dividend_yield_model, OptionPricingModelType.BLACK_SCHOLES)
```

To view all the pre-built dividend yield models, see [Supported Models](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/dividend-yield/supported-models.md).

## Default Behavior

For US Equity Options, the default dividend yield model is the [DividendYieldProvider](https://www.quantconnect.com/docs/v2/writing-algorithms/reality-modeling/dividend-yield/supported-models.md#04-Dividend-Yield-Provider-Model), which provides the continuous yield calculated from all dividend payoffs from the underlying Equity over the previous 350 days.

For other Option types, the default dividend yield model is the `DividendYieldProvider`, but it calculates the yield from the dividends of the SPY ETF.

## Model Structure

Dividend yield models must extend the `IDividendYieldModel` interface. Extensions of the `IDividendYieldModel` interface must implement a `get_dividend_yield` method. The `get_dividend_yield` method returns the dividend yield for a given date.

```python
from datetime import date

class CustomDividendYieldModelExampleAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        # Create the dividend yield model.
        dividend_yield_model = MyDividendYieldModel()
        # Add the Option contracts.
        underlying_symbol = self.add_equity('SPY', data_normalization_mode=DataNormalizationMode.RAW).symbol
        strike = 595
        expiry = datetime(2024, 12, 30)
        option = self._add_contract(underlying_symbol, OptionRight.PUT, strike, expiry)
        mirror = self._add_contract(underlying_symbol, OptionRight.CALL, strike, expiry)
        # Add the indicator.
        iv = ImpliedVolatility(option, self.risk_free_interest_rate_model, dividend_yield_model, mirror)

    def _add_contract(self, underlying_symbol, right, strike, expiry) -> Symbol:
        contract_symbol = Symbol.create_option(
            underlying_symbol, Market.USA, OptionStyle.AMERICAN, right, strike, expiry
        )
        self.add_option_contract(contract_symbol)
        return contract_symbol

# Define the custom dividend yield model
class MyDividendYieldModel(DividendYieldProvider):

    def get_dividend_yield(
            self,
            date_or_data: datetime | date | IBaseData,
            security_price: float | None = None) -> float:
        return 0.02
```

## Examples

The following examples demonstrate common practices for implementing a custom dividend yield model.

### Example 1: Fixed Yield

The following algorithm implements a custom dividend yield model with a fixed yield of 2%.

```python
from datetime import date

class CustomDividendYieldModelAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)

        option = self.add_option('MSFT')
        option.set_filter(0, 1, 0, 31)
        self._symbol = option.symbol
        self._deltas = {}
        self._dividend_yield_model = {self._symbol.underlying : MyDividendYieldModel()}

    def on_data(self, data: Slice) -> None:
        chain = data.option_chains.get(self._symbol)
        if not chain:
            return
        expiry = min([x.expiry for x in chain])
        symbols = [x.symbol for x in chain if x.expiry == expiry and x.right == OptionRight.CALL and x.symbol not in self._deltas]
        for symbol in symbols:
            self._deltas[symbol] = self._deltas.get(symbol, self._create_delta_indicator(symbol))

    def _create_delta_indicator(self, symbol: Symbol) -> Delta:
        dividend_yield_model = self._dividend_yield_model.get(symbol.underlying)
        delta = Delta(symbol.value, symbol, self.risk_free_interest_rate_model, dividend_yield_model)
        self.register_indicator(symbol, delta)
        self.register_indicator(symbol.underlying, delta)
        return delta

    def on_end_of_day(self, symbol) -> None:
        delta = self._deltas.get(symbol)
        if delta:
            self.plot('Delta', symbol.value, delta.current.value)

class MyDividendYieldModel(DividendYieldProvider):

    def get_dividend_yield(
            self,
            date_or_data: datetime | date | IBaseData,
            security_price: float | None = None) -> float:
        return 0.02
```
