In a model trading system, trades are being performed in integer units of M fixed bundles. Each bundle takes the form Bi = {b1i, b2i,..., bNi} where bji represents the quantity (possibly negative) of product j in bundle i.

There are three price points for each product: retail price to buy RBj, retail price to sell RSj, and wholesale price Wj. For the retail price points there is a quantity available RQBj, RQSj.

There are functions Fi on vectors of product prices that describe how many units of bundle Bi we want to buy or sell at those prices. These are always monotonic in the prices (in the sense that if we are selling a product, we will want to sell the same or more at a higher price, and similarly if we're buying we'll want to buy the same or more at a lower price)

Finally, there are functions Pi on vectors of product prices that describe how much profit will be made trading a unit of bundle Bi at the given prices.

In each round of trading, we are trying to maximize sum(Qi*Pi) subject to the constraints:

1. RQSj <= sum(Qi*bji) <= RQBj (under the convention that RQS has negative sign)

2. Trades between bundles happen at the wholesale price point, other trades happen at retail.

Without the dependency of Qi on the prices, this is of course simple linear integer programming with fixed constraints. With the dependency of Qi on prices, and conversely, the dependence of prices on Qi, I don't really know how to solve this effectively.