API Endpoint
Stock Profit/Loss
Calculate profit or loss on stock sale including purchase price, sale price, and fees.
Endpoint
Also supports GET with query parameters.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
shares | number | — | Number of shares |
buyPrice | number | — | Average purchase price per share ($) |
sellPrice | number | — | Sale price per share ($) |
fees | number | 0 | Trading fees/commissions ($) |
Request Examples
POST (JSON body)
curl -X POST https://likeoptions.com/api/v1/calculate/stockprofit \
-H "Content-Type: application/json" \
-d '{"shares": 100000, "buyPrice": 50000, "sellPrice": 6}'GET (query parameters)
curl "https://likeoptions.com/api/v1/calculate/stockprofit?shares=100000&buyPrice=50000&sellPrice=6"Response
{
"kind": "stockprofit",
"result": {
"primary": 1234.56,
"secondary": [
{ "label": "Example metric", "value": 100, "format": "money" },
{ "label": "Example percent", "value": 5.5, "format": "percent" }
]
}
}When to Use
- Calculate capital gains/loss
- Plan tax strategy
- Evaluate trade profitability
Error Handling
- 400 Bad Request — Invalid input parameters or missing required fields
- 404 Not Found — Unknown calculator kind
- 429 Too Many Requests — Rate limit exceeded (120 req/hour per IP)
- 413 Payload Too Large — Request body exceeds 16 KB
Related Endpoints
View request examples in JavaScript, Python, cURL, and more →