{
  "id": "stock-average",
  "version": "30fd80664802",
  "status": "published",
  "name": "Stock Average Calculator",
  "question": "What is my stock average price?",
  "summary": "Computes the weighted average price per share, the total shares, and the total cost of several purchases of the same stock.",
  "category": "finance",
  "subcategory": "investing",
  "url": "https://www.acalculator.org/finance/stock-average-calculator",
  "markdown": "https://www.acalculator.org/finance/stock-average-calculator.md",
  "kind": "function",
  "method": "Average price = Σ(shares × price) ÷ Σ shares.",
  "assumptions": [
    "Each row is one purchase: shares in the first column, price per share in the second.",
    "Fees and commissions are not included unless you add them to the price.",
    "Sales are not counted; enter only purchases."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "buys": {
        "title": "Your purchases",
        "description": "One row per purchase: the number of shares, then the price paid per share.",
        "type": "array",
        "items": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    }
  },
  "outputs": {
    "average": {
      "label": "Average price per share",
      "description": "The total cost divided by the total shares.",
      "format": "money"
    },
    "totalShares": {
      "label": "Total shares",
      "description": "All the shares bought, added up.",
      "format": "number"
    },
    "totalCost": {
      "label": "Total cost",
      "description": "Each purchase’s shares × price, added up.",
      "format": "money"
    },
    "purchases": {
      "label": "Purchases",
      "description": "How many purchases have more than 0 shares.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "buys": "100,50;50,60"
    },
    "outputs": {
      "average": 53.333333333333336,
      "totalShares": 150,
      "totalCost": 8000,
      "purchases": 2
    },
    "text": "Buying 150 shares for $8,000.00 in total is an average of $53.33 per share."
  },
  "examples": [
    {
      "given": {
        "buys": [
          [
            100,
            50
          ],
          [
            50,
            60
          ]
        ]
      },
      "expect": {
        "average": 53.333333333333336,
        "totalShares": 150,
        "totalCost": 8000
      },
      "source": "the old page FAQ: (100 × $50 + 50 × $60) ÷ 150 = $53.33; hand calculation in content.mdx; Internal Revenue Service, Publication 550, Investment Income and Expenses: basis of stock bought at different times and the average basis method. https://www.irs.gov/publications/p550"
    },
    {
      "given": {
        "buys": [
          [
            50,
            12.5
          ],
          [
            25,
            15
          ],
          [
            100,
            9.8
          ]
        ]
      },
      "expect": {
        "average": 11.314285714285715,
        "totalShares": 175,
        "totalCost": 1980
      },
      "source": "hand calculation in content.mdx: (625 + 375 + 980) ÷ 175; Internal Revenue Service, Publication 550, Investment Income and Expenses: basis of stock bought at different times and the average basis method. https://www.irs.gov/publications/p550"
    },
    {
      "given": {
        "buys": [
          [
            10,
            0
          ],
          [
            10,
            50
          ]
        ]
      },
      "expect": {
        "average": 25,
        "totalCost": 500
      },
      "source": "hand calculation in content.mdx: a free share lowers the average; Internal Revenue Service, Publication 550, Investment Income and Expenses: basis of stock bought at different times and the average basis method. https://www.irs.gov/publications/p550"
    },
    {
      "given": {
        "buys": [
          [
            0.5,
            30000
          ],
          [
            0.25,
            40000
          ]
        ]
      },
      "expect": {
        "average": 33333.333333333336,
        "totalShares": 0.75
      },
      "source": "hand calculation in content.mdx: fractional shares, (15,000 + 10,000) ÷ 0.75; Internal Revenue Service, Publication 550, Investment Income and Expenses: basis of stock bought at different times and the average basis method. https://www.irs.gov/publications/p550"
    }
  ],
  "sources": [
    "Internal Revenue Service, Publication 550, Investment Income and Expenses: basis of stock bought at different times and the average basis method. https://www.irs.gov/publications/p550",
    "Weighted arithmetic mean: NIST/SEMATECH e-Handbook of Statistical Methods. https://www.itl.nist.gov/div898/handbook/"
  ],
  "related": [
    "cagr",
    "irr"
  ],
  "changelog": [
    {
      "date": "2026-09-29",
      "note": "Worked examples name a published reference for their rule."
    }
  ]
}
