Financial instruments may or may not have a fixed expiry date. If they do, they are last available for trading on their expiry date. Typically, instruments from a cash segment do not expire, whereas derivative instruments (those from the futures and options segment) have a short validity period, and expire on the given date. This recipe shows both types of instruments and how their expiry date can be fetched. An expiry date is static data, meaning it doesn't change during the live market hours.
Getting ready
Make sure the broker_connection and instruments objects are available in your Python namespace. Refer to the Technical requirements section of this chapter to set up broker_connection. Refer to the first recipe of this chapter to set up instruments.
How to do it…
We execute the following steps for this recipe:
- Get an instrument object using broker_connection:
>>> instrument1 = broker_connection.get_instrument('NSE',...