Hi!
I have seen that you can set the brokeragemodel in your algo. I've seen that there are brokerage models for almost any broker offered by QC but Alpaca.
QUANTCONNECT COMMUNITY
Hi!
I have seen that you can set the brokeragemodel in your algo. I've seen that there are brokerage models for almost any broker offered by QC but Alpaca.
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.
Derek Melchin
Hi Emiliano,
We have a brokerage model for Alpaca. View the source code here.
We will be adding this to the documentation. Track our progress here.
Best,
Derek Melchin
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.
Emiliano Fraticelli
It doesn't seem to work..this is just a little fragment of my code ( I can't show it in full since it's under NDA and I'm developing it in a team).
def Initialize(self): self.SetStartDate(2000, 5, 15) self.SetEndDate(2020, 7, 15) self.SetCash(100000) self.SetBrokerageModel(BrokerageName.AlpacaBrokerageModel) self.leverage = 1 self.symbol = self.AddEquity('SPY', Resolution.Daily).Symbol self.coarse_count = 500 self.top_by_market_cap_count = 100
The code above does not work..whereas this one below does...
def Initialize(self): self.SetStartDate(2000, 5, 15) self.SetEndDate(2020, 7, 15) self.SetCash(100000) self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage) self.leverage = 1 self.symbol = self.AddEquity('SPY', Resolution.Daily).Symbol self.coarse_count = 500 self.top_by_market_cap_count = 100
Derek Melchin
Hi Emiliano,
Can you elaborate on what isn't working? I have different results when using different brokerage models.
Best,
Derek Melchin
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.
Emiliano Fraticelli
Derek, I mean that using
self.SetBrokerageModel(BrokerageName.AlpacaBrokerageModel)
instead of
self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage)
gives me an error. It's not that backtests results are different (and that's something that one should expect due to different commission model), it's that it's an error. Maybe the syntax is wrong?
Emiliano Fraticelli
Here's the error in detail:
During the algorithm initialization, the following exception has occurred: AttributeError : type object 'BrokerageName' has no attribute 'AlpacaBrokerageModel'
at Initialize in main.py:line 7
:: self.SetBrokerageModel(BrokerageName.AlpacaBrokerageModel)
AttributeError : type object 'BrokerageName' has no attribute 'AlpacaBrokerageModel'
Derek Melchin
Hi Emiliano,
The correct syntax would be
self.SetBrokerageModel(BrokerageName.Alpaca)
See the LEAN source code and the attached backtest for reference.
Best,
Derek Melchin
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.
Emiliano Fraticelli
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!