Skip to content
All library documents

Accounting for Entry and Exit Costs in Prediction-Based Trading

Article Quant Q&A · Author: siamii

Summary

The document asks how to adjust a prediction-based trading profit when the strategy sizes exposure in proportion to a signal ranging from short to long. Gross profit is defined as the signal multiplied by the asset’s relative price change. The position is opened when the prediction is made and closed at the next time step, so the question concerns costs on both transactions.

The response proposes subtracting a cost at the opening price and another at the closing price, with the closing cost adjusted for the changed price. This illustrates that net performance must account for turnover at both trade points, rather than deducting a single flat fee from gross profit. The example assumes proportional transaction costs and one opening and closing cycle. It does not discuss alternative fee conventions, bid-ask spread, market impact, slippage, or whether costs should be applied to signed exposure, so the formula depends on the stated trading and cost assumptions.

Key ideas

  • Gross profit is modeled as predicted exposure times relative price movement.
  • A round trip incurs transaction costs at both entry and exit.
  • The exit cost depends on the position value after the price has moved.
  • The proposed adjustment assumes proportional fees and a single trade cycle.
  • Spread, market impact, and other execution costs are outside the discussion.

Tags

Full text
# Add transaction costs to prediction


# Add transaction costs to prediction












An algorithm predicts price movement by some certainty and it invests proportional to the confidence level. Predictions range from -1 to +1, -1 meaning sell for a value of `$1` +1 meaning buy for a value of `$1`. Then the profit is calculated by multiplying the prediction with the relative price movement of the security traded.

Now assume a transaction cost of 0.6%. How does that change the profit the algorithm makes? For now, we only calculate the transaction cost for one cycle, i.e buy or sell once and the next time step sell or buy again in order to realize the profit.

So to clarify. I have two variables `pred` which is a prediction ranging from -1 and +1. I also have `d_price` which is the relative price movement of the security. This can be 0.0003 or -0.002 or something similar. You calculate this by `d_price = (price_t1 - price_t0) / price_t0`

I have this eqution now:

```
profit = pred * d_price
```

The algorithm makes two trades. It makes a trade when it makes the prediction at time step `t0`, then it makes another trade at time step `t1` in order to realize a profit. So if it predicts +0.5 and then the relative price movement is +0.01 then the profit it makes is 0.005.

What I'm asking about is how this changes when there is a transaction cost of `trans=0.006`. The transaction cost if percentage based, meaning if I buy 1 amount, I will receive 0.994 only. Likewise, if I sell 1 amount I will receive price * 0.994

`profit = f(pred,d_price,trans)`

What is `f` ?

## Answer by user2183336 (score 2)

https://quant.stackexchange.com/a/8005

I'm not really sure what your question is, you appear to answer it yourself...

If I'm understanding you correctly you are making 2 transactions at 0.6% cost, so then your profit = pred * d_price - pred*(trans) - pred/(1+d_price)*trans

That is just your raw profit minus your transaction costs at your opening and closing prices

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.