Hi, I am just getting my head around universes but I am having one simple problem. I cant get a symbol to put in my schedule function.
Attached is the code. Essentially I am using the top5DollarVolume coarse universe example. But I want to trigger a schedule function and need one symbol for the date rule part.
You can see i have created logs to try get a symbol, but I am not sure if any symbols are added to my unverse in the first place.
using Accord;
using MathNet.Numerics.Statistics;
namespace QuantConnect.Algorithm.CSharp
{
public class prev_day_change : QCAlgorithm
{
private const int NumberOfSymbols = 5;
private SecurityChanges _changes = SecurityChanges.None;
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
public override void Initialize()
{
//SetWarmUp(TimeSpan.FromDays(2)); //Warm up 30 days of data.
UniverseSettings.Resolution = Resolution.Minute;
SetStartDate(2013, 10, 07); //Set Start Date //SetStartDate(2013, 10, 07);
SetEndDate(2013, 10, 11); //Set End Date
SetCash(10000); //Set Strategy Cash
// Find more symbols here: http://quantconnect.com/data
AddUniverse(CoarseSelectionFunction);
Log("beginning:" + _changes.AddedSecurities.Count);
Log("securities.values" + Securities.Values);
foreach (var security in _changes.AddedSecurities)
{
Log("test security:" + security.Symbol);
}
var a = 1;
//Schedule function that runs 60 min after open every day
Schedule.On(DateRules.EveryDay(SYMBOL), TimeRules.AfterMarketOpen(SYMBOL, 10), () =>
{
//Create a function that calls the functions I want to call and put it here
testFunction();
});
}
public static IEnumerable<Symbol> CoarseSelectionFunction(IEnumerable<CoarseFundamental> coarse)
{
// sort descending by daily dollar volume
var sortedByDollarVolume = coarse.OrderByDescending(x => x.DollarVolume);
// take the top entries from our sorted collection
var top5 = sortedByDollarVolume.Take(NumberOfSymbols);
// we need to return only the symbol objects
return top5.Select(x => x.Symbol);
}