Not really sure why I have to use a consolidator to access minute data? I'm a day trader. ALL of my strategies involve intraday trading. But okay....
I'm looking at your "How to use Consolidators" algorithm in QU. Trying to convince myself of exactly what data this is returning. What line of code would I need to add to see the value of SPY, minute by minute?
//Traditional 1 minute events here:
public void OnData(TradeBars data)
{
Debug("The value of SPY is " + ???????????);
Order("SPY", 100);
}
Crissi Wells
Or even better
Debug("The value of SPY is " + ????? + " and the date and time are " + ??????);
Ray Bohac
If you click "Create New Project" then select C# the "Basic Template C#" template that is loaded does exactly what you are asking for. Note: That for backtesting it is against the terms of service to log price data. However for live your exact debug statement would be
Debug("The value of SPY on " +data["SPY"].Close.ToString("#.##")+ " and the date and time are " + Time.ToShortDateString());
Ray Bohac
Its also advisable to check the data array first to make sure it contains the key you are looking for. so...
if (data.ContainsKey("SPY"))
{
// Do stuff
}
Crissi Wells
Most excellent! Thank you! I was missing the ToString("#.##") part.
Have a great w/e!
Ray Bohac
Sure thing. Also about the consolidators: Equity data is pre-consolidated for you at resolutions of Tick, Sec, Min, Hour, Daily. See "Data Library" at https://www.quantconnect.com/docs
So when you use AddSecurity you can pass it the resolution you would like. Consolidators are handy when you want other resolutions (say 10 minutes) etc
As an example:
AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
AddSecurity(SecurityType.Equity, "SPY", Resolution.Hour);
AddSecurity(SecurityType.Equity, "SPY", Resolution.Tick); // Note this comes in its own OnData event .See https://www.quantconnect.com/docs#Handling-Data
Crissi Wells
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!