| Overall Statistics |
|
Total Trades 510 Average Win 1.94% Average Loss -3.20% Compounding Annual Return -30.943% Drawdown 89.700% Expectancy -0.138 Net Profit -51.136% Sharpe Ratio 0.005 Loss Rate 46% Win Rate 54% Profit-Loss Ratio 0.61 Alpha 0.012 Beta -0.258 Annual Standard Deviation 0.665 Annual Variance 0.442 Information Ratio -0.046 Tracking Error 0.681 Treynor Ratio -0.012 Total Fees $1044.43 |
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 xiv = "XIV";
string tvix = "TVIX";
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(2015, 1, 1);
SetEndDate(DateTime.Now.Date.AddDays(-1));
SetCash(25000);
AddSecurity(SecurityType.Equity, xiv, Resolution.Minute);
AddSecurity(SecurityType.Equity, tvix, Resolution.Minute);
AddData<Quandl>(VXV, Resolution.Daily);
AddData<Quandl>(VIX, Resolution.Daily);
}
/// <summary>
/// Event - v3.0 DATA EVENT HANDLER: Basic template for user to override for receiving all subscription data in a single event
/// </summary>
/// <code>
/// TradeBars bars = slice.Bars;
/// Ticks ticks = slice.Ticks;
/// TradeBar spy = slice["SPY"];
/// List<Tick> aaplTicks = slice["AAPL"]
/// Quandl oil = slice["OIL"]
/// dynamic anySymbol = slice[symbol];
/// DataDictionary<Quandl> allQuandlData = slice.Get<Quand>
/// Quandl oil = slice.Get<Quandl>("OIL")
/// </code>
/// <param name="slice">The current slice of data keyed by symbol string</param>
public void OnData(Slice data)
{
// gets all Quandl data from our 'Slice' object
var quandls = data.Get<Quandl>();
if (!quandls.ContainsKey(VIX) || !quandls.ContainsKey(VXV)) return;
// add logic to have orders placed once / day
// IVTS = VIX / VXV
IVTS = quandls[VXV].Value / quandls[VIX].Value;
if (IVTS < 0.923m)
{
Liquidate(xiv);
SetHoldings(xiv, -1);
} else
{
Liquidate(xiv);
SetHoldings(xiv, 1);
}
}
}
}