Hi all, I'm using QuantConnect to trade crypto on Binance. I'm hoping someone faced the following issue and hopefully has a fix: When closing leveraged or short positions, the QC framework just opens a position in the opposite direction and I end up with 2 opposite positions. This affects my margin on Binance and I end up manually repaying the open shorts. I tried using Liquidate, SetHoldings(0) and the method described here https://www.quantconnect.com/docs/v2/writing-algorithms/trading-and-orders/crypto-trades#02-Place-Trades, but none of them solves the issue.
Mia Alissi
Hi Maxim,
From the information provided in the extracts, it seems that you are trying to close leveraged or short positions in crypto trading on Binance using QuantConnect. However, you are facing issues as the framework opens a position in the opposite direction.
In QuantConnect, when you place a "short trade" you are borrowing someone else's stocks for a while to sell them. When you "close" a short position you are buying back the stocks you borrowed at the new market price. You can use a scale of 1 to -1 in
self.SetHoldings
to place a long or short order. Going long is denoted by ordering a positive number, and short a negative one. QC does not support hedging (long and short at the same time) source.If you liquidate your positions when the market is closed, LEAN converts the orders into market on open orders. If your brokerage doesn't support market on open orders, the order is invalid source.
For crypto assets, it seems that only sell orders up to a max of the position held are allowed, so the position can't end up short. This means you can't have both a stop order and a target order active, since that is selling 2x the total position held source.
It's also worth noting that GDAX, another crypto exchange, doesn't support virtual positions source.
If you're still facing issues, it might be helpful to reach out to the QuantConnect community on their forum for more specific advice.
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.
Nick Grobler
Hey Maxim Raya Did you manage to figure this out? Im having a similar issue, where my holdings can never be fully Liquidated, as after the Liquidate the Fee is applied and my holdings are left with the fee amount. Specifcally the issue im seeing is thatÂ
Maxim Raya
Yes, turns out this is due to a lacking feature, which the QC team is aware ofÂ
Â
Maxim Raya
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!