techan icon indicating copy to clipboard operation
techan copied to clipboard

Add a way to include transaction fees

Open Peltoche opened this issue 6 years ago • 4 comments

Hello!

Would it be possible to add a way to include transaction fees into the calculations? I see two way to do it:

  • Update the Strategy interface in order to include it.
  • Make a new analyze tool

What do you think of it?

Peltoche avatar Aug 08 '19 08:08 Peltoche

I like it!

Probably the best way to accomplish this is to add a Commision field to Order, and then adjust the logic in the relevant analysis tools to take it into account when calculating profit.

What do you think?

sdcoffey avatar Aug 14 '19 20:08 sdcoffey

I just started to work on the subject and a question appeared: How do we deduce the commission from a position? I see two solution:

  1. We deduce the commission from the Order
  2. We deduce the commission from the wallet

Solution 1

This solution have as downside that the amount ordered will never be the one expected.

For example if I open a position with 100 BTC with a 10% commission I remove the commission from the order and so I will end up with only 90 BTC inside my position.

Solution 2

This solution imply to create a new Analysis tool for the commissions and let the people deduce them at the end of the operations. It have as downside that the commission are not taken into account into the positions max amount.

For example I have 100 BTC and I want to open a position with 10% commission with all my money. Normally I should be able to open a position for only 90 BTC due to the fact that 10 BTC have been paid for the commission. With the solution 2 the position will be opened with 100 BTC and the 10 BTC for the commission will be paid later.

IMHO the solution 2 seems a lot easier to implement and less error prone.

Peltoche avatar Sep 09 '19 09:09 Peltoche

I currently do it this way :

o := techan.Order{
Side: techan.SELL,
Security: Symbol,
Price: nc.ClosePrice,
Amount: big.NewFromInt(amount).Mul(big.ONE.Sub(big.NewDecimal(transactionFeePercent))),
ExecutionTime: time.Now(),
}

On my trading platform there is a transaction fee of 0,075% This seems to be the aforementioned Solution 1.

I am not 100% sure this is correct, any suggestions here?

GeorgeGkinis avatar Mar 18 '21 08:03 GeorgeGkinis

Not sure it needs to be this complicated. The code used to determine when to place an order should figure in the commission before choosing to execute the order. Like, shouldn’t strategy tell your code it is time to buy or sell, then your code double-checks the fees, then if acceptable, do the math to exec the 90 BTC trade? Maybe I’m saying something wrong, but the repo does leave me wanting for more documentation via examples, with comments on every line, and more realistic scenarios. I know this is just a chore, and it’s easier said than done, but needs to be done.

atljoseph avatar Oct 06 '21 00:10 atljoseph