Each item in the game has a base 'commerce' value which, in conjunction with a player's ego modifier, is used to determine the item's buy and sell prices while trading. Note that it is the player's ego modifier, and not their actual ego stat, which controls trading prices. The ego modifier, as with all modifiers, can be found in parentheses to the right of its associated stat on the status screen, and will increment by 1 every time its associated stat goes up by 2. This means that trading prices are only changed upon reaching even-number levels of ego, so players who only wish to use ego for trading purposes may prefer to create characters with an even ego stat.
A player with a 0 ego modifier will sell items to NPCs at 35% of their commerce value. For each level above 0, players will sell items for an additional 7% of the commerce value (42% at +1, 49% at +2, ect), up to a 95% maximum at 34 ego. Similarly, if a player has a negative ego modifier, then each level below 0 will reduce the sell percentage by 7%. This means the exact formula for an item's selling price is Commerce Value * (0.35 + 0.07 * Ego Modifier) up to a maximum of Commerce Value * 0.95.
The price at which a player buys items from NPCs is a bit more confusing, but follows a very similar formula. At an ego modifier of 0, NPCs will always sell items at a price such that the commerce price is 35% of the selling price. For example, if the commerce price of an item was 35 drams, then an NPC would sell the item for 100 drams, since 35 is 35% of 100. If the item's commerce value was 70 drams, it would sell for 200 drams, ect. Put another way, at 0 ego modifier players sell to NPCs at Commerce Value * 0.35, and buy from NPCS at Commerce Value / 0.35. For each level above 0 ego modifier, this percentage goes up by 7 (up again to a maximum of 95%), and for each level below 0 it goes down 7%. Thus the exact formula for an item's purchasing price is Commerce Value / (0.35 + 0.07 * Ego Modifier) up to a maximum of Commerce Value / 0.95.
The main take-away should be that the price to sell an item to an NPC goes up at a constant rate, but the price to buy from an NPC goes down roughly as 1 / Ego Modifier. This means players with very low egos benefit greatly from small increases to their ego when buying goods, while players with very high egos shouldn't notice much of a price difference from the same ego increase.