The total volume traded for a financial instrument is the sum total of all quantities that were traded (bought and sold, but counted once) in the day. For example, if trader A buys 10 quantities of stock X from trader B, while trader C sells 20 quantities of the same stock X to trader D, the total volume traded for X would be 10 + 20 = 30. It won't be 10 + 10 + 20 + 20 = 60 because the contribution of the trade to the total volume is considered only once. This data is dynamic in nature and may increase at any moment during the live trading hours.
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 instruments recipe of this chapter to set up instrument1.
How to do it…
Fetch and print the total traded volume for the day of an instrument...