Exercise

It is now time to put our newly-learned skills into practice. Here is a new requirement to build into the Stock class:

  • Sometimes, updates might come out of order and we might get an update for a newer timestamp, followed by an update for an older timestamp. This could be due to random network latency, or due to the fact that sometimes we might get updates from different sources and one might be slightly ahead of the other.
  • The Stock class should be able to handle such cases, and the price attribute should return the latest price as per the timestamp.
  • The is_increasing_trend should also process the latest three prices as per their timestamps.

Try your hand at implementing this requirement. Do not make any changes to the existing interfaces ...

Get Test-Driven Python Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.