Ejemplo n.º 1
0
 /// <summary>
 /// Gets the <see cref="CoarseFundamental"/> data for the specified market/date
 /// </summary>
 public static IEnumerable<CoarseFundamental> GetCoarseFundamentals(string market, DateTimeZone timeZone, DateTime date, bool isLiveMode)
 {
     var factory = new CoarseFundamental();
     var config = new SubscriptionDataConfig(typeof(CoarseFundamental), SecurityType.Equity, new Symbol(market + "-coarse"), Resolution.Daily, market, timeZone, true, false, true);
     var reader = new BaseDataSubscriptionFactory(config, date, isLiveMode);
     var source = factory.GetSource(config, date, isLiveMode);
     return reader.Read(source).OfType<CoarseFundamental>();
 }
Ejemplo n.º 2
0
        private void AddSubscriptionForUniverseSelectionMarket(string market)
        {
            var exchangeHours = SecurityExchangeHoursProvider.FromDataFolder().GetExchangeHours(market, null, SecurityType.Equity);
            var symbolName = new Symbol(market + "-coarse");
            var subscriptionDataConfig = new SubscriptionDataConfig(typeof (CoarseFundamental), SecurityType.Equity, symbolName, Resolution.Daily, market, exchangeHours.TimeZone,
                true, false, true);
            var security = new Security(exchangeHours, subscriptionDataConfig, 1);

            var cf = new CoarseFundamental();
            var list = new List<BaseData>();
            foreach (var date in Time.EachTradeableDay(security, _algorithm.StartDate, _algorithm.EndDate))
            {
                var factory = new BaseDataSubscriptionFactory(subscriptionDataConfig, date, false);
                var source = cf.GetSource(subscriptionDataConfig, date, false);
                var coarseFundamentalForDate = factory.Read(source);
                list.AddRange(coarseFundamentalForDate);
            }

            // spoof a subscription for the market that emits at midnight of each tradeable day
            var subscription = new Subscription(security,
                list.GetEnumerator(),
                _algorithm.StartDate.ConvertToUtc(exchangeHours.TimeZone),
                _algorithm.EndDate.ConvertToUtc(exchangeHours.TimeZone),
                false,
                true
                );

            // let user know if we fail to load the universe subscription, very important for when understanding backtest results!
            PrimeSubscriptionPump(subscription, true);
            _subscriptions.AddOrUpdate(new SymbolSecurityType(subscription), subscription);
        }
Ejemplo n.º 3
0
        private void AddSubscriptionForUniverseSelectionMarket(string market)
        {
            var usaMarket = SecurityExchangeHoursProvider.FromDataFolder().GetExchangeHours(market, null, SecurityType.Equity);
            var symbolName = market + "-market";
            var usaConfig = new SubscriptionDataConfig(typeof (CoarseFundamental), SecurityType.Equity, symbolName, Resolution.Daily, market, usaMarket.TimeZone,
                true, false, false, false, true);
            var usaMarketSecurity = new Security(usaMarket, usaConfig, 1);

            var cf = new CoarseFundamental();
            var list = new List<BaseData>();
            foreach (var date in Time.EachTradeableDay(usaMarketSecurity, _algorithm.StartDate, _algorithm.EndDate))
            {
                var factory = new BaseDataSubscriptionFactory(usaConfig, date, false);
                var source = cf.GetSource(usaConfig, date, false);
                var coarseFundamentalForDate = factory.Read(source);
                list.AddRange(coarseFundamentalForDate);
            }

            // spoof a subscription for the USA market that emits at midnight of each tradeable day
            var usaMarketSubscription = new Subscription(usaMarketSecurity,
                list.GetEnumerator(),
                _algorithm.StartDate.ConvertToUtc(usaMarket.TimeZone),
                _algorithm.EndDate.ConvertToUtc(usaMarket.TimeZone),
                false,
                true
                );

            // prime the pump
            usaMarketSubscription.MoveNext();
            _subscriptions.AddOrUpdate(new SymbolSecurityType(usaMarketSubscription), usaMarketSubscription);
        }