# 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 ?

• What exactly is your question? Obviously, positive transactions costs will reduce your profit. May 16 '13 at 12:07
• @LouisMarascio the question is by how much May 16 '13 at 13:08
• @siamii, you are asking a question that is impossible to answer without a host of other information which you did not provide.
– Matt
May 16 '13 at 13:17
• @Freddy I've made some amendments. See if it is clearer now? May 16 '13 at 16:20
• You need to take an optimal action in some sense. Typically that is somethink like the expected log return where you plug in the model for the expectation probabilities. Transaction costs affect the pay off naturally in that way. Be careful about stop loss limits etc if you are taking large enough positions to bail i.e. model your exit events excplicitly. Apr 1 '20 at 13:55

• So what I'm confused about is does the first transaction cost affect how much I pay for the second transaction cost? Because the second time I'm not going to trade pred amount but rather pred*(1-trans) so do I need to take the transaction cost of that? I may be wrong. May 16 '13 at 19:05
• in addition, if pred is negative and d_price is positive, then - pred/(1+d_price)*trans will be positive thus you get additional profit from transaction cost? This doesn't seem right. May 16 '13 at 19:21
• Yes, but if you were to trade the second time only with what you have left from the first trade, that's pred*(1-trans) amount. May 16 '13 at 21:30
• also, wouldn't the initial potential profit be something like pred*d_price*(1-trans)^2 and then you add the rest of the terms? That's because you not only just pay transaction costs, but the potential profit you can make is also reduced. May 16 '13 at 22:22