There are a number of metrics that you can track and the ease of doing so depends on the whether you are designating your closing trades or not.
If you are not designating which shares you are selling (or buying if short), tracking total open cost basis is easy. Purchases are debits and sales are credits. You maintain a running total cost summary (dollars at risk). Dividing that by the number of open shares determines your average cost per share for open positions.
It's a bit more complicated if you are designating which positions are sold. You do the same as above but you have to remove part or all of specific security purchases.
For decades I have done this myself. The core is a pair of 'master' spreadsheets. The first lists the transactions sequentially and the second is closed positions are segregated for tax purposes.
If needed, I use a third spreadsheet for any single underlying that breaks down the P&L of each of the remaining purchases that are open and if options are involved, it tracks them as well. This sounds a lot more daunting then it really is since once you have a functional spreadsheet, it can be copied and used for any security.
On occasion, I have used a professional tax program which handles the tax side of it accurately and completely. It does some positional analysis. But that need has only been for years with heavy trading (like 2008).
I don't know what, if anything is available online that is free and does this. There should be something that manages non designation of shares but I would surmise that there's not going to be much, if anything, available for tracking designated sales.