↑↓ to select, press enter to go, use esc to exit
  • Pricing
  • Research
  • Data
  • Documentation Docs Docs
  • Algorithm Lab Lab Lab
  • Sign In
Forum
    Platform
  • Pricing
  • Research
  • Datasets
  • Documentation
  • Algorithm Lab

    SIGN IN

  • Sign in
  • Don't have an account? Join QuantConnect Today

  • Sign up for Free
 

back arrow

QUANTCONNECT COMMUNITY

 
Research Announcements Lean League
COMMUNITY COMMUNITY FEED |

OPEN LEAGUE PRO LEAGUE
No Results
  • «
  • 1
  • »
LEAN Logo

Radically Open-Source Algorithmic Trading Engine

LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.

Join Our Discord Channel

Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.

This research is under review. To publish this research attract three community upvotes.


Draft Discussions




Bookmarked Discussions


Loading...
  • «
  • »
 Share New Research

Refer to our Research Guidelines for high quality research posts.

 Start New Discussion Sign up

SEARCH DISCUSSIONS


TOP 5 Research Publications

-


444,300 Quants.
Become a Quant

Online Now

Code of Conduct

VOTE FOR UPCOMING FEATURES

Share your input and vote on our future direction.

LEAN Roadmap

Create an account on QuantConnect for the latest delivered to your inbox.

Sign Up Today
profile

Answers

Answers

  Backtests

Backtests

  Comments

Comments

  Live Traded

Live Traded

 

 

 

Research Announcements Lean League
COMMUNITY COMMUNITY FEED |

This research is under review. To publish this research attract three community upvotes.
This discussion is a draft. Click here to publish this discusison.

Documentation discussion algorithm-reference/trading-and-orders


Update Backtest





person upvoted this people upvoted this

QuantConnect Robot

 |  | accepted answerAccepted Answer
Permalink
Update Backtest





  • Notebook

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.

Twitter Facebook LinkedIn Copy Link

Roland Le Franc


19 Pro ,

Is there any Trailing Stop Loss order type? If not, why?


Alexandre Catarino


108.3k Pro ,

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.


Andrey Solovyev


19 Pro ,

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. 


Jack Simonson


49.4k Pro ,

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.


Andrew Angeles


10 Pro ,

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/p1

Jack Simonson


49.4k Pro ,

Hi 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.


Laszlo Pasztor Questive Ltd


4.5k Pro ,

Is there a way to use OCA Group orders with IB?


Link Liang


6.1k Pro ,

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.


Laszlo Pasztor Questive Ltd


4.5k Pro ,

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.


Link Liang


6.1k Pro ,

Hi Laszlo,

Thanks for the information you provided. We will work on implementing this IB API. Stay tuned!


Meghdoot dhameliya


149 Pro ,

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


Jared Broad


STAFF Pro ,

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.


Ryland Mathews


231 Pro ,

 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! 


Alethea Lin


7.5k Pro ,

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. "


Laurent Crouzet


4.9k Pro ,

Jared Broad : thanks a lot for the update of this page, which is really helpful!


Alexandre Catarino


108.3k Pro ,

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.


Carlos Rendon


167 Pro ,

Thanks for the quick response Alexandre!!


Shailesh Raval


1k Pro ,
# Use order response object to read status if response.IsSuccessful: self.Debug("Order successfully canceled") It is not IsSuccessfulONLY     IsSuccess

QuantConnect Robot INVESTOR

 | 
Permalink
Update Backtest







  • Notebook

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.

Reply
person upvoted this people upvoted this
|
person upvoted this people upvoted this
Profile Image
Loading...
  • 1
Load More

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!


Allocate to this Strategy

Institutional clients can contact the author and allocate capital to this strategy.

Learn More
Organization

Organization Website

Team

Show More
Clone Strategy

Copy this strategy code to your QuantConnect account and deploy it live with your brokerage.

Clone
Previous Ranking

Browse strategies and organization entries from previous quarter's competitions.


Author:


IN THIS RESEARCH

PARTICIPANTS

Discussion Awards

SHARE RESEARCH
SHARE DISCUSSION
SHARE ARTICLE
SHARE


Actions
View in Strategy Explorer Award Discussion
Print Research
Comments
award-icon

What is an Award?

Research Announcements Lean League
COMMUNITY COMMUNITY FEED |

 
 

Join QuantConnect for Free

QuantConnect Logo

QuantConnect™ 2025. All Rights Reserved

Technology

  • Algorithm Lab
  • Documentation
  • Research
  • Build vs. Buy
  • Tutorials
  • Data Library
  • Learning Articles
  • System Status
  • Settings
  • Discussions List

Company

  • About
  • Affiliates
  • Our Blog
  • Contact
  • Pricing
  • Integration Partners
  • QuantConnect Swag
  • Terms & Conditions
  • Privacy Policy

LEAN

  • Fork 4,000
  • Star 14,000
QuantConnect Logo

QuantConnect™ 2025. All Rights Reserved

Technology

  • Algorithm Lab
  • Documentation
  • Research
  • Build vs. Buy
  • Tutorials
  • Data Library
  • Learning Articles
  • System Status
  • Settings
  • Discussions List

Company

  • About
  • Affiliates
  • Our Blog
  • Contact
  • Pricing
  • Integration Partners
  • QuantConnect Swag
  • Terms & Conditions
  • Privacy Policy

LEAN

  • Fork 4,000
  • Star 14,000