Thank you Ghpstage, that was exactly what I was looking for. Now I can look up the calculations of for AI_getEnemyPeacetimeTradeValue and AI_getEnemyPeacetimeTradeValue.
Interesting to see that there is a decay on this.
The calculations for those specific functions are found in CvDeal.cpp. In themselves they are quite simple, the total of all things traded to a worst enemy while at peace with the worst enemy, and the total given when begged/demanded under the same circumstances. It does take into account additional value from ongoing trades (OB, resources, GPT etc).
The problem is that those functions take their values from the same valuation functions that determine the cost in trades, which civics and religions the AI will use among other things, and are they themselves tied to a number of other functions many of which haven't been publicly worked out yet.
Everything tradeable has a value, (capitulation/vassaling has a value of 0 though!) so if you intended to track it through the game you would need to take into account when you changed religions, civics, accepted a DoW request, Opened Borders, traded techs etc etc etc. Some of these would be relatively easy to follow, but would be very time consuming, some values (e.g. that of techs and maps), could only be found indirectly, others, as mentioned above methods of calculating haven't even been formulated yet, and some may be incalculable from ingame information alone!
I have an ongoing effort to find out how trade items are evaluated linked in my sig. It has ground to a halt for the time being, mostly due to a lack of time, but I have also hit
major roadblocks on many fronts. Much of what i'm certain of in there had already been done before too!
Though it wouldn't even cover your problem in its entirity as it doesn't cover the ongoing value from CvDeal.cpp as its currently aimed at tackling the costing of things.