{
  "id": "stock",
  "version": "a8a5b07309fc",
  "status": "published",
  "name": "Stock Calculator",
  "question": "What will my stock trade make?",
  "summary": "Works out the profit and return of a stock trade from the shares and the buy and sell prices, or the sell price for a target return or profit, or the shares for a target profit, with commissions.",
  "category": "finance",
  "subcategory": "investing",
  "url": "https://www.acalculator.org/finance/stock-calculator",
  "markdown": "https://www.acalculator.org/finance/stock-calculator.md",
  "kind": "function",
  "method": "Profit = (shares × sell price − commission to sell) − (shares × buy price + commission to buy); return = profit ÷ (shares × buy price + commission to buy) × 100. For a target, the same equation is solved for the sell price or the shares.",
  "assumptions": [
    "Prices are what you type; nothing is looked up.",
    "Commissions are dollar amounts for the whole trade.",
    "Taxes and dividends are not included. This is an estimate, not investment advice."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "find": {
        "title": "Find the",
        "description": "What to work out: the profit of a trade, the sell price that reaches a target, or the shares that make a target profit.",
        "type": "string",
        "enum": [
          "profit",
          "sell",
          "shares"
        ]
      },
      "shares": {
        "title": "Number of shares",
        "description": "How many shares are bought and sold. Fractional shares are fine.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000
      },
      "buy": {
        "title": "Buy price per share",
        "description": "The price paid for each share.",
        "type": "number",
        "x-unit": "USD",
        "exclusiveMinimum": 0,
        "maximum": 10000000
      },
      "sell": {
        "title": "Sell price per share",
        "description": "The price each share is sold for, or the price you expect.",
        "type": "number",
        "x-unit": "USD",
        "minimum": 0,
        "maximum": 10000000
      },
      "goal": {
        "title": "Target",
        "description": "Whether the target is a return in percent or a profit in dollars.",
        "type": "string",
        "enum": [
          "roi",
          "profit"
        ]
      },
      "roi": {
        "title": "Target return",
        "description": "The return you want, as a percent of the total cost.",
        "type": "number",
        "x-unit": "percent",
        "minimum": -100,
        "maximum": 100000
      },
      "profit": {
        "title": "Target profit",
        "description": "The profit you want from the trade, in dollars.",
        "type": "number",
        "x-unit": "USD",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "buyfee": {
        "title": "Commission to buy",
        "description": "Commissions and fees on the purchase, in dollars for the whole trade.",
        "type": "number",
        "x-unit": "USD",
        "minimum": 0,
        "maximum": 1000000
      },
      "sellfee": {
        "title": "Commission to sell",
        "description": "Commissions and fees on the sale, in dollars for the whole trade.",
        "type": "number",
        "x-unit": "USD",
        "minimum": 0,
        "maximum": 1000000
      }
    }
  },
  "outputs": {
    "sell": {
      "label": "Sell price per share",
      "description": "The sell price that reaches the target, after both commissions.",
      "format": "money"
    },
    "shares": {
      "label": "Shares needed",
      "description": "The number of shares that make the target profit at these prices.",
      "format": "number"
    },
    "profit": {
      "label": "Profit",
      "description": "Net sale proceeds minus the total cost. Negative for a loss.",
      "format": "money"
    },
    "roi": {
      "label": "Return",
      "description": "The profit as a percent of the total cost.",
      "format": "percent"
    },
    "cost": {
      "label": "Total cost",
      "description": "Shares × buy price + commission to buy.",
      "format": "money"
    },
    "proceeds": {
      "label": "Net sale proceeds",
      "description": "Shares × sell price − commission to sell.",
      "format": "money"
    },
    "breakEven": {
      "label": "Break-even sell price",
      "description": "The sell price per share with a profit of exactly $0: (total cost + commission to sell) ÷ shares.",
      "format": "money"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "find": "profit",
      "shares": 100,
      "buy": 50,
      "sell": 60,
      "goal": "roi",
      "roi": 20,
      "profit": 1000,
      "buyfee": 0,
      "sellfee": 0
    },
    "outputs": {
      "profit": 1000,
      "roi": 20,
      "cost": 5000,
      "proceeds": 6000,
      "breakEven": 50
    },
    "text": "100 shares bought at $50.00 and sold at $60.00 make $1,000.00, a 20% return."
  },
  "examples": [
    {
      "given": {
        "find": "profit",
        "shares": 100,
        "buy": 50,
        "sell": 60
      },
      "expect": {
        "profit": 1000,
        "roi": 20,
        "cost": 5000,
        "proceeds": 6000,
        "breakEven": 50
      },
      "source": "IRS Publication 550: gain = amount realized minus basis (https://www.irs.gov/publications/p550); hand calculation in content.mdx"
    },
    {
      "given": {
        "find": "sell",
        "shares": 200,
        "buy": 25.5,
        "goal": "roi",
        "roi": 20,
        "buyfee": 5,
        "sellfee": 5
      },
      "expect": {
        "sell": 30.655,
        "profit": 1021,
        "roi": 20,
        "cost": 5105,
        "breakEven": 25.55
      },
      "source": "IRS Publication 550, basis includes the commission to buy and the amount realized is net of the commission to sell (https://www.irs.gov/publications/p550); hand calculation in content.mdx"
    },
    {
      "given": {
        "find": "sell",
        "shares": 40,
        "buy": 80,
        "goal": "profit",
        "profit": 500,
        "buyfee": 1,
        "sellfee": 1
      },
      "expect": {
        "sell": 92.55,
        "roi": 15.620118712902219,
        "proceeds": 3701
      },
      "source": "IRS Publication 550, basis and amount realized (https://www.irs.gov/publications/p550); hand calculation in content.mdx"
    },
    {
      "given": {
        "find": "shares",
        "buy": 12,
        "sell": 15,
        "profit": 1500
      },
      "expect": {
        "shares": 500,
        "roi": 25,
        "cost": 6000
      },
      "source": "IRS Publication 550, gain on a sale (https://www.irs.gov/publications/p550); hand calculation in content.mdx"
    }
  ],
  "sources": [
    "Internal Revenue Service, Publication 550, Investment Income and Expenses: basis and amount realized. https://www.irs.gov/publications/p550",
    "U.S. Securities and Exchange Commission, Investor.gov: Understanding fees. https://www.investor.gov/introduction-investing/getting-started/understanding-fees"
  ],
  "related": [
    "stock-profit",
    "stock-average",
    "crypto-profit",
    "roi",
    "dividend"
  ],
  "changelog": []
}
