Skip to content

Concurrent Requests

This is a guide to making concurrent requests for this REST API. Depending on your subscription tier, a different amount of threads are allocated to processing your requests as a client on our servers. Below is a table that describes these allocations. Using more threads than these allocations can still improve your performance.

Subscription Tier# of server allocated Threads
FREE1
VALUE1
STANDARD2
PRO4

What are Concurrent Requests?

Making multiple requests at the same time instead of waiting for a response for each request sequentially. This allows the user to improve performance since a large overhead of making a request could be the round trip time. If it takes 100ms to get back a response from Theta Data due to your ping to our servers, then 100ms per request is being wasted waiting for a response. If you make multiple in-flight requests at the same time, this overhead is eliminated and the bottleneck shifts from transit time to server-side, which is what you should aim for when using Theta Data.

Setup

You will need to be familiar with concurrency and multithreadding in the programming language you use. The amount of threads or concurrent requests you make should be equal to the HTTP_CONCURRENCY field in the config file. The default value is 4. The path to the config is printed when you start the terminal.

Pro Tips

  • You should decrease the default HTTP_CONCURRENCY value if you are making multi-day tick-level requests and your machine has under 8GB of RAM or if you are getting out of memory errors.
  • Increasing the HTTP_CONCURRENCY value will cause the terminal to consume more memory.
  • Increasing HTTP_CONCURRENCY will have diminishing returns. We recommend a max value of 4 on low-end machines and 24 on high-end machines.
  • If you have more inflight requests or threads than the HTTP_CONCURRENCY value, the requests might timeout after sometime. It is very important that your inflgiht / concurrent requests match this field.