Hi!
I'm developing a project for a client.
The client wants to print the Daily Equity.
Due to NDA I can't share the full code and I will share just a snippet.
This code unfortuntaly makes print more time the daiy equity during some days..I really can't understand why.
The daily_equity is called just once in all my code, a few lines above in the here:
self.Schedule.On(self.DateRules.EveryDay(),self.TimeRules.At(12, 0), self.daily_equity)
I can't understand why I'm getting logs like this:
Emiliano Fraticelli
Sorry I was editing images but there was like a timer which ran off,
the links don't work properly.
Here's n1
https://ibb.co/18xhT59And n2:
https://ibb.co/TKXZ3vmEmiliano Fraticelli
Ok, I did erare all the code I can't share. The problem is still there...what do I do wrong?
Thanks
Emiliano Fraticelli
I changed the function ths way:
def daily_equity(self): # only once per day if self.previous is not None and self.previous.Date == self.Time.Date: return if self.flagCommentRank==0: self.Log("daily equity: " + str(self.Portfolio.TotalPortfolioValue))
but I still get more log prints on the same day!!!
Derek Melchin
Hi Emiliano,
When a log is made, it is timestamped to match the time of the next bar that is passed to the algorithm. If we replace the logging statement with one that includes the algorithm's current time when the Scheduled Event is called, we can see the problem is resolved.
self.Log("daily equity: " + str(self.Portfolio.TotalPortfolioValue) + f" at {self.Time}")
See the attached backtest logs for reference.
Best,
Derek Melchin
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.
Emiliano Fraticelli
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!