this setup has an syntax error that I can not figure out. from what I understand I should be able to set a quantity for the code to return available but the line is not compatable for some reason. what am I missing?
def AllShortableSymbols(self, localTime: datetime):
return [Symbol.Create("T", SecurityType.Equity, Market.USA): 0]
Mia Alissi
The syntax error in your code is due to the incorrect use of the list and dictionary syntax. In Python, a list is defined using square brackets
[]
and a dictionary is defined using curly braces{}
with key-value pairs separated by a colon:
.If you want to create a dictionary with "T" as the key and 0 as the value, you should use the following syntax:
If you want to create a list with a single element, which is the symbol "T", you should use the following syntax:
Please note that the
AllShortableSymbols
method in QuantConnect returns a dictionary of quantity shortable keyed by Symbol. So, if you are trying to override this method, you should return a dictionary, not a list.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.
Pj Kenedy
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!