Playing around with things I have found I can add tags with the MarketOrder constructor using the syntax self.MarketOrder(Symbol symbol, Decimal quantity, DateTime time, String tag) with each parameter as a positional argument and all parameters stated. The equivelant does not work for me with StopMarketOrder.
I couldn't attach the failed backtest, so I commented the failed StopMarketOrder tag attempt. The error it gives is "Runtime Error: Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the StopMarketOrder method. Please checkout the API documentation. at OnData in main.py:line 78 TypeError : No method matches given arguments for StopMarketOrder'
Michael Manus
the docu says:
https://www.quantconnect.com/docs/algorithm-reference/trading-and-ordersStopMarketOrder(Symbol symbol, decimal quantity, decimal stopPrice, string tag="")
Submit a market order when the stop price is reached.
did you try without the time parameter?
please write QC the link where you got the old info from or post it here if the tag works correctly.
Noah Chasek-Macfoy
Sadly, already tried the tag="<string.>" without the time syntax, that doesn't work either... :(
Here are the two doc pages I got the initial idea from. The MarketOrder syntax does work for me.
StopMarketOrder:
https://www.quantconnect.com/lean/documentation/topic25378.html
MarketOrder:
https://www.quantconnect.com/lean/documentation/topic25192.html
Michael Manus
self.stopLoss = self.StopMarketOrder(self.future.Symbol, -1.0, data[self.future.Symbol].Price * 0.999, "Stop Loss")
should work
Noah Chasek-Macfoy
Ahh, thank you! That works. I don't know how I didn't try that. I guess I thought I had tried it because that syntax doesn't work for MarketOrder.
Noah Chasek-Macfoy
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!