question

Upvotes
Accepted
4 0 0 3

EOD Implied volatility of equity stock options

I tried to follow the tutorial https://developers.refinitiv.com/en/api-catalog/refinitiv-tick-history/refinitiv-tick-history-rth-rest-api/tutorials#rest-api-tutorial-7-on-demand-end-of-day-extraction in python and managed to retrieve the field list for EOD data but i don't see any fields to retrieve the implied volatility.

Is is possible ?

tick-history-rest-apipricingvolatility
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
38.1k 71 35 53

Refer to DATA DICTIONARY - CUSTOM REPORTING FOR TICK HISTORY 11.3, the implied volatility fields are available in the Tick History Time and Sales report template.

  • Quote - Ask Implied Volatility
  • Quote - Bid Implied Volatility
  • Quote - Implied Volatility
  • Trade - Implied Volatility
       {
            "Code": "THT.Quote - Ask Implied Volatility",
            "Name": "Quote - Ask Implied Volatility",
            "Description": "Expected ask volatility that the market is pricing into the option, where ask volatility is the measure of the rate and magnitude of the change in the underlying instrument's ask price",
            "FormatType": "Number",
            "FieldGroup": "Quote"
        },
        {
            "Code": "THT.Quote - Bid Implied Volatility",
            "Name": "Quote - Bid Implied Volatility",
            "Description": "Expected bid volatility that the market is pricing into the option, where bid volatility is the measure of the rate and magnitude of the change in the underlying instrument's bid price",
            "FormatType": "Number",
            "FieldGroup": "Quote"
        },
        {
            "Code": "THT.Quote - Implied Volatility",
            "Name": "Quote - Implied Volatility",
            "Description": "Expected volatility that the market is pricing into the option, where volatility is the measure of the rate and magnitude of the change in the underlying instrument's price",
            "FormatType": "Number",
            "FieldGroup": "Quote"
        },

        {
            "Code": "THT.Trade - Implied Volatility",
            "Name": "Trade - Implied Volatility",
            "Description": "Expected volatility that the market is pricing into the option, where volatility is the measure of the rate and magnitude of the change in the underlying instrument's price",
            "FormatType": "Number",
            "FieldGroup": "Trade"
        },

To extract Tick History Time and Sales data, please refer to REST API Tutorial 4: On Demand tick data extraction.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
4 0 0 3
@jirapongse.phuriphanvichai

Thank you, but it seems a little inconvenient to go though the tick data endpoint when i just need the EOD data. I used to use the EOD Realtime on TRTH v1 via the GUI, is there an equivalent here to retrieve the EOD needed to build an equity volatility surface on a stock (for each option ric, i need the bid/ask close, settlement price and the volatility at the end of day) ?

Here is the python code i have at this moment (i removed my password and username):

import requests, json
from requests import Request, Session
from collections import OrderedDict
import pprint as pp
import pandas as pd

class TRTH:
    def __init__(self):
        self._auth_token = self.get_auth_token()
        
    def get_auth_token(self):
        urlGetToken = 'https://hosted.datascopeapi.reuters.com/RestApi/v1/Authentication/RequestToken'
        header = {'Content-Type': 'application/json'}
        body = json.dumps({'Credentials':{'Password':'#######','Username':'#######'}})
        response = requests.post(urlGetToken, body, headers=header)
        return response.json()['value']
    
    def resolve_historical_optionchain(self, chain, start_date, end_date):
        url = 'https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/HistoricalChainResolution'
        header = {'Content-Type': 'application/json', 'Authorization': 'Token ' + self._auth_token }
        body = json.dumps({'Request' : {'ChainRics': [chain], 'Range':{'Start':start_date, 'End':end_date} } } )
        response = requests.post(url, body, headers=header).json()['value'][0]['Constituents']
        output_rics = [{'Identifier':ric['Identifier'], 'IdentifierType':ric['IdentifierType']} for ric in response]
        return output_rics[0], output_rics[1:]
    
    def retrieve_historical_ref_data_fields(self):
        url = "https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/GetValidContentFieldTypes(ReportTemplateType=ThomsonReuters.Dss.Api.Extractions.ReportTemplates.ReportTemplateTypes'HistoricalReference')"
        header = {'Content-Type': 'application/json', 'Authorization': 'Token ' + self._auth_token }
        body = json.dumps({})
        response = requests.get(url, body, headers=header).json()['value']
        return response
    
    #https://developers.refinitiv.com/en/api-catalog/refinitiv-tick-history/refinitiv-tick-history-rth-rest-api/tutorials#rest-api-tutorial-10-on-demand-histo-reference-extraction
    def retrieve_historical_ref_data(self, rics, fields, start_date, end_date):
        url = 'https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/Extract'
        header = {'Content-Type': 'application/json', 'Authorization': 'Token ' + self._auth_token }
        body = json.dumps(
            {
                "ExtractionRequest": {
                    "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.HistoricalReferenceExtractionRequest",
                    "ContentFieldNames": fields,
                    "IdentifierList": {
                        "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
                        "InstrumentIdentifiers": rics,
                        "ValidationOptions": {"AllowHistoricalInstruments": True},
                        "UseUserPreferencesForValidationOptions": False
                    },
                    "Condition": {
                        "ReportDateRangeType": "Range",
                        "QueryStartDate": start_date,
                        "QueryEndDate": end_date
                    }
                }
            }
        )


        response = requests.post(url, body, headers=header)
        try:
            response = response.json()['value']
        except KeyError:
            print(response, response.text)
        return response
    
    def retrieve_historical_eod_data_fields(self):
        url = "https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/GetValidContentFieldTypes(ReportTemplateType=ThomsonReuters.Dss.Api.Extractions.ReportTemplates.ReportTemplateTypes'ElektronTimeseries')"
        header = {'Content-Type': 'application/json', 'Authorization': 'Token ' + self._auth_token }
        body = json.dumps({})
        response = requests.get(url, body, headers=header).json()['value']
        return response


trth = TRTH()
date = '2018-02-27'
underlying_ric, options_rics = trth.resolve_historical_optionchain(chain='0#DTEGn*.EX', start_date=date, end_date=date)
pp.pprint(underlying_ric)
#pp.pprint(options_rics)
#print(pd.DataFrame(data=underlying_ric).head())


#pp.pprint(trth.retrieve_historical_ref_data_fields())
ref_data = trth.retrieve_historical_ref_data(rics=options_rics, fields=['Strike Price', 'Expiration Date', 'Exercise Style', 'Put Call Flag'], start_date=date, end_date=date)
print(pd.DataFrame(data=ref_data).head())


pp.pprint(trth.retrieve_historical_eod_data_fields())


### Retrieve bid, ask, settlement price, implied vol at EOD for each option rics of the option chain
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
13.7k 26 8 12

@Arthur Pham,

The DATA DICTIONARY - CUSTOM REPORTING FOR TICK HISTORY 11.3 is your best tool to determine what templates will deliver what data fields. If you filter the field name column to display only those that contain the word Volatility, you will see that only the Tick History Time and Sales template delivers what you need. You will therefore have to make a separate request for that.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea