Thats a good question, since it's really impossible to create a Lookup realtionship to OLI.
Next best you could do is to create a Lookup- or Master/Detail-Relationship on Opportunity and add an other custom field (e. g. external Id text(30) ) and store the associated OLI id.
But you won't get many features you usually have for relationships. And you might have to query twice all the time with an WHERE filter to match the association.
You might want to reconsider the second requirement, since for very high quantities you can easily end up with a huge number of custom objects. It will work to a point, but may possibly exhaust your storage limits soon. Expect limit issues for quantities > 2k or 10k or 50k. Introduce an If-statement to prevent huge quantities from polluting your database. If that requirement persists you have to write the logic to maintain the right inventory objects - differently for open and closed opps.