With the data in and stored in sensible C# classes, we can start to have some fun - I’ve added in some meta data about the current search item. By checking the lastest history item with the latest but, comparisons can be made about their differences. in this case, the change in price and percentage change.

double _latest = hist.items[hist.items.Count - 1].avgPrice;
double _latestButOne = hist.items[hist.items.Count - 2].avgPrice;

double _change = (_latest - _latestButOne);
double _percentChange = (_change / _latestButOne);

DateTime _latestDate = DateTime.Parse(hist.items[hist.items.Count - 1].date);
TimeSpan _outofDate = (DateTime.Now - _latestDate);

The TimeSpan class is great for this as it can be calculated with a the DateTime class.

We can also display when the latest history was updated - this is where buy/sell order wil come into their own as it is updated much more often than market history.

Links in this post