Hi,
I tried a small example to buy/sell crypto using binance. The buy works fine:
xrp = self.AddCrypto(self.ticker1_1, Resolution.Daily, Market.Binance).Symbol
quantity = self.CalculateOrderQuantity(xrp, *)
self.Buy(xrp, quantity)
- New Order Event: Time: 01/18/2022 23:00:00 OrderID: 1 EventID: 2 Symbol: XRPBUSD Status: Filled Quantity: 215 FillQuantity: 215 FillPrice: 0.7572 OrderFee: 0.215 XRP Message: Binance Order Event Buy
but when I wanted to sell using : self.Liquidate() I get the following error:
- Order Error: id: 2, Insufficient buying power to complete order (Value:-159.1451), Reason: Your portfolio holds 214.785 XRP, 0 XRP of which are reserved for open orders, but your Sell order is for 215 XRP. Cash Modeling trading does not permit short holdings so ensure you only sell what you have, including any additional open orders.
Looks like Binance takes the fee from that 215 xrp and remains 214.785 xrp. My problem is why quant is not aware of this and try to sell 215. And how could I solve it…
Regards,
Gabi
Fred Painchaud
Hi Gabi,
You need to use the CashBook. Such as self.Portfolio.CashBook["BTC"].Amount. Refer to https://www.quantconnect.com/docs/data-library/crypto
This will tell you which position to exit precisely.
Fred
Gabi.C
Thanks
Varad Kabade
Hi Gabi.C,
Thank you for the report.
We have a GitHub issue to address the problem:
Can't liquidate a binance position due to error "Account has insufficient balance for requested action" #6123 Meanwhile, you may need to remove the Liquidate method calls and replace for:
Best,
Varad Kabade
Gabi.C
Thanks
Gabi.C
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!