# Decision Calculations

## Decision Calculations

#### **Rate of Return Calculation** <a href="#rate-of-return" id="rate-of-return"></a>

Rate of return is always calculated as max profit / max loss for all position types, where max loss is defined as the theoretical risk less any premium received.

```
Assume a credit spread where strike width = $2.00 and credit = $0.50, then

Max profit = 0.5
Max risk = 2.00 - 0.5 = 1.5

Rate of return = 0.5 / 1.5 = 33%
```

#### % Premium Calculation <a href="#percent-premium" id="percent-premium"></a>

The formula for % premium increase/decreased is:

$$
change\_{percent} = \frac {change} {price\_{open}}
$$

where$$change\_{percent}$$is equal to the net `change` in position value divided by the `openPrice` of the position, defined as:

```javascript
let {openPrice, markClose} = position;
let change = markClose - openPrice;
let changePct = change / openPrice * 100;
```

The definition for `markClose` calculations of individual position types can be found [here](https://docs.optionalpha.com/calculations/broken-reference).

#### **Return % Calculation** <a href="#return-calculation" id="return-calculation"></a>

```javascript
let {priceChange, openPrice} = position;
let returnPct = priceChange && openPrice ? priceChange / openPrice : 0;

//where priceChange = position.currentPrice - position.openPrice;
```

Percentage return measures the percentage gain or loss on an asset or portfolio relative to its starting value.

In the example above, the investor earned a $1,250 total dollar return on a $5,000 investment. To calculate the total return in percentage, simply divide the total gains ($1,250) by the starting value ($5,000) = 25%.

<figure><img src="https://cdn.prod.website-files.com/5fba23eb8789c3c7fcfb5f31/67056a07e53311e0da1d60e0_60d3bc7d4410c25409e7ef89_1091622_PercentageReturn_062321.jpeg" alt="Percentage return formula"><figcaption></figcaption></figure>

Total percent return can be a better indicator of return on investment because it shows growth relative to the initial investment.

#### Total P/L

The sum of open and closed P/L.

#### Total P/L %

The total P/L divided by the bot allocation.

#### Day P/L

The current intraday total P/L minus the previous days closing P/L value or $0 if no previous day.

#### Day P/L %

The day P/L divided by the previous day's closing net liquid or bot allocation if no previous day.

#### Closed P/L

The bot's P/L for all closed positions.

#### Win Rate

The bot's percentage of winning trades. Win Rate (win%) = number of wins divided by total number of closed trades.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.optionalpha.com/technical-documentation/calculations/decision-calculations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
