Most authors who have interstellar trade simply make it work like current or medieval trade and ignore the details.
The big problem with realistic interstellar trade is the energy cost. It's certainly possible to have a star without heavier elements. Heavier elements come from previous stars that have died. So stars located away from other stars likely have fewer heavy materials (e.g. iron). The problem is that for the energy cost of bringing iron from another star system, you could transmute lighter elements into iron. Since power comes from fusion of light elements together, power's going to be available anywhere.
So what can be traded? Information (new discoveries, blueprints, schematics, movies, music, etc.). Unique items. This would be similar to medieval times. Although it was possible to ship food locally then. But this is consistent with shipping coffee, tea, spices, etc.
Note that you need FTL to make even that trade work. Trading via generation ships has several problems. First, they're slower than light, so you could have finished your information trade sooner by radio. Second, the exporter has to pay to create them but has no guarantee of a return (also a problem for radio, but less risky). Third, it's hard to motivate future generations by commercial promises made before they were born. So generation ships might bring things to trade, but they are unlikely to be built for the purpose of trading.
So you can have FTL trade similar to the medieval trade between Europe and China, expensive and only good for luxury goods. Given FTL, that seems reasonable. Ships would buy goods in one system and try to trade them in another.
If you really want trade more like modern trade, where we ship out of season vegetables from South America, then you'll probably have to handwave it. The closest to a realistic way to do this is folded space, where you take shortcuts. And even that requires space to be folded in the right way first. If you need to use energy to fold the space in the first place, it's probably a no go again.
The problem with comparative advantage here is that some things just aren't worth trading. If I'm only willing to pay 100 for something that costs 1000 to make, then you can't trade with me. Trading generally requires that shipping costs be less than the worth of the final item. To trade iron from Mars, we'd first have to justify the cost of shipping iron from Mars. Since iron is cheap and easily available on Earth, this seems difficult. It's also worth noting that the asteroid belt is going to be cheaper in energy terms. Less gravity trumps more distance.