sthewissen / Mynt

An Azure Functions-based crypto currency trading bot; featuring 10 exchanges, 25 indicators, custom strategy support, backtester and more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong calculation of profit in ExecuteSellOrder method if the AmountOfBtcToInvestPerTrader is changed after the buy

rjovic opened this issue · comments

First of all I want to thank you on putting your effort and publishing the source of this awesome project. I'm also in process of playing with creation of trading bots and your project really helped me a lot, especially because it is on Azure and it uses .NET (environment where I'm most comfortable). So thumbs up!

Now on possible issue. I'm looking at the code and trying to understand it and following line in ExecuteSellOrder method confuses me:

var investment = (Constants.AmountOfBtcToInvestPerTrader * (1 - Constants.TransactionFeePercentage));

So if I understood correctly the whole workflow, the problem will arise if I the system generate the buy order for amount of Constants.AmountOfBtcToInvestPerTrader and if after that buy user change the Constants.AmountOfBtcToInvestPerTrader the whole profit will be calculated using the old value which will mess up the calculation.

Should we use trade.StakeAmount which is persisted in the storage when buy is generated?

var investment = (trade.StakeAmount * (1 - Constants.TransactionFeePercentage));

That would probably work yeah. I'm currently a bit busy with other projects so feel free to submit a PR for this :)

Done :)