FactSet Tick History API

  • SECTIONS
  • Overview
  • API Definition
  • API Documentation
  • Notebooks
  • Code Snippet
  • Changelog
Overview

FactSet’s Tick History provides cost-effective access to global exchange data. Proprietary technology normalizes over 200 global exchanges. Asset types integrated include equities, futures, options, fixed income, mutual funds, ETFs, indices, commodities, and FX rates.

The API generates output files with data based on client-specified request body for Level 1 Tick History data. The request body include universe specification and date ranges for which the data will be generated. When the API request with specified request body has been completed, the output files will be made available back to the users through a secure URL to the location where the files are stored. Therefore, this API has several endpoints (i) Create files (ii) Check status (iii) Get files.

For large universes and date ranges the output files will be chunked based on size (each file will be maximum of 128MB) and multiple secure links will be returned by the get endpoint for the various files. Each secure link will be valid for 10 minutes. The user can request data from 2012-01-01 to the current date. Please note it is best practice to include multiple IDs per each create files request body for clients interested in larger universes. For additional details surrounding best practices, please refer to FactSetTickHistory_API_V2.0A documentation.

Please make sure, you should be making smaller historical requests via API, ideally 6 - 12 months history for each request to get quicker response times.

Additionally, there is the coverage endpoint which returns coverage details for Tick History Level 1 data based upon client-specified input parameters. The input parameters include tickers or ISINs and exchange code.

Introduced Minute bars endpoint which returns minute intervals of trade data for Tick History Level 1 based upon client-specified input parameters.

Note: This API will be mentioned as end-of-day Tick History for ease of understanding.

Sandbox Data Availability:

/level1/files/create data available from 2021-01-01 to 2021-01-31.

Available IDs is limited to:

  • US Equity - IBM-USA, F-USA, AAPL-USA, GOOG-USA
  • AUS - CBA-AUS, BHP-AUS
  • LSE - HSBA-LON, VOD-LON
  • Tokyo - 7203-TKS, 4307-TKS
  • Swiss - NESN-SWX, COTN-SWX
  • Singapore - J36-SES
  • Hong Kong - 700-HKG

/level1/files/minute-bars/create data available from 2023-08-01 to 2024-01-31.

Available IDs is limited to:

  • IBM-USA
  • AMZN-USA
  • FDS-USA
  • MSFT-USA
  • AAPL-USA
  • TSLA-USA
  • CL00-USA
  • ES00-USA
  • NQ00-USA
API Definition
Notebooks
Tick History API V2- Getting Started
Tick History API V2-Minute bars-Getting Started
Code Snippet
Tick_History_V2_MinuteBars_snippet
import requests
import json
import time
import os
from urllib.parse import urlparse
import pandas as pd
pd.set_option("display.max_rows", None)  # Display all rows
pd.set_option("display.max_columns", None)

from fds.sdk.utils.authentication import ConfidentialClient # To install, please use pip install fds.sdk.utils

import fds.sdk.FactSetTickHistory # To install, please use pip install fds.sdk.FactSetTickHistory==0.31.0
from fds.sdk.FactSetTickHistory.api import level_1_api
from fds.sdk.FactSetTickHistory.models import *
from dateutil.parser import parse as dateutil_parser
from pprint import pprint
from pytz import timezone

#configuration = fds.sdk.FactSetTickHistory.Configuration(
#    fds_oauth_client=ConfidentialClient('TH-config.json')
#)

output_dir = r'C:\Users\xxxx'


configuration = fds.sdk.FactSetTickHistory.Configuration(
     username='USERNAME',
     password='API-KEY'
)

with fds.sdk.FactSetTickHistory.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = level_1_api.Level1Api(api_client)

    min_request = MinRequest(
        data=MinutesbarRequestBody(
            tickers=Tickers(["FDS"]),
            factset_exchange_code=FactsetExchangeCode("USA"),
            date_time_range=DateTimePeriodMin(
                start=dateutil_parser('2012-01-01T11:00:00Z'),
                end=dateutil_parser('2012-01-30T11:20:30Z')
            ),
            granularity=Granularity("1m"),
            type=Type("trades"),
        ),
    ) # MinRequest | 

    api_response = api_instance.request_minutebars_files(min_request)

    pprint(api_response)

    data = api_response['data']
    # Now, get the 'id' from the 'data' dictionary
    ID = data['id']        

# Level 2 status
status = 'executing'

while(status == 'executing'):
    with fds.sdk.FactSetTickHistory.ApiClient(configuration) as api_client:
        # Create an instance of the API class
        api_instance = level_1_api.Level1Api(api_client)
    
    
        api_response_wrapper = api_instance.get_minutebars_file_status(ID, _check_return_type = False)

        if api_response_wrapper.get_status_code() == 201:
            api_response = api_response_wrapper.get_response_201()
        if api_response_wrapper.get_status_code() == 202:
            api_response = api_response_wrapper.get_response_202()

        pprint(api_response)
    
  
    # Get the 'data' dictionary
    data = api_response['data']
    # Now, get the 'status' from the 'data' dictionary
    status = data['status']
    print("Status:", status) 
    if(status == 'executing'):      
        time.sleep(180)
        
            
with fds.sdk.FactSetTickHistory.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = level_1_api.Level1Api(api_client)

    pagination_limit = 20 
    pagination_offset = 0

    api_response_wrapper = api_instance.get_minutebars_files(ID, pagination_limit=pagination_limit, pagination_offset=pagination_offset, _check_return_type=False)

    if api_response_wrapper.get_status_code() == 200:
        api_response = api_response_wrapper.get_response_200()
    if api_response_wrapper.get_status_code() == 202:
        api_response = api_response_wrapper.get_response_202()

    #pprint(api_response)

    results = pd.DataFrame(api_response.to_dict()['data'])
    
    list_of_files =results.get('listOfFiles')
    list_df = pd.DataFrame(list_of_files)
    pd.set_option("display.max_colwidth", None)
    #display(list_df)
    df_normalized = pd.json_normalize(list_df['listOfFiles'])
    #display(df_normalized)
    
for index, row in df_normalized.iterrows():
    file_url = row['url']
    file_name = row['fileName']
    output_file_path = os.path.join(output_dir, file_name)

    response = requests.get(file_url)
    if response.status_code == 200:
        with open(output_file_path, 'wb') as f:
            f.write(response.content)
        print(f'Downloaded {file_name}')
    else:
        print(f'Failed to download {file_name}')
Changelog

V2.2.0

Summary

  • Version 2.2.0 released on 11th April, 2024

  • Version 2.1.0 released on 1st February, 2024

  • Version 2.0.0 released on 21st August, 2023

  • Version 1.1.0 released on 2nd February, 2023

  • Version 1.0.0 released on 16th March, 2021

Functionality Additions

  • Ability to generate tick history output files with data based on client specified input parameters ie., ticker, iso_code, product, start_date & end_date

  • Added start_time and end_time parameters which uses to fetch the data on particular days in between the timestamps given

  • Added single parameter to get the data in single file

  • Added regionalISOCode parameter to get the required data

  • Ability to provide coverage details for Tick History Level 1 data based upon client-specified input parameters. The input parameters include tickers or ISINs and exchange code.

  • Ability to provide minute bars- trade data for Tick History Level 1 data based upon client-specified input parameters. The input parameters include tickers and exchange code etc.

Changes

  • Changed the server path[v2.0.0]
  • Meta property refinement[v2.0.0]
  • Updated endpoints structure[v2.0.0]
  • Error code refinement[v2.0.0]
  • Removed product parameter from Level1[v2.0.0]
  • Updated request method from GET to POST in Level1[v2.0.0]
  • Removed Level2 endpoints[v2.2.0]

Bug Fixes

  • No bug fixes