If I live trade equities through QuantConnect with Alpaca as my broker, will I be able to trade fractional shares? If so, is there any way to backtest while trading fractional shares?
QUANTCONNECT COMMUNITY
If I live trade equities through QuantConnect with Alpaca as my broker, will I be able to trade fractional shares? If so, is there any way to backtest while trading fractional shares?
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.
Mia Alissi
Here's a direct answer for 'Zachary':
Live Trading Fractional Shares with Alpaca via QuantConnect
self.buy(symbol, 0.5)
for half a share) to brokers that allow it, such as Alpaca.Backtesting with Fractional Shares
Backtesting support for fractional shares in US equities on QuantConnect is limited. The backtesting and paper trading brokerages are primarily designed to emulate standard trading, which, for US Equities, usually means whole shares. There is no explicit documentation or example showing support for fractional share backtesting for US equities. Most provided backtesting and regression tests use whole-numbered share quantities for equities.
Fractional quantities are well supported for some asset classes (like crypto and forex), but in backtesting, US equities orders for fractional shares may either round to the nearest whole share or potentially error out, depending on the model and updates to the QuantConnect platform.
Summary Table:
Environment Fractional US Equity Shares? Live Trading (Alpaca) ✅ Supported Paper Trading ⚠️ Likely NOT supported* Backtesting ❌ Not supported*You may test fractional orders in paper trading, but they may be rounded or rejected.
What You Should Do:
Tip: If you want to check if it's supported in your project, try running a small backtest using a fractional order and see the result in the logs. For production/live deployment, Alpaca will accept those orders.
Let me know if you’d like a code snippet showing how to place a fractional share order in QuantConnect!
Sources: QuantConnect Paper Trading - QuantConnect.com, Alpaca - QuantConnect.com, Alpaca - QuantConnect.com, Reimagining the 60-40 Portfolio in an Era of AI and Falling Rates, ZerodhaBrokerageSupport - QuantConnect.com
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.
Zachary Allgood
You use self.buy() as an example. Would I still be able to purchase fractional shares through Quant Connect with Alpaca as my broker using self.SetHoldings()?
Zachary Allgood
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!