Interactive Cost Tracking

Average Cost Basis Visualizer

Track your investment cost basis over time with interactive charts. Enter transactions manually or upload CSV/JSON files to visualize how your average cost changes with each trade.

Position Settings

$

Add Transaction

Position Summary - AAPL

Total Shares
150
Current position
Average Cost
$151.29
Per share
Total Cost Basis
$22,693.06
Investment in position
Current Value
$27,750.00
At $185.00/share
Unrealized P&L
+$5,056.94
+22.28%
Realized P&L
+$2,468.11
From closed trades
Break-Even Price
$151.29
To recover cost basis

Cost Basis History

$222.00$166.50$111.00$55.50$0
Current: $185.00
Jan 15Mar 20May 10Jul 25Sep 15
Average Cost
Buy Transaction
Sell Transaction
Current Price

Transaction History

DateTypeSharesPriceFeesTotalAvg Cost AfterAction
1/15/2024BUY100$150.00$9.99-$15,009.99$150.10
3/20/2024BUY50$165.00$9.99-$8,259.99$155.13
5/10/2024SELL30$180.00$9.99+$5,390.01$155.13
7/25/2024BUY75$145.00$9.99-$10,884.99$151.29
9/15/2024SELL45$190.00$9.99+$8,540.01$151.29

What is Average Cost Basis?

Average cost basis is the average price you paid per share of a stock, including any transaction fees or commissions. It is calculated by dividing your total investment cost by the total number of shares you own. This metric is essential for tracking investment performance and calculating capital gains or losses when you sell shares.

When you make multiple purchases of the same stock at different prices (a strategy known as dollar-cost averaging), your average cost basis changes with each transaction. Understanding your average cost helps you make informed decisions about when to buy more shares or when to sell for a profit.

How to Use This Average Cost Basis Visualizer

  1. Enter Your Stock Symbol: Input the ticker symbol of the stock you want to track (e.g., AAPL, MSFT, GOOGL).
  2. Set Current Market Price: Enter the current market price to calculate unrealized gains or losses.
  3. Add Transactions: Enter each buy or sell transaction with the date, number of shares, price per share, and any fees.
  4. Import Data (Optional): Upload a CSV or JSON file with your transaction history for bulk entry.
  5. Analyze Results: View your average cost per share, total cost basis, unrealized P&L, and realized P&L from closed trades.
  6. Visualize History: The interactive chart shows how your average cost changed over time with each transaction.

Understanding Cost Basis Calculations

The average cost basis is calculated using this formula:

Average Cost = Total Cost Basis ÷ Total Shares Owned

For example, if you bought 100 shares at $150 and then 50 more shares at $165 (with $10 fees each):

  • First purchase: 100 × $150 + $10 = $15,010
  • Second purchase: 50 × $165 + $10 = $8,260
  • Total cost basis: $15,010 + $8,260 = $23,270
  • Total shares: 150
  • Average cost: $23,270 ÷ 150 = $155.13 per share

Why Track Your Cost Basis?

Tax Reporting

Accurate cost basis is required for calculating capital gains and losses on your tax returns.

Performance Tracking

Know your true return on investment by comparing current price to your actual cost basis.

Dollar-Cost Averaging

Visualize how regular investing at different prices affects your overall cost basis.

Sell Decisions

Make informed decisions about when to sell by knowing your break-even price.

Cost Basis Methods Explained

There are several methods for calculating cost basis when selling shares. This tool uses the average cost method, which is the most common for mutual funds and is accepted by the IRS for stocks. Other methods include:

  • First In, First Out (FIFO): Assumes the first shares purchased are the first sold.
  • Last In, First Out (LIFO): Assumes the most recently purchased shares are sold first.
  • Specific Identification: You choose which specific shares to sell.
  • Average Cost: Uses the average price of all shares owned (used by this tool).

Frequently Asked Questions

What is the difference between cost basis and book value?

Cost basis is the total amount you paid for your shares, including commissions and fees. Book value is an accounting term that refers to a company's net asset value. For individual investors, cost basis is the relevant metric for tracking investment performance and tax purposes.

How do stock splits affect my cost basis?

Stock splits do not change your total cost basis, but they do change your cost per share. For example, in a 2-for-1 split, your number of shares doubles while your cost per share is halved. Your total investment remains the same.

Should I include dividends in my cost basis?

If you reinvest dividends to purchase additional shares, those purchases should be included in your cost basis calculations. The dividend amount becomes part of your investment cost for those new shares.

How do I track cost basis for multiple accounts?

You should track cost basis separately for each account, as tax treatment may differ between taxable brokerage accounts, IRAs, and 401(k)s. This tool allows you to export your data and manage multiple positions independently.

Is this tool accurate for tax purposes?

This tool provides estimates using the average cost method. For official tax reporting, always verify your cost basis with your broker's records and consult a tax professional for complex situations involving wash sales, corporate actions, or inherited shares.

Track Your Investments Smarter with Automation

Now that you understand your cost basis, take your portfolio management further. Use Pineify to create custom Pine Script indicators that track your entry points and alert you when stocks hit your target prices.