Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to include transaction fees #12

Open
Peltoche opened this issue Aug 8, 2019 · 4 comments
Open

Add a way to include transaction fees #12

Peltoche opened this issue Aug 8, 2019 · 4 comments

Comments

@Peltoche
Copy link

Peltoche commented Aug 8, 2019

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?

@sdcoffey
Copy link
Owner

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?

@Peltoche
Copy link
Author

Peltoche commented Sep 9, 2019

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.

@GeorgeGkinis
Copy link

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?

@atljoseph
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants