The production output. Should be simple. You get 100 units (or something other abstract number like that, game doesn't use tonns)multipled by population according to following table:
Colonies: Multiplier based on population:
- 000-199: x1/6
- 200-299: x2/6
- 300-399: x3/6
- ...
- 600-699: x6/6
Towns: Multiplier based on population:
- 700-5000: x6/6
- 5001-10000: x7/6
- 10001-20000: x8/6
- 20001-40000: x9/6
- 40001-80000: x10/6
- 80001-200000: x11/6
- 200001-...: x12/6
So, its really simple.
The game displays leading producer of goods. It has nothing to do leading trader, and sadly, there is no way to know this, as province assignemnt to COT is calcuated on reload, and doesn't stored in savefile, nor is it possible to reproduce the process, AFAIK (other than knowing the source code, perhaps)
TPs doesn't produce anything.
You can compute real income breakdown (the one shown in history book ingame, ledger). If you want to implement it, tell me and i will check how to do it
Oh, i have an idea. I have a book about population history of the world. While EU is alternative history, demography shouldn't be affecetd that much. So, with some work it could be possible to assign some number to provinces... OTOH, colonies would be completly messed up-in EU it happens way to early. Perhaps its not worth it