how much it costs to bring the goods there?
Is the source planet safe ? And the destination?
How is the availability of the good on the source planet ? How much is the cost going to increase if other traders buy it ?
How is the demand on the destination planet ? Is the market going to be saturated by excessive offer or by other traders ?
5. Other sources
If the transport costs raise the final price by 30%, would the NPC goods be more expensive than the same item taken from a source nearer and maybe unaccesible to the NPC?
I'm not saying the above points aren't manageable, but even the basic economic model looks to me a little more complicated than you think.
Sure! These are all great extensions to the basic algorithm! But surely you can see that they're all easy!
What we will want to do is compute, instead of maximal price differential, maximal "appeal" (this is actually what the engine uses at the moment). The appeal is just a function of several variables that outputs a scalar that represents how favorable the trade is. To compute it, we can take all of the above (and more) into account without a problem!
We already have a graph for calculating distance to various destinations, so you can factor this into the appeal function. Note that we will actually compute travel time, not distance, because that's what matters (but that's also what the pathfinding graph already considers). So we will divide the "appeal" equation by this travel time, so as to turn the computation into a computation of "value per unit time spent on the trade."
Sure! We take the NPC's faction, and look up the source and destination planets' factional disposition towards the NPC's faction. We can, for example, factor this in by multiplying by 1-e^(-k*disposition), where 0 means worst possible disposition, hence, this component will be zero (we never go there), and infinity means best possible disposition, hence, we have no qualms about going to this planet. If the NPC is not associated with a faction, we can do something simpler like take the security rating of the system that the planets lie in.
I contend that this isn't really a factor, since the price will already reflect this.
Again, I contend that it isn't a factor, because the price already reflects it.
5. Other Sources
It's actually an emergent property of the algorithm we've already discussed, not a special case. If we factor in distance, as we did above, then NPCs will be less likely to make a long-distance trade. That means that, if the only source of some good is far away, the supply will be thinner, hence the price higher. So yes, if the player (or an NPC) finds a new source of the good that is closer, they will be in good shape to make a profit! That's part of what makes exploration so appealing. And I think this is a very desirable property (it's no different from real life).
One thing that I want to point out is that, often, implementing the right features results in the emergence of other features. We could probably find a bunch of cool consequences of implementing 1. and 2., but we didn't have to do any extra work to achieve them!
I hope this gives some sense of how easy it is to extend the basic economic model to something complex! If you have other ideas, feel free to throw them out and we can explore the ramifications.