My understanding is that it works like this:
The value of your shares is the total amount that they cost you to purchase and should be listed on your statement. If you do not sell all of one stock, what you retain is worth the percentage of what you kept. What you sold is worth the balance. Your statement should break out the value of each stock by symbol.
For instance: You own 100 shares of stock AAA and 500 shares of stock BBB. Stock AAA has a book value (total amount paid, over several purchases) of $1000 and a market value of $2000. Stock BBB has a book value of $1000 and a market value of $2500. You want to sell 50 shares of AAA and 100 shares of BBB. You get the market price for both.
The book value of AAA retained is $500. The AAA you sold had a book value of $500 and you recieved $1000 for it, so your capital gain on the sale of that stock is $500.
The book value of BBB retained is $800. The BBB you sold had a book value of $200 and you recieved $500 for it, so your capital gain on the sale of that stock is $300.
Total reportable capital gain is $800.
The book value is based on the average price paid per share at the time of the last purchase, not the actual price paid at the time of any one of several purchases of the same stock over time.
Market value on the statement is the last closing price of that stock on the day of (or day before) the statement date. You may be able to sell for more, or end up selling for less, depending on the floor you set for the sale of the stock.
If you have a financial advisor, he can probably explain this a lot better than I can - you should talk to him/her before you sell. If you don't have an advisor, you can always talk to someone at the brokerage firm you use, or even at your bank, or your accountant. If you're going to be doing much investing, it might be worth your while to start using a Personal Financial Advisor. Ask where you invest, or get a referral from someone you know, or from your bank. It's worth the money!