Back

Plotting Hour Resolution Chart in local LEAN instance

Hello,

I'm trying to use a local instance of LEAN to plot a Chart and I got this console red error:

20170725 10:33:02 Error:: QuoteBar.ParseTradeAsQuoteBar(): Data formatted as Trade when Quote format was expected.  Support for this will disappear June 2017.

This is the code:

using System;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;


namespace QuantConnect.Algorithm.Examples
{

public class CustomChartingAlgorithm : QCAlgorithm
{
decimal lastOpenPrice = 0;
decimal lastClosePrice = 0;

ExponentialMovingAverage EMAFast;
ExponentialMovingAverage EMASlow;


DateTime startDate = new DateTime(2017, 7, 1);
DateTime endDate = new DateTime(2017, 7, 18);


public override void Initialize()
{
SetStartDate(startDate);
SetEndDate(endDate);

SetCash(100000);


AddForex("EURUSD", Resolution.Hour);



Chart stockPlot = new Chart("Trade Plot");
Series assetOpenPrice = new Series("Open", SeriesType.Scatter, 0);
Series assetClosePrice = new Series("Close", SeriesType.Scatter, 0);
Series fastMA = new Series("FastMA", SeriesType.Line, 0);
Series slowMA = new Series("SlowMA", SeriesType.Line, 0);

EMAFast = EMA("EURUSD", 9);
EMASlow = EMA("EURUSD", 90);

stockPlot.AddSeries(assetOpenPrice);
stockPlot.AddSeries(assetClosePrice);
stockPlot.AddSeries(fastMA);
stockPlot.AddSeries(slowMA);
AddChart(stockPlot);

}


public void OnData(QuoteBars data)
{

if (!Portfolio.HoldStock)
{
SetHoldings("EURUSD", 10);
}

lastOpenPrice = data["EURUSD"].Open;
lastClosePrice = data["EURUSD"].Close;
Plot("Trade Plot", "Open", lastOpenPrice);
Plot("Trade Plot", "Close", lastClosePrice);

if (EMASlow.IsReady)
{
Plot("Trade Plot", "FastMA", EMAFast);
Plot("Trade Plot", "SlowMA", EMASlow);

}
}

}
}

In the video below it is possible to see what happens when running.

https://drive.google.com/file/d/0B2EWhkth6cfMaHViLThDYmZWdkk/view

 

Any help is much appreciated.

Cheers.

Update Backtest








^^^^^^^^^^^^ The video first shows what happens when running on minute resolution (which works) and then tries it at Hour resolution.

 

0

We couldn't reproduce the issue.
Did you verify your data file? That is how one line should look like:

20170702 14:00,1.14144,1.14214,1.14123,1.14144,0,1.14261,1.14279,1.14181,1.1426,0

 

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.


Local file was corrupt somehow, I just deleted the file and it worked.

Thanks.

0

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