Back

System.Linq.Enumerable+WhereEnumerableIterator in Python

I'm working on a strategy that needs to get the next trading day. There is a method to get the next trading day using TradingCalendar in C# which I found here: 

https://www.quantconnect.com/forum/discussion/1958/get-next-trading-day/p1

I'm trying to replicate the code in python with:

self.TradingCalendar.GetDaysByType(TradingDayType.BusinessDay, self.Time.date(), self.Time.date() + datetime.timedelta(days=5))

When I log the result, I get System.Linq.Enumerable+WhereEnumerableIterator`1[QuantConnect.TradingDay] as the value. Does anyone have any ideas about how to work with this in python?

 

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.


I found the solution. You just need to convert it to a list:

list(self.TradingCalendar.GetDaysByType(TradingDayType.BusinessDay, self.Time.date(), self.Time.date() + timedelta(days=5)))[1].Date

I'll leave this up in case anyone comes across the same problem. 

1

Hi Nibraas Khan ,

Thank you for letting the community know that you have found a solution.

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