Would like to display end of day statistics on both log and chart, but neither is displayed.
What am I doing wrong?
Trying to find the problem for a few days already, on another algorithm log and chart are displaying partial period.
Thanks in advance!
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Securities;
using System;
using System.Collections.Generic;
using QuantConnect.Orders;
using QuantConnect.Securities.Interfaces;
using QuantConnect.Interfaces;
using QuantConnect.Indicators;
using QuantConnect.Scheduling;
namespace QuantConnect.Algorithm.CSharp
{
public class Test : QCAlgorithm
{
public override void Initialize()
{
SetStartDate(2017, 01, 01);
SetEndDate(2017, 07, 01);
SetCash(100000);
Chart assets = new Chart("Assets");
AddEquity("AMZN", Resolution.Tick,Market.USA);
assets.AddSeries(new Series("AMZN", SeriesType.Line, 0));
AddChart(assets);
}
public override void OnData(Slice data)
{
foreach (String symbol in data.Ticks.Keys)
{
if (!Portfolio[symbol].Invested)
{
MarketOrder(symbol, 1000);
}
else
{
Liquidate(symbol);
}
}
}
public override void OnEndOfDay()
{
try
{
Debug("End of day: " + Time.Date.ToShortDateString());
Plot("Strategy Equity", "Portfolio", Portfolio.TotalPortfolioValue);
Plot("Assets", "AMZN", Securities["AMZN"].Price);
}
catch (Exception err)
{
Error("OnEndOfDay Err:" + err.Message);
}
}
}
}
Jenny S
In addittion, if EndOfDay is called for a part of the period, does the whole algorithm is running on a partial period as well?
Jenny S
In general, I see that backtest's trades CSV contains at most 10,001 trades, regardless charting/logging.
Does COMMUNITY plan has this kind of limitations?
If not, what can be the reason for this behavior?
Thanks!
Jenny S
Adding to this thread -
Removing MarketOrder and Liquidate orders allowed chart to display Assets, and Log to display the whole period (until log limitaions).
Alexandre Catarino
Jenny S, sorry for taking so long to answer. The issue in your algorithm was related to this line:
Plot("Strategy Equity", "Portfolio", Portfolio.TotalPortfolioValue);
The "Strategy Equity" name for a chart is reserved. Please use another name to plot Portfolio.TotalPortfolioValue.
Also, I couldn't run the algorithm for more than 3 months. It consumes too much memory.
Jenny S
Thank you Alexandre
Jenny S
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!