The last traded quantity (LTQ) of a financial instrument is the quantity that was traded the last time an order was executed for that instrument. This data is dynamic in nature as it may change continuously during the live trading hours. This recipe demonstrates how to fetch the LTQ of a financial instrument.
Getting ready
Make sure the broker_connection and instrument1 objects are available in your Python namespace. Refer to the Technical requirements section of this chapter to set up broker_connection. Refer to the Attributes of a financial instrument recipe of this chapter to set up instrument1.
How to do it…
Fetch and print the LTQ of instrument1:
>>> ltq = broker_connection.get_ltq(instrument1)
>>> print(f'Last traded quantity: {ltq}')
We get the following output (your output may differ):
Last traded quantity: 19
How it works…
The get_ltq() method of the BrokerConnectionZerodha class fetches...