Vellos, I think you missed the second two tabs of the trade data.
No, that's the data I used; the total gold and total food amounts from the second two tabs. It doesn't add up. For example, on February 28:
Gold that is bid for food in buy offers = 2933
Gold that is asked for food in sell offers = 2284
Food that is bid for gold in sell offers = 7850
Food that is asked for gold in buy offers = 10850
Average price, the real, actual, buy off average price for a single bushel will be Gold Bid in Buys / Food asked in Buys. For sell offers, it will be gold asked in sells / food bid in sells.
Quoted for 100 bushels instead of 1, this yields an average sell price of about 29.096 gold, and an average buy price of 27.032 gold.
But the chart for February 28 says that the average sell price is 28.34, and average buy price is 21.81
The sell price is close, but the buy price is way off. And I've noticed this tracking back to February 8; there does not appear to be a single day wherein the game reported the actual average price for which food was offered for purchase or sale.
The line you posted, Tom,
seems to be the right code, but it is giving a value which, as best I can tell, is simply wrong. Maybe my math is messed up somewhere; it's easy enough to check. I suggest folks get on the market, take out the data, and check it themselves. Maybe you'll find that my math is wrong, but, as best I can tell, the in-game statistics are misreported by a fairly large margin.