Python Jupyter Notebook

Tick History Request - Parametrize and Parallelize

    Zoya Farberov
    Developer Advocate

Last Updated: Jan 2026

Introduction

This article will discuss a quick and easy wrapper approach for running parallel Tick History requests.  We are going to use TickHistoryTimeAndSalesExtractionRequest as an example request, while the analogous steps can be used with other Tick History and Datascope Select requests.

The companion example code is a Python Jupyter notebook* and is based on Tick History Python Code Samples*:

With this in mind, let us embark on a little coding voyage.

Approach in Brief

  •  Authentication- token request
  •  Parametrize request (TickHistoryTimeAndSalesRequest)
  •  On Demand extraction request 
    • Define
    • Extraction status polling
    • Extraction notes retrieval
    • Parallelize
  •  Data retrieval and save to disk (includes AWS download)
    • Define
    • Parallelize

* see References section for the links to download example code

Import Required Modules and Define Required Parameters

This includes the definition of a "cookie-cutter" request:

Read Credentials from File

It is not essential how credentials are acquired, they can be entered as input pramterese or hard-coded, most importantly, that we have them at hand, for the required authentication step.

Authentication - Datascope Token Request

Parametrise Our Request

resulting in required requests to be ready to go:

Send On-demand Extraction Request - Define

We define a helper function to issue a request, that can consequently be issued in parallel

Send On-demand Extraction Request - Parallelize

This example code shows 2 requests issued in parallel.  We can issue more requests in parallel, using the same pre-defined helper function.  However, for TickHistoryTimeAndSalesRequest per Tick History REST API User Guide*, at the time of this writing, the number of concurrent processing requests is 2, same as for most other Tick History Templates.  The maximum number of the requests that can be submitted is 50.  

Therefore, per design, we should never submit more then 50 requests - maximum accepted.  If we wish to only submit requests that will be immediately accepted for processing, we should submit 2 requests at a time.  If we prefer to submit more and have some requests awaiting their turn, we can submit up to maximum allowed to be submitted, up to 50 requests.

if we are running in Jupyter notebook, event loop is already running and our tasks are executing in parallel, for example:

all that we need to do is await their completion:

Retrieve Results and Save to File - Define a Helper Function

  • Request the extraction results, using the known jobId
  • Save the compressed data as GZIP
  • Display a few lines of the result

Retrieve Results and Save to File - Parallelize

Now all that is left for us to do is obtain the results: 

that should look something like:

this concludes our discussion for the moment, a good next step is downloading and running the example code listed in References

Request Free Trial

Help & Support

Already a customer?

Office locations

Contact LSEG near you