<jupyter_start><jupyter_text>Expired FuturesWhen searching for an expired asset, you will need to specify the date range based on the ExpiryDate property.<jupyter_code>import refinitiv.dataplatform as rdp
import pandas as pd
import datetime as dt
import dateutil.relativedelta

rdp.open_desktop_session('Your API Key here')
pd.set_option('display.max_colwidth', 140)
rdp.__version__<jupyter_output><empty_output><jupyter_text>Example - Expired Vodafone futures in the month of Nov 2019.<jupyter_code>rdp.search(
    view = rdp.SearchViews.DerivativeQuotes,
    filter = "TickerSymbol eq 'vod' and ExpiryDate lt 2019-12-01 and ExpiryDate ge 2019-11-01",
    select = "DTSubjectName, ExchangeName, RIC, RCSAssetCategoryLeaf, AssetState, ExpiryDate, UnderlyingQuoteRIC"
)<jupyter_output><empty_output><jupyter_text>Example - Expired Crude Oil Futures in the last year<jupyter_code># Build expiry date range expression
date_1_year_ago = dt.datetime.today() - dateutil.relativedelta.relativedelta(days=365)
date_range = f'ExpiryDate ge {date_1_year_ago.strftime("%Y-%m-%d")} and ExpiryDate lt {dt.datetime.today().strftime("%Y-%m-%d")}'
date_range
rdp.search(
    filter = f"RCSUnderlyingProductName xeq 'Energy' and \
               SearchAllCategoryv3 eq 'Commodities' and \
               RCSAssetCategoryName eq 'Derivative\Future' and RCSUnderlyingProductName eq 'Crude Oil' and \
               ExchangeName xeq 'Source is a Refinitiv Contributor' and {date_range}",
    order_by = "ExpiryDate desc",
    top = 30,
    select = "DTSubjectName, RIC, ExpiryDate, RCSUnderlyingProductLeaf",
)<jupyter_output><empty_output><jupyter_text>Example - Expired Electricity Futures in the last year<jupyter_code>rdp.search(
    filter = f"SearchAllCategoryv3 eq 'Commodities' and \
               RCSUnderlyingProductName eq 'Power' and \
               ExchangeName xeq 'Source is a Refinitiv Contributor' and {date_range}",
    order_by = "ExpiryDate desc",
    top = 30,
    select = "DTSubjectName, RIC, ExpiryDate, RCSUnderlyingProductLeaf"
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09143686502177069, 'fraction_numerical': 0.01644895984518626, 'mean_word_length': 4.858356940509915, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '653443', 'license': 'CNRI-Python', 'n_tokens_mistral': 728, 'n_tokens_neox': 686, 'n_words': 172, 'path': 'Search - Expired Assets.ipynb', 'repo_name': 'Refinitiv-API-Samples/Article.RDPLibrary.Python.Search', 'size': '2067'}