Overall Statistics |
Total Orders 36 Average Win 41.69% Average Loss -6.18% Compounding Annual Return -80.287% Drawdown 85.000% Expectancy -0.742 Net Profit -80.346% Sharpe Ratio -1.135 Sortino Ratio -0.78 Probabilistic Sharpe Ratio 0.003% Loss Rate 97% Win Rate 3% Profit-Loss Ratio 6.74 Alpha -0.825 Beta 1.261 Annual Standard Deviation 0.548 Annual Variance 0.3 Information Ratio -1.832 Tracking Error 0.428 Treynor Ratio -0.493 Total Fees $0.00 Estimated Strategy Capacity $1000.00 Lowest Capacity Asset VIX XNUJM2J12SJ2|VIX 31 Portfolio Turnover 1.80% |
#region imports using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Globalization; using System.Drawing; using QuantConnect; using QuantConnect.Algorithm.Framework; using QuantConnect.Algorithm.Framework.Selection; using QuantConnect.Algorithm.Framework.Alphas; using QuantConnect.Algorithm.Framework.Portfolio; using QuantConnect.Algorithm.Framework.Execution; using QuantConnect.Algorithm.Framework.Risk; using QuantConnect.Algorithm.Selection; using QuantConnect.Parameters; using QuantConnect.Benchmarks; using QuantConnect.Brokerages; using QuantConnect.Util; using QuantConnect.Interfaces; using QuantConnect.Algorithm; using QuantConnect.Indicators; using QuantConnect.Data; using QuantConnect.Data.Consolidators; using QuantConnect.Data.Custom; using QuantConnect.DataSource; using QuantConnect.Data.Fundamental; using QuantConnect.Data.Market; using QuantConnect.Data.UniverseSelection; using QuantConnect.Notifications; using QuantConnect.Orders; using QuantConnect.Orders.Fees; using QuantConnect.Orders.Fills; using QuantConnect.Orders.Slippage; using QuantConnect.Scheduling; using QuantConnect.Securities; using QuantConnect.Securities.Equity; using QuantConnect.Securities.Future; using QuantConnect.Securities.Option; using QuantConnect.Securities.Forex; using QuantConnect.Securities.Crypto; using QuantConnect.Securities.Interfaces; using QuantConnect.Storage; using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm; #endregion using QuantConnect.DataSource; namespace QuantConnect { public class VixBullSpreadAlgorithm : QCAlgorithm { private Symbol _optionSymbol; public override void Initialize() { SetStartDate(2020, 1, 1); SetEndDate(2021, 1, 1); SetCash(200000); UniverseSettings.Asynchronous = true; var index = AddIndex("VIX"); var option = AddOption(index.Symbol); option.SetFilter(-2, +2, 0, 180); _optionSymbol = option.Symbol; } public override void OnData(Slice slice) { if (!Portfolio.Invested && IsMarketOpen(_optionSymbol)) { OptionChain chain; if (slice.OptionChains.TryGetValue(_optionSymbol, out chain)) { var callContracts = chain .Where(contract => contract.Right == OptionRight.Call) .OrderByDescending(x => x.Expiry) .ThenBy(x => x.Strike) .ToList(); if (callContracts.Count < 2) { return; } var longCall = callContracts.First(); var shortCall = callContracts.First(contract => contract.Strike > longCall.Strike && contract.Expiry == longCall.Expiry); // Use all the buying power var quantity = new[] { CalculateOrderQuantity(shortCall.Symbol, -1m), CalculateOrderQuantity(longCall.Symbol, 1m) } .Min(x=> Math.Abs(x)); MarketOrder(shortCall.Symbol, -quantity); MarketOrder(longCall.Symbol, quantity); var expectedMarginUsage = Math.Max((longCall.Strike - shortCall.Strike) * Securities[longCall.Symbol].SymbolProperties.ContractMultiplier * quantity, 0); if (expectedMarginUsage != Portfolio.TotalMarginUsed) { throw new Exception("Unexpect margin used!"); } } } } public override void OnSecuritiesChanged(SecurityChanges changes) { foreach (var security in changes.AddedSecurities) { if (security.Type == SecurityType.IndexOption) { // Historical data var history = History(security.Symbol, 10, Resolution.Minute); Debug($"We got {history.Count()} from our history request for {security.Symbol}"); } } } } }