Back

Custom data properties Time and Endtime changed after I set them?

public PortfolioWeight(string csvLine)
{
var line = csvLine.Split(',');

//Date = Parse.DateTimeExact(line[0], "yyyyMMdd HH:mm:ss");
this.Date = Parse.DateTimeExact(line[0], "yyyy-MM-dd").AddHours(18);
this.EndTime = this.Date;
this.Time = this.Date;
this.Weight = double.Parse( line[1] , CultureInfo.CurrentCulture.NumberFormat );
this.Ticker = line[2];
}

 

Hi,

 I set the time in each row of my custom data, which would arrive at around 6pm each evening. I used this value to set Endtime and then also Time, because I notived that the Endtime was being reset to Midnight in the OnData method. Why are both Time and EndTime being reset somewhere after I set them? I think this is causing the Security.Price to be zero when OnData is called, when there should be data. 
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.


this.EndTime = this.Date;
this.Time = this.Date;

Do you also set a period in that constructor? That might cause the EndTime to reset. I'd recommend setting the EndTime only unless your portfolio weight genuinely has a period. The object should arrive in your algorithm at the end time. 

If you set the Value of the object it will give it a price. 

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.


The end time is being reset by SubscriptionData.Create - that method is rounding the EndTime based on market hours ? But the market hours are "Open All Day" so it gets set to Midnight, I guess. Very confusing, as the market hours database shows the correct equity market hours. 

 

I dont understand the point above about Value giving a price? I am reading in a portfolio weight, it does not have a price. After the market closes each day, there are new allocatiions, and at that time (arbitrarilty chosen to be two hours after the close) I want to call SetHoldings, and have the order executed the next day. 

 

 

 

 

0

I am just setting .Time in my data object, and I added the time zone to the AddData method. But no change in behaviour, it still tries to round down to the beginning of day. So sometimes it thinks price is zero, and the other times I think it gets the wrong price. 

0

Can you please post a mock example so we can assist you with debugging?

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