Back

Help with External Source - minute resolution data / Exponential Moving Average

Hi. I'm a very beginner to QuantConnect and to AlgoTrading.

I'm interested in learning/creating algorithms for short-term trading; My target is the brazilian stock exchange.
As far as I understood, I need minute-resolution brazilian data and I cannot obtain it neither from QuantConnect nor from Quandl sources for Google or Yahoo Finance. However, Yahoo Interactive chart api provides the data I need, and I wrote my own class importing it (based on the Quandl class).

1. Real data (excluding the null entries) comes in irregular intervals. Sometimes 1 minute, sometimes 3 or even 6. Is this a problem for QuantConnect framework?

2. Running a 1 month backtest, I wasn't able to use the ExponentialMovingAverage class provided by QuantConnect. The EMA throws a runtime error saying "this is a forward only indicator". What am I doing wrong? Data is sorted just like Quandl data.

3. As a temporary solution I implemented a separate Exponential Moving Average class based on the video tutorial (attached project). I see at least two issues:
3.1. Multiple Trades are happening at the same time. For example, 2015-06-19 20:07:00 has more than 10!
3.2. In the IDE Trades list (and in the STOCKPLOT chart), I can only see trades between 2015-06-01 and 2015-06-19, while in the downloaded trades list, I see trades along the whole tested period (attached backtest).

Help please! I really enjoy the idea of QuantConnect, but I'm not being able to do the very basic.

Thanks in advance
Update Backtest








Hi @Pedro, please look at my edits to your project. Note how I use consolidator and register indicators with it. Look at the callback on DataConsolidated event. You have minute resolution data and it starts from 2015-05-21, that's not enough to get 50 days for the ema. So I used hourly resolution on consolidator to get get some trades.

Thank you for your question, it's an opportunity to learn.
0


Hey @Pedro Nucci,

It looks like there's an error in your custom data. The GetSource method is called each day, and if the source string is different, we'll re-download the data, so by using DateTime.Now, every day we're redownloading the data.

I've made changes to show how you can set it up to download the data for each month, I've also provided some (commented out) code to download for each day. I prefer the monthly method, tends to result in faster backtests and less data gaps.
1

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.


Great to see some support here.

@Dmitri, thanks, but what I really want is to make the EMA to process each data point (irregular minute resolution data), without grouping them as days or hours. Your code gave me the idea to set the data source to Tick level and the EMA to Minute level, I was able to backtest, but not the ideal solution. I believe our friend MichaelH solved above. Anyway your code modifications will teach me about Consolidators as a bonus

@MichaelH, thank you. headshot! I didn't know GetSource() would be called for each day. For me the docs were not clear about this ( https://www.quantconnect.com/docs/API#3.1 ). Backtest works now and is very fast. Thanks!

Cheers
1

@Pedro Check my question nearby on the list. It seems as though your problem is similar to mine in that the data source is irregular. I will clone your code and take a look.

Nick
0

@Nicholas Stein, in my case the problem is that my algo was downloading the csv for each day. Maybe the solution MichaelH gave me will help you too
0

@Pedro Your problem is easily solved I think. Just request 1 day in your download url. Like this

http://newnode-pnucci.rhcloud.com/stock/yahoocsv?s=spy&d1=7/8/2015&d2=7/8/2015

I got a proxy error when I tried it in a browser, so I could not test.it.
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