The last traded price (LTP) of a financial instrument is the latest price at which an order was executed for that instrument. It is essentially an indicator of the current price at which the instrument can be bought or sold (assuming the liquidity is good). As the description suggests, this data is dynamic in nature and it may change continuously during the live trading hours. This recipe shows how to fetch the LTP 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 LTP of instrument1:
>>> ltp = broker_connection.get_ltp(instrument1)
>>> print(f'Last traded price: {ltp}')
We get the following output (your...