using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data.Fundamental;
using QuantConnect.Data.Market;
using QuantConnect.Data.UniverseSelection;
using QuantConnect.Securities;
namespace QuantConnect.Algorithm.CSharp
{
public class CoarseFineFundamentalComboAlgorithm : QCAlgorithm
{
private Symbol _msft = QuantConnect.Symbol.Create("MSFT", SecurityType.Equity, Market.USA);
public override void Initialize()
{
AddSecurity(SecurityType.Equity, _msft, Resolution.Daily);
UniverseSettings.Resolution = Resolution.Daily;
AddUniverse(coarse => new [] { _msft }, fine => new [] { _msft });
SetStartDate(2019, 03, 01);
SetEndDate(2019, 04, 01);
SetCash(50000);
}
public void OnData(TradeBars data)
{
Security msft;
if (Securities.TryGetValue(_msft, out msft))
{
var f = msft.Fundamentals;
if (f != null && f.ValuationRatios.PERatio > 0)
Log($"{Time} :: {f.ValuationRatios.PERatio}");
}
}
}
}