Esempio n. 1
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            Stop();

            _syncLock.EnterWriteLock();
            try
            {
                _stopEvent.DisposeSafely();
                _lightTeamLogicExecutor.DisposeSafely();
                _darkTeamLogicExecutor.DisposeSafely();

                _makeMoveEvent.DisposeSafely();

                _disposed = true;
            }
            finally
            {
                _syncLock.ExitWriteLock();
            }

            _syncLock.DisposeSafely();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes the data feed for the specified job and algorithm
        /// </summary>
        public void Initialize(IAlgorithm algorithm,
                               AlgorithmNodePacket job,
                               IResultHandler resultHandler,
                               IMapFileProvider mapFileProvider,
                               IFactorFileProvider factorFileProvider,
                               IDataProvider dataProvider,
                               IDataFeedSubscriptionManager subscriptionManager,
                               IDataFeedTimeProvider dataFeedTimeProvider,
                               IDataChannelProvider dataChannelProvider)
        {
            if (!(job is LiveNodePacket))
            {
                throw new ArgumentException("The LiveTradingDataFeed requires a LiveNodePacket.");
            }

            _cancellationTokenSource = new CancellationTokenSource();

            _job                  = (LiveNodePacket)job;
            _timeProvider         = dataFeedTimeProvider.TimeProvider;
            _dataProvider         = dataProvider;
            _mapFileProvider      = mapFileProvider;
            _factorFileProvider   = factorFileProvider;
            _channelProvider      = dataChannelProvider;
            _frontierTimeProvider = dataFeedTimeProvider.FrontierTimeProvider;
            _customExchange       = new BaseDataExchange("CustomDataExchange")
            {
                SleepInterval = 10
            };
            _subscriptions = subscriptionManager.DataFeedSubscriptions;

            _dataQueueHandler = GetDataQueueHandler();
            _dataQueueHandler?.SetJob(_job);

            // run the custom data exchange
            var manualEvent = new ManualResetEventSlim(false);

            Task.Factory.StartNew(() =>
            {
                manualEvent.Set();
                _customExchange.Start(_cancellationTokenSource.Token);
            }, TaskCreationOptions.LongRunning);
            manualEvent.Wait();
            manualEvent.DisposeSafely();

            IsActive = true;
        }
Esempio n. 3
0
 /// <summary>
 /// Free resources
 /// </summary>
 public override void Dispose()
 {
     _newLiveDataEmitted.Set();
     _newLiveDataEmitted?.DisposeSafely();
     _realTimeScheduleEventService?.DisposeSafely();
 }