Hi everyone! I'm a little bit stucked with Binance fees while backtesting... I notice that despite they are properly calculated and deducted from the order amount in base currency, then the Cashbook is not properly updated and fees are not deducted from holdings... is that right? should I manually update Cashbook holdings?
It’s worth noting that I began to experience this behaviour a few days ago when I saw the following message in the execution log: “When buying currency pairs, using Cash account types, fees in base currency will be deducted from the filled quantity so virtual positions reflect actual holdings”. Before that I never saw this message and when I made a trade, order amount wasn’t impacted with the fee amount since fees were directly deducted from holdings (Portfolio.Cashbook[USD].Amount). I understand this new behaviour and it makes sense to me but I am not able to understand why Cashbook is not properly updated. Cost of the received BTC amount is deducted from Holdings but cost of fee amount not.
Thanks in advance, best regards
Fred Painchaud
Hi Jesus,
Not 100% sure this answers your question but if you buy BTCUSD, the amount of BTC you hold after the buy will reflect the implied fees. So you will have a bit less BTC in your cashbook than what you would have if you were to pay no fees…
I believe that's what is meant by “fees in base currency will be deducted from the filled quantity”.
I feel this is normal - do you think it should not be that way or are you saying that's not what you are seeing?
Fred
Jesus Ruiz Bustos
Hi Fred,
Thank a lot for your answer.
This is not the problem I am having. The behavior you describe is correct and it makes sense to me.
I understand that but I would expect that after this buy, the USD cost deducted from USD cashbook reflect the total cost of this trade (this is the cost of BTC that I have received plus the cost of BTC for the fee). However, only the cost of the BTC amount I have receive is deducted from the USD cashbook.
A simple example would be: I perform a buy of 10 BTC. I receive 9 BTC in BTC cashbook because 1 BTC is the brokerage fee. I would expect that my USD cashbook reflect (X-10*BTCprice). However, it reflects (X-9*BTCprice)
I hope that is clear now.
Thanks. Jesus
Fred Painchaud
Hi Jesus,
Would you please include the simplest code and backtest that exhibits this behavior?
It is certainly not normal to me. It basically means there are no fees. If you buy 10 BTC but get 9 because of fees. but then you are credited 9 BTC, you basically bought 9 BTC without any fees… as you certainly understand since you are here asking 😊.
Fred
Jesus Ruiz Bustos
Hi Fred,
Please find enclosed a simplest code with its bakctest.
I am ordering to buy 1 BTC. After performing this trade I receive 1 BTC minus fee. Then I would expect the USD cost for this trade will be the cost of 1 BTC (the BTC amount that I receive + the BTC amount for the fee). However, if you check the portfolio USD cashbook, only the cost of BTC that I have received has been deducted.
Log shows these variables before and after the trade.
Hope this is clear now.
Thank you
Fred Painchaud
Hi Jesus,
It looks clear to me, indeed. Let's wait a bit to see if Varad for instance has some answer for that.
Fred
Martin Molinero
Hi all!
Thank you for the report Jesus Ruiz Bustos
The issue has been fixed this morning starting from Lean v13591.
Best regards,
Martin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jesus Ruiz Bustos
Thank you Martin Molinero for your support.
It works now.
Much appreciated.
Regards, Jesús
Jesus Ruiz Bustos
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!