There are only 2 ways to gain reputation with a faction through trading:
Buy or sell at a station belonging to that faction. It doesn't matter what you are buying or selling (ships, wares, equipment, etc), you will gain a small uptick. This is more noticeable at low levels as it doesn't take much to bump your reputation at that point. However, I'm not sure if buying/selling shares at a stock exchange does the same thing as I haven't done it much.
If you own a station and a member of that race buys from your station, you'll also get a rep bonus. This is why I like to spread space weed and space fuel complexes around the galaxy as they always sell out and are great ways to keep my rep topped off with various factions (even pirates!). Just keep in mind those factories I listed are illegal in most sectors.
Here's what I've found out based on testing:
There seems to be a threshold value before you gain the rep. Its somewhere around 100k credits. Buying 1000 energy cells didn't uptick my reputation at all but buying 10000 did.
The reputation gain is 10 points each time, no matter how much was the transaction.
I stopped gaining reputation once I reached 'friend' status with the Borons. I set my reputation higher (to queen's guard) and then spent 75 million buying an orca but my rep didn't change at all.
To see exactly how much reputation you have with a race, you can download the Universal best buy/sells mod. When you pull that menu up, you'll be able to see exactly how much notoriety you have with a certain race. I used the Borons for my testing since I just happened to be in their space at that time.
Its possible that selling stuff to the Borons via factories and complexes work differently and you can improve rep with them that way, but in the end, 10 rep is a very small tick (only really noticeable when you rep with them is very close to 0). For instance. it takes 333k points to reach maximum (level 10) reputation with a race.