Fractional Share Inventory Management
Published 3 October 2026
Coding — Fractional Share Inventory Management¶
Customers may buy or sell fractional shares, but the external exchange only accepts whole-share transactions. Robinhood therefore maintains a fractional inventory for each stock symbol.
For example, suppose the firm initially holds no shares of a stock. A customer wants to buy 1.35 shares. Since the exchange only sells whole shares, Robinhood may need to acquire enough whole shares externally, give the requested quantity to the customer, and retain the remaining fractional amount as inventory.
A later customer may be served partly or entirely using that existing inventory. The important invariant is that after every order, the firm's inventory for a symbol must satisfy:
If inventory rises above one whole share after a customer sells shares to Robinhood, whole shares should be sent back to the market until only the fractional remainder remains.
Similarly, if inventory would become negative after a customer purchase, Robinhood must obtain enough whole shares from the market to bring inventory back into the valid range.
The prompt referred to this normalization step as flattening the inventory.
Order Representation¶
All numeric values use integers with two implied decimal digits.
For example:
Each order is represented as:
where:
SYMBOLcan be any stock ticker.BUY_OR_SELLisBfor buy orSfor sell.QUANTITYcan represent either shares or a dollar-denominated amount.- Dollar-based quantities are prefixed with
$. CURRENT_PRICEis also represented using two implied decimal digits.
For example input could be:
The first order represents a share-based transaction, while the second represents a dollar-based order that must first be converted into the corresponding share quantity using the supplied price.
Initial Inventory¶
Inventory is provided separately as:
For example:
represents:
- 0.30 shares of MSFT
- 0.65 shares of NVDA
After processing all orders, return the final inventory using the same format and preserving the same symbol ordering as the inventory input.
Follow-Up — Inventory Transaction Log¶
The follow-up asked for a complete inventory-side transaction log in addition to the final inventory. The new result should contain:
- The final inventory state
- An ordered list of inventory transactions generated while processing the customer orders
Each log entry has the conceptual structure [symbol, quantity, side, contra]. The log must be written from Robinhood inventory's perspective. For example, if the inventory first acquires one whole share from the market and then transfers 0.37 shares to a customer, those should appear as two separate ordered inventory transactions with the appropriate side and counterparty.
The follow-up therefore required tracking not just the final fractional balance, but every market-facing and customer-facing inventory movement produced while executing the order sequence.