Stock Profit Calculator
Calculate profit, loss, and return on investment for stock trades.
About this tool
A stock profit calculator is an essential tool for investors and traders who want to track the performance of their stock transactions. Whether you've just made a trade or are analyzing a completed investment, this calculator helps you quickly determine your profit or loss, return on investment (ROI), and other key metrics by simply entering your purchase price, selling price, and number of shares. Understanding exactly how much you gained or lost on each trade is crucial for evaluating your investment strategy and building a portfolio that aligns with your financial goals.
To use the calculator, enter your initial investment details—the price you paid per share, the price you sold at, and the quantity of shares traded. The tool instantly calculates your gross profit or loss, ROI percentage, and other important performance metrics. This makes it simple to review individual trades, compare investment outcomes, and identify which trades performed well and which ones to learn from. Whether you're a day trader managing multiple positions or a long-term investor reviewing your portfolio, this calculator helps you understand the real impact of each decision you make in the market.
Frequently Asked Questions
Code Implementation
def stock_profit(
shares: float,
buy_price: float,
sell_price: float,
buy_fee: float = 0,
sell_fee: float = 0
) -> dict:
"""Calculate stock trade profit/loss."""
total_cost = shares * buy_price + buy_fee
total_proceeds = shares * sell_price - sell_fee
profit = total_proceeds - total_cost
pct_return = (profit / total_cost) * 100 if total_cost > 0 else 0
return {
"total_cost": total_cost,
"total_proceeds": total_proceeds,
"profit": profit,
"pct_return": pct_return,
"fees_paid": buy_fee + sell_fee,
}
# Example
result = stock_profit(
shares=100,
buy_price=50.00,
sell_price=65.50,
buy_fee=4.95,
sell_fee=4.95
)
print(f"Total Cost: ${result['total_cost']:,.2f}")
print(f"Total Proceeds: ${result['total_proceeds']:,.2f}")
print(f"Profit/Loss: ${result['profit']:,.2f}")
print(f"Return: {result['pct_return']:.2f}%")
print(f"Fees Paid: ${result['fees_paid']:,.2f}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.