I would do something like
2024-01-01 opening balances
    equity:start
    ;
    ; Several lots of Apple stock totaling 100 units of stock with average cost basis of $10
    assets:brokerage1:aapl:2022-12-15             20 AAPL @ $8
    assets:brokerage1:aapl:2023-01-20             30 AAPL @ $8
    assets:brokerage1:aapl:2023-09-14             50 AAPL @ $12
    ;
    ; shares of a mutual fund 'XXX' totaling 50 units with average cost basis of $5
    assets:brokerage1:xxx                         50 XXX @ $5
    
(I think people usually track individual lots of stocks, but just average cost of mutual funds.)