Overall Statistics Total Trades0Average Win0%Average Loss0%Compounding Annual Return0%Drawdown0%Expectancy0Net Profit0%Sharpe Ratio0Loss Rate0%Win Rate0%Profit-Loss Ratio0Alpha0Beta0Annual Standard Deviation0Annual Variance0Information Ratio0Tracking Error0Treynor Ratio0Total Fees\$0.00
```using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data.Fundamental;
using QuantConnect.Data.Market;
using QuantConnect.Data.UniverseSelection;

using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Orders;
using QuantConnect.Securities.Option;
using System.Collections.Generic;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// In this algorithm we demonstrate how to define a universe
/// as a combination of use the coarse fundamental data and fine fundamental data
/// </summary>
public class CoarseFineFundamentalComboAlgorithm : QCAlgorithm
{
private const int NumberOfSymbolsCoarse = 5;
private const int NumberOfSymbolsFine = 2;

// initialize our changes to nothing
private SecurityChanges _changes = SecurityChanges.None;

public override void Initialize()
{
UniverseSettings.Resolution = Resolution.Daily;

SetStartDate(2016, 03, 01);
SetEndDate(2016, 03, 10);
SetCash(10000);

// this add universe method accepts two parameters:
// - coarse selection function: accepts an IEnumerable<CoarseFundamental> and returns an IEnumerable<Symbol>
// - fine selection function: accepts an IEnumerable<FineFundamental> and returns an IEnumerable<Symbol>
}

// sort the data by daily dollar volume and take the top 'NumberOfSymbolsCoarse'
public IEnumerable<Symbol> CoarseSelectionFunction(IEnumerable<CoarseFundamental> coarse)
{
// select only symbols with fundamental data and sort descending by daily dollar volume
var sortedByDollarVolume = coarse
.Where(x => x.HasFundamentalData)
.OrderByDescending(x => x.DollarVolume);

// take the top entries from our sorted collection
var top5 = sortedByDollarVolume.Take(15);

// we need to return only the symbol objects
}

// sort the data by P/E ratio and take the top 'NumberOfSymbolsFine'
public IEnumerable<Symbol> FineSelectionFunction(IEnumerable<FineFundamental> fine)
{
return fine.Where(x =>

// More than 7 days after earnings report

// Invalid FileDate
x.EarningReports.FileDate != new DateTime())

.Take(5)
.Select(x => x.Symbol);
}

//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
public override void OnData(Slice data)        {
foreach (var kvp in data.OptionChains) {
var symbol = kvp.Key;
var chain = kvp.Value;

.OrderBy(x => Math.Abs(chain.Underlying.Price - x.Strike))
.ThenByDescending(x => x.Expiry)
.FirstOrDefault();

if (atmStraddle != null && !Portfolio.Invested)
{
}
}

_changes = SecurityChanges.None;
}

// this event fires whenever we have changes to our universe
public override void OnSecuritiesChanged(SecurityChanges changes)
{
_changes = changes;

{
}
if (changes.RemovedSecurities.Count > 0)
{
Debug("Securities removed: " + string.Join(",", changes.RemovedSecurities.Select(x => x.Symbol.Value)));
}
foreach (var security in changes.RemovedSecurities)
{
if (security.Invested)
{
Liquidate(security.Symbol);
}
}

}
}
}```