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.
using System;
using System.Linq;
using System.Collections.Generic;
using QuantConnect.Securities;
using QuantConnect.Models;
namespace QuantConnect
{
// Name your algorithm class anything, as long as it inherits QCAlgorithm
public class BasicTemplateAlgorithm : QCAlgorithm
{
decimal open = 0m;
decimal close = 0m;
private Consolidator oneDayConsol;
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{
SetStartDate(2014, 12, 01);
SetEndDate(2014, 12, 03);
SetCash(1000);
AddSecurity(SecurityType.Equity, "SPY", Resolution.Tick);
oneDayConsol = new Consolidator(TimeSpan.FromDays(1));
Log("ACTUAL VALUES:");
Log("12/01/14: Open: 206.40, Close: 205.76");
Log("12/02/14: Open: 205.81, Close: 207.09");
//Log("12/03/14: Open: 207.30, Close: 207.89");
Log("====================================");
Log("EVALUATED VALUES:");
}
Tick last;
Tick first;
public void OnData(Ticks ticks)
{
List tick;
if (ticks.TryGetValue("SPY", out tick))
{
// im not sure how the ticks are ordered in the list,
// sadly DateTime doesn't provide decent precision so we don't know
// who was actually the first
if (first == null)
{
first = tick.First();
}
last = tick.Last();
}
}
public override void OnEndOfDay()
{
Log("TICK: Open: " + first.Value.ToString(".00") + " Close: " + last.Value.ToString(".00"));
first = null;
}
}
}
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.
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.
...the price you see on yahoo and google finance aren't created by actual trades! :) It was set by a human who makes the representative price for the open and closing.
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.
Hello,
I know it's been 2 years since the last comment in this thread, but I was wondering whether or not there was now a solution to get the "official" daily closing price, instead of the close of the last bar of the day which often still differs from the official close.
@Fred - "solution to get the "official" daily closing price"; yes what we have in place is a good solution which statistically matches the vast majority of symbols with minimum error. The majority of the time matching precisely.
If you're using intraday data you'll get the last intraday bar. For daily data we use the ticks marked as the closing ticks from the exchanges. We get a bunch of ticks all marked as closing so we pick the best one we can which match Yahoo etc closest as possible. All other public sources also differ so there's no one price. I think it depends on which exchange the physical MarketOnClose order is sitting.
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.
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!