The historical data of a financial instrument is time-series data for the timestamps in the past. It can be fetched using the Broker API for a given duration. This recipe demonstrates how to set up a broker connection and how to fetch historical data for a financial instrument for the duration of a single day.
Getting ready
Make sure the broker_connection object is available in your Python namespace. Refer to the Technical requirements section of this chapter to learn how to set it up.
How to do it…
Execute the following steps to complete this recipe:
- Fetch the historical data for an instrument:
>>> instrument = broker_connection.get_instrument('NSE',
'TATASTEEL')
>>> historical_data = broker_connection.get_historical_data(
instrument=instrument,
candle_interval='minute',
...