Hello,
I'm new here and just dicovered Quant Connect, it looks promising.
Immediately I have a question though: I'm used to run backtests on all stocks and it seems I have to add each stock manually. Is there a way to run a backtest on many stocks at once? I'd like to receive, for example, minute bars for all active stocks between 1/1/2010 and 12/31/2010. So each "OnTradeBar" dictionary should have about 6000-8000 items in it if I request just NYSE and NASDAQ stocks. How would I do this in the "Initialize" method and is this even possible with QuantConnect?
Thanks!
-luke
LukasBühler
Jared Broad
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.
LukasBühler
public class BasicTemplateAlgorithm : QCAlgorithm, IAlgorithm { //Initialize the data and resolution you require for your strategy: public override void Initialize() { //Initialize the start, end dates for simulation; cash and data required. SetStartDate(2012, 06, 01); SetEndDate(2012, 12, 30); SetCash(30000); //Starting Cash in USD. AddSecurities("NYSE", Resolution.EOD); AddSecurities("NASDAQ", Resolution.EOD); SetRunMode(RunMode.Series); //Series or Parallel for intraday strategies. } //Handle TradeBar Events: a TradeBar occurs on every time-interval public override void OnTradeBar(Dictionary data)
{
if(IsEod)
{
//remove yesterdays intraday data, to get ready for todays data
//this could be done smarter too where only the new securiteis
// are added and the old ones removed.
ClearSecurities(Resolution.Minute);
var selectedStocks = OnEndOfDay(data);
foreach(var selectedStock in selectedStocks)
{
AddSecurity(SecurityType.Equity, selectedStock, Resolution.Minute);
}
//also request the securities for open positions from yesterday
}
else
{
OnIntraday(data);
}
}
private IList OnEndOfDay(Dictionary data)
{
//select the most insteresting stocks based on eod data.
// could be volatility, volume, paterns, MAs...
return mySelectedStocks;
}
private void OnIntraday(Dictionary data)
{
//look for intraday patterns and trade them
}
}
Jared Broad
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.
LukasBühler
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!