---
title: "Patent Maintenance"
description: "Patent Maintenance dataset from United States Patent and Trademark Office."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/united-states-patent-and-trademark-office/patent-maintenance
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/united-states-patent-and-trademark-office/patent-maintenance.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/31%20United%20States%20Patent%20and%20Trademark%20Office/01%20Patent%20Maintenance
modified: 2026-11-27
index: https://www.quantconnect.com/llms.txt
---

# Patent Maintenance

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [United States Patent and Trademark Office](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/united-states-patent-and-trademark-office.md) > Patent Maintenance

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

## Introduction

The Patent Maintenance dataset by the United States Patent and Trademark Office (USPTO) tracks the patent renewals and lapses of US-listed companies. The data covers 2,896 US Equities, starts in April 1985, and is delivered on a weekly frequency. This dataset is created by combining the USPTO maintenance fee records with PatentsView assignee data and mapping each patent owner to its ticker.

This dataset depends on the [US Equity Security Master](https://www.quantconnect.com/datasets/quantconnect-us-equity-security-master) dataset because the US Equity Security Master dataset contains information on splits, dividends, and symbol changes.

For more information about the Patent Maintenance dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/uspto-patent-maintenance).

## About the Provider

The United States Patent and Trademark Office is the agency of the US Department of Commerce that grants patents and registers trademarks. Its mission is to promote innovation by protecting the intellectual property of inventors and businesses.

## Getting Started

The following snippet demonstrates how to request data from the USPTO Patent Maintenance dataset:

```python
ibm = self.add_equity("IBM", Resolution.DAILY).symbol
self._patents = self.add_data(USPTOPatentMaintenance, ibm).symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | April 1985 |
| Asset Coverage* | 2,896 US Equities |
| Data Density | Sparse |
| Resolution | Daily** |
| Timezone | New York |

* The coverage includes all assets since the start date. It increases over time.

** Weekly data we fetch daily.

## Requesting Data

To add USPTO Patent Maintenance data to your algorithm, call the `add_data` method. Save a reference to the dataset `Symbol` so you can access the data later in your algorithm.

```python
class USPTOPatentMaintenanceAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2020, 1, 1)
        self.set_end_date(2021, 1, 1)

        ibm = self.add_equity("IBM", Resolution.DAILY).symbol
        self._patents = self.add_data(USPTOPatentMaintenance, ibm).symbol
```

## Accessing Data

To get the current USPTO Patent Maintenance data, index the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) with the dataset `Symbol`. `Slice` objects deliver unique events to your algorithm as they happen, but the `Slice` may not contain data for your dataset at every time step. To avoid issues, check if the `Slice` contains the data you want before you index it.

```python
def on_data(self, slice: Slice) -> None:
    if slice.contains_key(self._patents):
        data_point = slice[self._patents]
        self.log(f"{self._patents} expired patents at {slice.time}: {data_point.patents_expired}")
```

To iterate through all of the dataset objects in the current `Slice`, call the `get` method.

```python
def on_data(self, slice: Slice) -> None:
    for dataset_symbol, data_point in slice.get(USPTOPatentMaintenance).items():
        self.log(f"{dataset_symbol} expired patents at {slice.time}: {data_point.patents_expired}")
```

## Historical Data

To get historical USPTO Patent Maintenance data, call the `history` method with the dataset `Symbol`. If there is no data in the period you request, the history result is empty.

```python
# DataFrame
history_df = self.history(self._patents, 100, Resolution.DAILY)

# Dataset objects
history_bars = self.history[USPTOPatentMaintenance](self._patents, 100, Resolution.DAILY)
```

For more information about historical data, see [History Requests](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md).

## Universe Selection

To select a dynamic universe of US Equities based on USPTO Patent Maintenance data, call the `add_universe` method with the `USPTOPatentMaintenanceUniverse` class and a selection function.

```python
def initialize(self) -> None:
    self.universe_settings.resolution = Resolution.DAILY
    self.add_universe(USPTOPatentMaintenanceUniverse, self.universe_selection)

def universe_selection(self, data: List[USPTOPatentMaintenanceUniverse]) -> List[Symbol]:
    renewing = [d for d in data if d.net_maintenance_change is not None and d.net_maintenance_change > 0]
    renewing.sort(key=lambda d: d.net_maintenance_change, reverse=True)
    return [d.symbol for d in renewing[:10]]
```

For more information about dynamic universes, see [Universes](https://www.quantconnect.com/docs/v2/writing-algorithms/universes/key-concepts.md).

## Remove Subscriptions

To remove your subscription to USPTO Patent Maintenance data, call the `remove_security` method.

```python
self.remove_security(self._patents)
```

If you subscribe to USPTO Patent Maintenance data for assets in a dynamic universe, remove the dataset subscription when the asset leaves your universe. To view a common design pattern, see [Track Security Changes](https://www.quantconnect.com/docs/v2/writing-algorithms/algorithm-framework/alpha/key-concepts.md#05-Track-Security-Changes).

## Example Applications

The Patent Maintenance dataset enables you to follow how companies manage the patents they already own. Examples include the following strategies:

- Ranking companies by patent renewals against patent lapses
- Detecting a company that suddenly starts letting many of its patents lapse
- Comparing the lapse rate of a company against its sector peers

### Classic Algorithm Example

The following example algorithm buys IBM when its net patent maintenance change rises above its trailing 13-week average. When the change falls below that average, it liquidates the position.

```python
from AlgorithmImports import *
from QuantConnect.DataSource import *

class USPTOAlgorithm(QCAlgorithm):
    '''Example algorithm that trades IBM on its patent maintenance activity.'''

    def initialize(self) -> None:
        self.set_start_date(2020, 1, 1)
        self.set_end_date(2021, 1, 1)
        self.set_cash(100000)

        self._ibm = self.add_equity("IBM", Resolution.DAILY).symbol

        # Add the USPTO patent maintenance data for IBM.
        self._patents = self.add_data(USPTOPatentMaintenance, self._ibm).symbol

        # Track the last 13 weekly net maintenance changes.
        self._net = RollingWindow(13)

    def on_data(self, slice: Slice) -> None:
        points = slice.get(USPTOPatentMaintenance)
        if self._patents not in points:
            return

        point = points[self._patents]
        self.debug(f"{self.time:%Y-%m-%d} expired: {point.patents_expired}, "
                   f"renewed 12yr: {point.maintenance_paid_twelfth_year}")

        if point.net_maintenance_change is None:
            return

        if self._net.is_ready:
            # Buy above the trailing average and liquidate below it.
            average = sum(self._net) / self._net.count
            if point.net_maintenance_change > average and not self.portfolio[self._ibm].invested:
                self.set_holdings(self._ibm, 1)
            elif point.net_maintenance_change < average and self.portfolio[self._ibm].invested:
                self.liquidate(self._ibm)

        self._net.add(point.net_maintenance_change)

    def on_order_event(self, order_event: OrderEvent) -> None:
        if order_event.status == OrderStatus.FILLED:
            self.debug(f"{self.time} - Filled: {order_event.symbol} {order_event.fill_quantity}")
```

## Data Point Attributes

The USPTO Patent Maintenance dataset provides `USPTOPatentMaintenance` and `USPTOPatentMaintenanceUniverse` objects.

### USPTOPatentMaintenance

`USPTOPatentMaintenance` objects have the following attributes:

*Members of `QuantConnect.DataSource.USPTOPatentMaintenance` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.USPTOPatentMaintenance&language=python*

### USPTOPatentMaintenanceUniverse

`USPTOPatentMaintenanceUniverse` objects have the following attributes:

*Members of `QuantConnect.DataSource.USPTOPatentMaintenanceUniverse` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.USPTOPatentMaintenanceUniverse&language=python*
