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.
OnDatal(Quandl _symbol1)
{
s1 = _symbol1.Value;
}
OnDatal(Quandl _symbol2)
{
s2 = _symbol2.Value;
}
OnDatal(TradeBars data)
{
someFunc = s1/s2;
}
int quandlCount = 4;
Dictionary<string, Quandl> _quandls = new Dictionary<string, Quandl>()
public void OnData(Quandl object) {
_quandls[object.Symbol] = object;
if (_quandls.Count != quandlCount) return;
//Use _quandls.
}
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.
namespace QuantConnect
{
/*
* QuantConnect University: Futures Example
*
* QuantConnect allows importing generic data sources! This example demonstrates importing a futures
* data from the popular open data source Quandl.
*
* QuantConnect has a special deal with Quandl giving you access to Stevens Continuous Futurs (SCF) for free.
* If you'd like to download SCF for local backtesting, you can download it through Quandl.com.
*/
public class VolatilityETN : QCAlgorithm
{
string shortTerm = "VXX";
string longTerm = "VXZ";
decimal IVTS = new decimal();
string VIX = "YAHOO/INDEX_VIX";
string VXV = "CBOEFE/INDEX_VXV";
DateTime sampledToday = DateTime.Now;
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{
SetStartDate(2004, 1, 1);
SetEndDate(DateTime.Now.Date.AddDays(-1));
SetCash(25000);
AddSecurity(SecurityType.Equity, shortTerm, Resolution.Minute);
AddSecurity(SecurityType.Equity, longTerm, Resolution.Minute);
AddData(VXV, Resolution.Daily);
AddData(VIX, Resolution.Daily);
}
int quandlCount = 2;
Dictionary _quandls = new Dictionary();
public void OnData(Quandl object)
{
_quandls[object.Symbol] = object;
if (_quandls.Count != quandlCount) return;
//Use _quandls.
}
//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
public void OnData(TradeBars data)
{
// add logic to have orders placed once / day
// IVTS = VIX / VXV
// Add buy/sell logic
}
}
}
///
/// Event - v3.0 DATA EVENT HANDLER: Basic template for user to override for receiving all subscription data in a single event
///
/// TradeBars bars = slice.Bars;
/// Ticks ticks = slice.Ticks;
/// TradeBar spy = slice["SPY"];
/// List aaplTicks = slice["AAPL"]
/// Quandl oil = slice["OIL"]
/// dynamic anySymbol = slice[symbol];
/// DataDictionary allQuandlData = slice.Get
/// Quandl oil = slice.Get("OIL")
/// The current slice of data keyed by symbol string
public void OnData(Slice data)
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.
Sorry for dredging this up again, but the quandl data invoked in the example code Michael provided contains multiple columns. What column does the property '.Value' represent, and how does it know which column to associate with?
Value is assumed to be Close, if there's no close it won't have a Value and you'll have to set it. See QCU algorithm "How do I import futures data?" for an example of using "Settlement" column as the Value column which we use for the trade price.
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!