trophy

Long Only, ETF Alpha Streams Competition with $27,500 Prize Pool

Back

DateTime & DayOfWeek test

Hi evryone,

I try to test the Day of week, when i lunch a Debug line, i get my message but not the day of the week, someone can test ? I think my condition is not respected because if i make a loop up with goto this block the algo.

DateTime dt = Time;

if (dt.DayOfWeek == DayOfWeek.Friday && Time.Hour >= 15 && Time.Minute > 56)
{
Debug("FRRRRRRRRRRRRRRRRRRRR" + dt.DayOfWeek);
}

if (dt.DayOfWeek == DayOfWeek.Monday && Time.Hour < 9 && Time.Minute < 01 )
{
Debug("MMMMMMMMMMMMMMMMONNNN" + dt.DayOfWeek);
}


if (dt.DayOfWeek == DayOfWeek.Saturday)
{
Debug("SAAAAAAAAAAAAAAAATTTTTTT" + dt.DayOfWeek);
}

if (dt.DayOfWeek == DayOfWeek.Sunday)
{
Debug("SSSSSSSSSSSSSSUNNNNNNNNN" + dt.DayOfWeek);
}

Thanks,

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.


Hi Gmamuze,

Try adding 

Debug(Time.ToString());

in the beginning of your OnData(Slice data) method. It is of hard to tell what is going on without knowing the Resolution of your equities but if you are using 

AddEquity("SPY", Resolution.Daily);

OnData(Slice data) is called Tuesday, Wednesday, Thursday, Friday, and Saturday at 12:00:00 AM.

 

0

Hi Gmamuze,

Please use the following code to see that the DayOfWeek is correctly printed and the boolean statement correctly checks the day of the week. 

Debug(Time.DayOfWeek.ToString());
Debug((Time.DayOfWeek == DayOfWeek.Friday).ToString());

Hope this helps!

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