Back

How to get (equity-)Tick-Data for the last 2 (trading-)Days?

Hey,

I've checked the Documentation (https://www.quantconnect.com/docs/algorithm-reference/historical-data) but could not find any examples for handling historical Tick data.

5 Minutes before the Market opens I want to process the Tick-Data of the last 2 trading days to make a guess for the upcoming session. Its very important that the last 2 days are trading days (e.g on a Monday I want to process Thursday and Friday). 

Any hints how to achieve this?

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.


Hey Paul, 

you can do this by 

first adding the stocks you want to trade in initialize

second adding a schedule function that is executed everyday before the market opens 

third getting the historical data ( which was your question) with: 

history = self.History(self.Securities.Keys, 2, Resolution.Daily)

this returns a pandas dataframe. 

for reference you can have a look at the algorithm I posted a few days ago: 

https://www.quantconnect.com/forum/discussion/7388/inside-bar-momentum-strategy-from-babypips/p1

and you can consult the documentation 

https://www.quantconnect.com/docs/algorithm-reference/historical-data

 

0

FoolishObserver: "history = self.History(self.Securities.Keys, 2, Resolution.Daily)"

This only gives me 2 daily bars but not the tickdata.

0

ahh i see, sorry for the confusion: 

I think the main problem is that there can be multiple ticks per second so you can not be too sure of how many observations you have to look back. You could, however, change the code below to look back >2 days and then only select the relevant data according to the timestamp.  

lookback = 2*24*60*60 # number of seconds in 2 days

history = self.History(self.Securities.Keys, lookback, Resolution.Tick) 

hope this helps!

0

Hey Paul,

Tick data is raw unfiltered data. There may be bad ticks which skew your trade results. You can learn about how to handle tick data in the documenation.

All the tick data from a given second is grouped together in backtesting. This means you can follow FoolishObserver's logic to retrieve the lookback period for the history call. 

Best
Rahul

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