Okay. Ultimately, here is my problem and goal.
I am currently working with hourly data consolidated from Resolution.Minute in my algorithm. The reason for this is because I need access to hourly extended market data and Resolution.Hour does not offer this.
So, for a specific example, I am able to use my algorithm on UPRO hour data from 4am-8pm.
My ultimate problem is this: How can I see accurate and detailed graphs displaying the exact data that my algorithm is being presented during runtime?
Obviously the graphs displayed at the end of the backtest leave much to be desired for this purpose. (4000 max points and a granularity that will miss much of the specific detail that I am looking for). They are good for general sanity checks, but not close inspection.
Currently, I use TradingView to look at detailed graphs regarding the market. They have a fantastic interface. However, as far as I can tell, they only show extended market data from ~7:00am - ~7:00pm. Regardless if this number is a bit off in general, TradingView does not (as far as I can tell) show the same data being offered by QuantConnect (5:00am - 8pm)
As you can probably guess, this is sort of an issue when trying to look at a detailed chart. I'm using 50 and 200 EMA indicators and 14 period RSI. This additional extended market data included in my algorithm, but not included in TradingView will obviously produce marginally different values at any given point. Not ideal.
I have also taken a look at QuantConnect's research.ipynb to see if I can produce better graphs from the same data, but I have run into an issue. Since I am using consolidated data, I have to consolidate the minute history into hourly history. However, it seems I have to use pandas DataFrame ohlc resampling (method shown in the research section of the documentation) to perform the consolidation. Regardless, this method of history consolidation appears to be different than the one performed during algorithm execution. For UPRO, the closing price between the two methods was off by ~$1 at any given point.
Because of the obvious logging limitations, I can't even have the algorithm debug the values at every hour to be graphed offline by another program (excel, etc).
Does anyone have any tips, tricks, helpful resources, or suggestions for what I am asking? Maybe another application aside from TradingView that offers the full extended market hours data? Thanks!
tl;dr - I need accurate and detailed graphs displaying the stock / indicator values being used by my algorithm.
Daniel Wygant
After some of my own googling, I took a look at Yahoo Finance's charting and it supports all of the extended trading hours that I am receiving in QuantConnect. Thus, I have found a sufficient way to view accurate and detailed graphs of the data that my algorithm is using.
However, I would still appreciate any way of generating / displaying more detailed graphs through QuantConnect (research.ipynb or otherwise) if anyone is aware of it.
Derek Melchin
Hi Daniel,
There seems to be an issue with hourly data not subscribing to pre-market data on the first day in the backtest. I've created a GitHub Issue to have this resolved. Track our progress here. (Will add on approval; See comments for details)
In the research environment, there should be no need to consolidate the data. To get extended hourly data into the research environment, we can use
qb = QuantBook() symbol = qb.AddEquity("UPRO", Resolution.Hour, Market.USA, True, 1, True).Symbol start_date = datetime(2020, 11, 6) end_date = datetime(2020, 11, 11) price_history = qb.History(symbol, start_date, end_date, Resolution.Hour)
Then to get RSI values across this historical period, we can use
qb.Indicator(RelativeStrengthIndex(14), symbol, start_date, end_date, Resolution.Hour)
We can then plot this data using matplotlib. See the attached backtest and research notebook for reference. For more information on indicators in the research environment, review our documentation.
Can you attach a backtest which shows the price discrepancy for UPRO?
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.
Alex Monk
Daniel Wygant Can you please explain to me how were you able to do any type of plotting(Trading view/Yahoo or say Matplot) when you are using Docker? I saw your post and accepted answer which was finding a json in debug dir, but I don't see anything like that. I was expecting either a mathplot, a js or html somewhere. I'd appreciate if you could share your TV or Yahoo porting with me as well. Thanks!
Daniel Wygant
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!