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.
Is there any Trailing Stop Loss order type? If not, why?
Hi Roland Le Franc, we have an open GitHub issue about it:
Add support for Trailing Stop Orders #2580
There is no particular reason other than it is more complex than the other types and there was no demand.
I have a question - is there any way of forcing the price to be taken by an order while backtesting? Ie I would like to enter long position with ask price and close long position with bid price. Or, to open a position with Open and close that with the next after a trigger Bar Open. How can I implement that in code?
Thanks a lot for answering.
Hi Andrey,
LEAN supports custom fill models which can be used to force order fulfillment based on customized criteria. The documentation section can help illustrate how these might be implemented.
Building an algo using OandaBrokerageModel, not sure how best handle:
"Backtest Handled Error: OrderID: 1 Warning - Code: NotSupported - The OandaBrokerageModel does not support MarketOnOpen order type"Â
From what I've read, a signal a trade signal is generated, I call SetHoldings(_fx.Symbol,1); or Liquidate(_fx.Symbol); and a market order is attempted. However, because the order cannot be filled in the current session it is converted into a MarketOnOpen, which is not supported by FXCM or Oanda.  My question is, how do I get arround this?
Â
The last piece of information I gathered from Alexandre Catarino's post here:Â
https://www.quantconnect.com/forum/discussion/1761/just-downloaded-lean-have-a-few-questions/p1Hi Andrew,
The best way to get around this would be to use the Order Status and Order Ticket features, whose documentation can be found here, to cancel any open orders at market close and then re-submit them upon market open. This is likely the best way to accomplish this, assuming you want to place the order on market open no matter what happens overnight.
Is there a way to use OCA Group orders with IB?
Hi Laszlo,
There are certainly ways to implement OCA orders. In fact, there are many discussions about One-Cancel-Others orders in the community, so I recommend to search in our forum. You might want to read this and this.
Meanwhile, you may subscribe to this Github Issue for updates of IB API support. Hope it helps.
Thanks for your comment. IB API order Class has OcaGroup property. One can set it when submitting the order. So there is no way I can Set that in quantconnect? I would prefer IB monitor and managa the OCA Froups rather me in my code.
Hi Laszlo,
Thanks for the information you provided. We will work on implementing this IB API. Stay tuned!
I'm working on custom brokerage, i have following queries
1) how can I check the trade placed for intraday order? by using security holding i am only getting overnight orders
2) brokers api return overnight order in holding after t + 1 day, how can i cancel that order on same day
Hi meghdoot dhameliya I think this would be best discussed on GitHub with an open pull request. Here it's hard to really understand your needs as the problems you're describing are abstract.Â
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.
 def OnData(self, slice):
    if slice.Bars.Count == 0: return
    if self.changes is None: return
    # start fresh
    self.Liquidate()
    percentage = 1 / slice.Bars.Count
    for tradeBar in slice.Bars.Values:
      self.Log("trade bar {0}".format(tradeBar))
      self.SetHoldings(tradeBar.Symbol, percentage)
      self.Log("percentage {0}".format(percentage))
    # reset changes
    self.changes = None
Â
when using setholdings() and liquidate() like above what type of order is being used? and when is it being executed. I get a backtest but I cant tell if its liquidating on open? on close? (assuming daily data) thanks!Â
Hi Ryland,
Both SetHoldings() and Liquidate() places market orders. Since they are called within the OnData() block, they will execute on open of the next day assuming daily data. Please refer to "Understanding Time" for more information! Below is a quote from the documentation page:
"Once a datapoint's EndTime has passed it will be transmitted to your algorithm OnData() method. For bar data, this is the beginning of the next bar. "
Jared Broad : thanks a lot for the update of this page, which is really helpful!
Hi Carlos Rendon ,
QuantConnect/lean does have such feature: TradeBuilder. Please check out the following thread:
Are there any examples of using TradeBuilder/StatisticsBuilder classes in Python? #3251
for details.
We will add information about the IAlgorithm.TradeBuilder as soon as possible.
Thanks for the quick response Alexandre!!
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!