It's pretty clear to me what you want to do, but it's not at all clear to me what you want from us. You asked about an algorithm. A sensible algorithm would be pretty illusory, because the number of factors that affect trade and its success or failure are variable and often not logical but rather politically emotional. However, if you're going to implement the following basically good concept:
You should give more thought to what you can and can't export. In the 1300s to 1500s, beer, for instance, certainly was one of the items you wouldn't export. Beers and ales of that era spoiled within a few days' time. Not only was refrigeration limited to what a beer cellar could provide, but the use of effective ingredients - particularly hops - that stabilized and helped preserve the brew were little known.