zerodha / pykiteconnect

The official Python client library for the Kite Connect trading APIs
MIT License
965 stars 462 forks source link

Can the kite API be made faster? #146

Closed tkanhe closed 1 year ago

tkanhe commented 2 years ago

The following images show the comparison between pykiteconnect and Kiteconnect REST-API for 15000 F&O instruments.

Current python client:

Capture1

Creating requests session object:

Capture2

Asynchronous execution:

Capture3

Let me know if it can be improved further.

knadh commented 2 years ago

hm, in your first example, you're making 15,000 HTTP requests, one for each instrument?

tkanhe commented 2 years ago

@knadh no, list (var_name: "opl") of about 490 instruments as there is a limit of 500. var: "op_list" is a list of list of 490x31 instruments, which is being passed to all three examples.

ranjanrak commented 1 year ago

Create requests session by default for connection reuse is available in a new release v4.2.0.

vijaykz commented 1 year ago

Does using the pool make API requests fasters?

vividvilla commented 1 year ago

@vijaykz Ideally yes since there is no overhead to create new connections, do note that if you face any issues then configure pool config - https://github.com/zerodha/pykiteconnect/blob/master/kiteconnect/connect.py#L194