#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
namespace QuantConnect.Algorithm.CSharp
{
public class FocusedBluePenguin : QCAlgorithm
{
public override void Initialize()
{
SetBenchmark(x => 1);
SetStartDate(2023, 3, 16);
SetCash(100000);
var equity = AddEquity("AAPL");
var option = AddOption(equity.Symbol);
// set our strike/expiry filter for this option chain
option.SetFilter(u => u.Strikes(-2, +2)
// Expiration method accepts TimeSpan objects or integer for days.
// The following statements yield the same filtering criteria
.Expiration(0, 180));
SetWarmUp(TimeSpan.FromDays(2));
}
/// 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 slice)
{
if (slice == null) return;
if (IsWarmingUp) return;
var tickData = new List<string>();
foreach (var tick in slice.Ticks)
{
tickData.Add($"{tick.Key}: {tick.Value}");
}
Log($"data.Time {slice.Time}. data.HasData {slice.HasData}. data.Count {slice.Count} " +
$"data.Bars.Keys: {string.Join(",", slice.Bars.Keys)}" +
$". data.OptionChains: {string.Join(",", slice.OptionChains)}" +
$". data.SymbolChangedEvents: {string.Join(",", slice.SymbolChangedEvents)}" +
$". data.Bars: {string.Join(",", slice.Bars)}" +
$". data.Ticks: {string.Join(" -- ", tickData)}" +
$". data.QuoteBars: {string.Join(",", slice.QuoteBars)}" +
$". data.Values: {string.Join(",", slice.Values)}");
}
}
}