Could be somewhat automated for NPRs if you could come up with some general guidelines for the "AI" as to when if felt it needed more of a mineral or had surplus of a mineral. Essentially it needs to set a "price" for each element to buy and to sell. The price gets higher as the element gets scarcer and lower if supply is high.
A simple method would be to figure how much had been used in all existing construction, and compare to supplies on hand, how much could be mined and how easily it could be obtained. It might also factor in a market location, as goods at a remote trade post are worth less than those at the homeworld.
If market prices could be established, them the AI could easily scan all accessible markets and determine possible cross trades accounting for shipping time, etc. One might even have a ship dedicated to trade runs between given markets. Of course there is always the risk that the market will change while you are in transit.
I tried to lay out an example but I am at work and time is lacking, alas.