示例#1
0
        public void Setup()
        {
            var start = new DateTime(2020, 1, 1);
            var end   = new DateTime(2020, 1, 2);

            // initialize using a seed for deterministic tests
            _symbol = Symbol.Create("AAPL", SecurityType.Equity, Market.USA);

            _security = new Security(
                SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork),
                new SubscriptionDataConfig(typeof(TradeBar),
                                           _symbol,
                                           Resolution.Minute,
                                           TimeZones.NewYork,
                                           TimeZones.NewYork,
                                           true, true, false),
                new Cash(Currencies.USD, 0, 0),
                SymbolProperties.GetDefault(Currencies.USD),
                ErrorCurrencyConverter.Instance,
                RegisteredSecurityDataTypesProvider.Null,
                new SecurityCache()
                );
            _security.SetMarketPrice(new Tick(start, _security.Symbol, 100, 100));
            _security.SetMarketPrice(new OpenInterest(start, _security.Symbol, 10000));

            _tickGenerator = new TickGenerator(
                new RandomDataGeneratorSettings()
            {
                Start = start,
                End   = end
            },
                _tickTypesPerSecurityType[_symbol.SecurityType].ToArray(),
                _security,
                new RandomValueGenerator());
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MidiClock"/> with the specified
        /// value indicating whether first tick should be generated immediately after clock started, and
        /// tick generator.
        /// </summary>
        /// <param name="startImmediately">A value indicating whether first tick should be generated
        /// immediately after clock started.</param>
        /// <param name="tickGenerator">Tick generator used as timer firing at the specified interval. Null for
        /// no tick generator.</param>
        public MidiClock(bool startImmediately, ITickGenerator tickGenerator)
        {
            _startImmediately = startImmediately;

            _tickGenerator = tickGenerator;
            if (_tickGenerator != null)
            {
                _tickGenerator.TickGenerated += OnTickGenerated;
            }
        }
示例#3
0
        public TickManagerImpl(ITickGenerator tickGenerator)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                TimeBeginPeriod(1);
            }

            _tickFrequency = Stopwatch.Frequency;
            _tickGenerator = tickGenerator;

            long nanoSecondsPerSecond = TimeSpan.FromSeconds(1).GetNanoSeconds();

            if (_tickFrequency <= nanoSecondsPerSecond)
            {
                _maxTick     = _tickFrequency * (long.MaxValue / nanoSecondsPerSecond);
                _maxTimeSpan = TimeSpan.FromNanoSeconds(long.MaxValue);
            }
            else
            {
                _maxTick     = long.MaxValue;
                _maxTimeSpan = TimeSpan.FromSeconds(long.MaxValue / _tickFrequency);
            }
        }
示例#4
0
 // Todo: Use configuration object if/when more options are added
 internal OsState(HorizonClient horizonClient, ITickGenerator tickGenerator)
 {
     Hos             = horizonClient;
     ResourceManager = new OsResourceManager(tickGenerator);
 }
示例#5
0
 public TickManager(ITickGenerator tickGenerator) => _impl = new TickManagerImpl(tickGenerator);
示例#6
0
 // Todo: Use configuration object if/when more options are added
 public OsResourceManager(ITickGenerator tickGenerator)
 {
     TickManager = new TickManager(tickGenerator);
 }