Back

Beginner issue with OnData

I'm undoubtedly doing something wrong, my code is here

public override void Initialize()
{
SetStartDate(new DateTime(2016, 10, 1));
SetEndDate(new DateTime(2016, 11, 1));

SetCash(25000);

UniverseSettings.Resolution = Resolution.Hour;

AddUniverse(coarse => {
return (from c in coarse
where c.Price > 10
orderby c.DollarVolume descending
select c.Symbol).Take(50);
});
}

public void OnData(TradeBars data)
{
Console.WriteLine("Entering OnData with " + data.Count + " equities");
}

 

The intention of course is to observe the OnData being fired.  The result in the console is:

2016-10-01 00:00:00 Launching analysis for 9f6c8b675533c601640220df6f2c308e with LEAN Engine v2.2.0.2.815
2016-10-04 10:00:00 Entering OnData with 49 equities
2016-10-10 10:00:00 Entering OnData with 48 equities
2016-10-12 10:00:00 Entering OnData with 49 equities
2016-11-02 00:00:00 Algorithm Id:(9f6c8b675533c601640220df6f2c308e) completed in 54.71 seconds at 3k data points per second. Processing total of 157,584 data points.
2016-11-02 00:00:00 Your log was successfully created and can be downloaded from: http://data.quantconnect.com/backtests/25401/388903/9f6c8b675533c601640220df6f2c308e-log.txt

 

 

The expection is that every day and every hour the OnData would fire.  Instead OnData fires only 3 times, once each on seemingly random days.  Any advice?

Thanks

 

Update Backtest








When we use System.Console.WriteLine or IAlgorithm.Debug to print out information into the console, the string object is compared with the previous one. If they are equal, a new line will not be written. We can see that your three lines are different because data.Count varies. 
If you modify that Console.Write line to:

Console.WriteLine(Time + " -> Entering OnData with " + data.Count + " equities");

you will see a new line for every new algorithm hour.

2

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.


Excellent!  Thank you very much

0

Somewhat unrelated, but it would be super-nice if the Live Dashboard could show the last 5 log messages at the bottom, just under the area where the portfolio holdings are.

more specifically, it would be nice if the last 1000 characters of the log were crammed in there (in a tiny font), as some of my log messages are quite long.  

2016-11-11 10:43:00 (Buylo) pfrCashN S q 300.00 ADM@47.47v1613 vsFMA 3.70 vsSMA 3.81 tox1 blah blah
blah blah blah blah blah blah blah B DHR@80.47v2543 vsFMA 0.64 vsSMA -6.19 tox1 blah blah

Would need to update like once a minute, although even a 5 minute delayed update would be better than using the log tab.

Also, is there a way to clear out the log in the log tab?

1

"Live Dashboard could show the last 5 log messages at the bottom" - great idea thank you. We'll look at doing it in the next couple of weeks.

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.


Update Backtest





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.


Loading...

This discussion is closed