LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
Is there an method already built in for incrementing by some time increment that takes into account when the market is open?
For example, I sell a stock 2 hours after I buy it. This takes place even over the end of day and over weekends. So if I buy on Friday at 3pm, then I would sell it on Monday at 10:30AM.
I could bulid one myself but was curious if it had already been implemented somewhere.
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.
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.
Atish Sawant
181
,
So I found this which describes regular schedules.
But it still doesn't quite work in Python. An example of this in python would be great.
0
Jared Broad
STAFF
,
Not currently; we have similar code for days but not intraday timespans like that. We have a MarketOpen check you could use and then iterate forward in minute increments? This is how we do it for the History API.
https://github.com/QuantConnect/Lean/blob/1ccd33bef724af683d0e806f116ef22cfdac9cf4/Common/Time.cs#L398public static DateTime GetStartTimeForTradeBars(SecurityExchangeHours exchange, DateTime end, TimeSpan barSize, int barCount, bool extendedMarketHours)
{
if (barSize <= TimeSpan.Zero)
{
throw new ArgumentException("barSize must be greater than TimeSpan.Zero", "barSize");
}
var current = end.RoundDown(barSize);
for (int i = 0; i < barCount;)
{
var previous = current;
current = current - barSize;
if (exchange.IsOpen(current, previous, extendedMarketHours))
{
i++;
}
}
return current;
}
0
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.
Atish Sawant
181
,
I pieced together all the code logic to work. However I'm getting an order status of 3 on a market order that doesn't kick off an error or seem to get filled for some reason.
0
Alexandre Catarino
100.3k
,
Please chekout the docs, under Order Error Codes, to get meaning of order status:
Error Code Interpretation
-3 InsufficientBuyingPower - Not enough money to to submit order.
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.
Loading...
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!