Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $1.00 |
namespace QuantConnect.Algorithm.CSharp { public class ResistanceParticlePrism : QCAlgorithm { Security stock; List<OptionContract> contracts = new List<OptionContract>(); public override void Initialize() { SetStartDate(2019, 12, 8); //Set Start Date SetEndDate(2019, 12, 9); SetCash(100000); //Set Strategy Cash stock = AddEquity("SPY", Resolution.Minute); stock.SetDataNormalizationMode(DataNormalizationMode.Raw); } /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. /// Slice object keyed by symbol containing the stock data public override void OnData(Slice data) { foreach(var symbol in data.OptionChains.Keys) { foreach(var contract in data.OptionChains[symbol].Contracts.Values) { contracts.Add(contract); } } if(contracts.Count == 0){ var symbols = OptionChainProvider.GetOptionContractList(stock.Symbol, Time); var filteredSymbols = symbols .Where(x => x.ID.OptionRight == OptionRight.Put && x.ID.StrikePrice >= stock.Price && (x.ID.Date - Time).TotalDays < 20 && (x.ID.Date - Time).TotalDays > 3) .OrderBy(x => Math.Abs(x.ID.StrikePrice - stock.Price)) .ThenBy(x => (x.ID.Date - Time).TotalDays); foreach(var symbol in filteredSymbols) { var option = AddOptionContract(symbol, Resolution.Minute); option.PriceModel = QuantConnect.Securities.Option.OptionPriceModels.BlackScholes(); } }else{ if(!Portfolio.Invested){ var selected = contracts .OrderBy(x => x.ImpliedVolatility).LastOrDefault(); MarketOrder(selected.Symbol, 1); Debug("BOUGHT " + selected.Symbol + " , with IV: " + selected.ImpliedVolatility); } } } public void CustomSecurityInitializer(Security security){ var bar = GetLastKnownPrice(security); security.SetMarketPrice(bar); } } }