Back

End of day summary of holdings and results?

Hello all,

How do I send myself an end of day summary of holdings and results?  To the log for the backtest, then to email for Live?

Thanks!

Update Backtest







#Send yourself an email on live trade executions
self.Notify.Email("myEmailAddress@gmail.com", "Live Trade Executed", "Bought 100 Shares of AAPL")
0

Thank you for that tip on email.  Is there a way of entering "If this is live, use this email call, otherwise use a debug call?"

Just for keeping track of things during the backtest, I did the following.  I scheduled a function to run after the market closed with -10 as the minutes BeforeMarketClose.  This did turn out to run at 4:10 every day:

self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.BeforeMarketClose("SPY", -10), self.ReportAfterMarketClose)

Then, I found the positions by checking all of the tickers I knew might be there through:

# send info after market close
def ReportAfterMarketClose(self):

self.Debug("ReportAfterMarketClose fired at: {0}".format(self.Time))

hList = ["XLB", "IYZ", "XLY", "XLP", "XLE", "XLF", "XLV", "XLI", "IYR", "XLK", "XLU", "SPY"]

for tkr in hList:
shs = 0
try:
shs = self.Portfolio[tkr].Quantity
except:
pass
price = self.Securities[tkr].Price
if shs != 0:
#self.Debug(tkr + " shs: " + str(shs) + " value: " + str(shs * price))
#self.Debug("".format tkr + " shs: " + str(shs) + " value: " + str(shs * price))
self.Debug("{} shs: {:,.0f} value: {:,.2f}".format(tkr, shs, shs * price))

self.Debug("Cash: {0:,.2f}".format(self.Portfolio.Cash))
self.Debug("PV: {0:,.2f}".format(self.Portfolio.TotalPortfolioValue))

return

This is a pretty horrible solution.  Among other things, I could not figure out how to iterate through the portfolio directly!  Is there a list of self.Portfolio calls that are available?

0

Please check out the Live Trading section of the documentation. For the scheduled event timing - 10 minutes before market close would be 3.50; -10 minutes before market close is 4.10. 

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