• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IAlgorithm类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IAlgorithm的典型用法代码示例。如果您正苦于以下问题:C# IAlgorithm类的具体用法?C# IAlgorithm怎么用?C# IAlgorithm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IAlgorithm类属于命名空间,在下文中一共展示了IAlgorithm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FileSystemDataFeed

        /********************************************************
        * CLASS CONSTRUCTOR
        *********************************************************/
        /// <summary>
        /// Create a new backtesting data feed.
        /// </summary>
        /// <param name="algorithm">Instance of the algorithm</param>
        /// <param name="job">Algorithm work task</param>
        public FileSystemDataFeed(IAlgorithm algorithm, BacktestNodePacket job)
        {
            Subscriptions = algorithm.SubscriptionManager.Subscriptions;
            _subscriptions = Subscriptions.Count;

            //Public Properties:
            DataFeed = DataFeedEndpoint.FileSystem;
            IsActive = true;
            Bridge = new ConcurrentQueue<List<BaseData>>[_subscriptions];
            EndOfBridge = new bool[_subscriptions];
            SubscriptionReaders = new SubscriptionDataReader[_subscriptions];
            FillForwardFrontiers = new DateTime[_subscriptions];
            RealtimePrices = new List<decimal>(_subscriptions);

            //Class Privates:
            _job = job;
            _algorithm = algorithm;
            _endOfStreams = false;
            _bridgeMax = _bridgeMax / _subscriptions; //Set the bridge maximum count:

            for (var i = 0; i < _subscriptions; i++)
            {
                //Create a new instance in the dictionary:
                Bridge[i] = new ConcurrentQueue<List<BaseData>>();
                EndOfBridge[i] = false;
                SubscriptionReaders[i] = new SubscriptionDataReader(Subscriptions[i], _algorithm.Securities[Subscriptions[i].Symbol], DataFeed, _job.PeriodStart, _job.PeriodFinish);
                FillForwardFrontiers[i] = new DateTime();
            }
        }
开发者ID:sopnic,项目名称:Lean,代码行数:37,代码来源:FileSystemDataFeed.cs


示例2: Approach

 public Approach(string title, int warmupRounds, int benchmarkRounds, IAlgorithm algorithm)
 {
     Title = title;
     WarmupRounds = warmupRounds;
     BenchmarkRounds = benchmarkRounds;
     Algorithm = algorithm;
 }
开发者ID:cthibault,项目名称:projecteuler,代码行数:7,代码来源:Approach.cs


示例3: UpdateKnn

        /// <summary>
        /// Missing mapping to P objects
        /// KdTree could be refactored to use P object instead of Math.Net
        /// 
        /// O(k * log n) 
        /// </summary>
        /// <param name="s"></param>
        /// <param name="origin"></param>
        /// <param name="k"></param>
        /// <param name="conf"></param>        
        /// <returns></returns>
        public long UpdateKnn(IAlgorithm s, IP origin, KnnConfiguration conf)
        {
            if (conf == null) conf = new KnnConfiguration();
            if (conf.SameTypeOnly) throw new NotImplementedException();
            if (conf.MaxDistance.HasValue) throw new NotImplementedException();

            var sw = new Stopwatch();
            sw.Start();

            var vector = new DenseVector(new[] { origin.X, origin.Y });
            var nn = Tree.FindNearestNNeighbors(vector, conf.K).ToList();

            s.Knn.Clear();
            s.Knn.Origin = origin;
            s.Knn.K = conf.K;
            foreach (var i in nn)
            {
                var p = new P { X = i[0], Y = i[1] };
                var dist = origin.Distance(p.X,p.Y);
                s.Knn.NNs.Add(new PDist {Point = p, Distance = dist});
            }

            sw.Stop();
            return sw.ElapsedMilliseconds;
        }
开发者ID:kunukn,项目名称:single-detect,代码行数:36,代码来源:KdTreeStrategy.cs


示例4: UpdateSingles

        /// <summary>
        ///  O(n^2)
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public long UpdateSingles(IAlgorithm s)
        {
            var sw = new Stopwatch();
            sw.Start();

            s.Singles.Clear();

            var n = s.Points.Count;
            for (var i = 0; i < n; i++)
            {
                var p1 = s.Points[i];
                var add = true;
                for (var j = 0; j < n; j++)
                {
                    if (i == j) continue;

                    var p2 = s.Points[j];
                    var dist = p1.Distance(p2.X, p2.Y);
                    if (!(dist > s.Rectangle.MaxDistance))
                    {
                        add = false;
                        break;
                    }
                }
                if (add) s.Singles.Add(p1);
            }

            sw.Stop();
            return sw.ElapsedMilliseconds;
        }
开发者ID:kunukn,项目名称:single-detect,代码行数:35,代码来源:NaiveStrategy.cs


示例5: DataPlanner

        /// <summary>
        /// Initializes a new instance of the <see cref="DataPlanner&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="algorithm">The algorithm.</param>
        public DataPlanner(IAlgorithm algorithm)
        {
            if (algorithm == null)
                throw new ArgumentNullException("algorithm");

            m_Algorithm = algorithm;
        }
开发者ID:pavkam,项目名称:school,代码行数:11,代码来源:DataPlanner.cs


示例6: Initialize

        public void Initialize(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler, IMapFileProvider mapFileProvider)
        {
            if (algorithm.SubscriptionManager.Subscriptions.Count == 0 && algorithm.Universes.IsNullOrEmpty())
            {
                throw new Exception("No subscriptions registered and no universe defined.");
            }

            _algorithm = algorithm;
            _resultHandler = resultHandler;
            _mapFileProvider = mapFileProvider;
            _subscriptions = new ConcurrentDictionary<Symbol, Subscription>();
            _cancellationTokenSource = new CancellationTokenSource();

            IsActive = true;
            Bridge = new BusyBlockingCollection<TimeSlice>(100);

            var ffres = Time.OneSecond;
            _fillForwardResolution = Ref.Create(() => ffres, res => ffres = res);

            // find the minimum resolution, ignoring ticks
            ffres = ResolveFillForwardResolution(algorithm);

            // add each universe selection subscription to the feed
            foreach (var universe in _algorithm.Universes)
            {
                var startTimeUtc = _algorithm.StartDate.ConvertToUtc(_algorithm.TimeZone);
                var endTimeUtc = _algorithm.EndDate.ConvertToUtc(_algorithm.TimeZone);
                AddUniverseSubscription(universe, startTimeUtc, endTimeUtc);
            }
        }
开发者ID:tremblayEric,项目名称:LeanHistory,代码行数:30,代码来源:FileSystemDataFeed.cs


示例7: TagCloudBuilder

 public TagCloudBuilder(IWordsReader reader, IAlgorithm algorithm, IImageWriter writer, IWordsFilter filter)
 {
     this.filter = filter;
     this.reader = reader;
     this.algorithm = algorithm;
     this.writer = writer;
 }
开发者ID:MyauMyauMyau,项目名称:03-design-hw,代码行数:7,代码来源:TagCloudBuilder.cs


示例8: HomeController

 public HomeController(IAlgorithm algorithm, IArrayRepository arrayRepository, IParametersRepository parametersRepository, IResultRepository resultRepository)
 {
     Algorithm = algorithm;
     _arrayRepository = arrayRepository;
     _parametersRepository = parametersRepository;
     _resultRepository = resultRepository;
 }
开发者ID:LexaGal,项目名称:MVC-1,代码行数:7,代码来源:HomeController.cs


示例9: TagCloudBuilder

 public TagCloudBuilder(IWordsReader reader, IWordNormalizer normalizer, IWordFilter filter, IAlgorithm algorithm)
 {
     this.reader = reader;
     this.normalizer = normalizer;
     this.filter = filter;
     this.algorithm = algorithm;
 }
开发者ID:KuchumovIlya,项目名称:03-design-hw,代码行数:7,代码来源:TagCloudBuilder.cs


示例10: TestLiveTradingDataFeed

 /// <summary>
 /// Creates a test live trading data feed with the specified fast forward factor
 /// </summary>
 /// <param name="algorithm">The algorithm under analysis</param>
 /// <param name="job">The job for the algorithm</param>
 public TestLiveTradingDataFeed(IAlgorithm algorithm, LiveNodePacket job)
     : base(algorithm, job)
 {
     _start = DateTime.Now;
     _current = DateTime.Now;
     _tickResolution = TimeSpan.FromSeconds(1);
 }
开发者ID:intelliBrain,项目名称:Lean,代码行数:12,代码来源:TestLiveTradingDataFeed.cs


示例11: LiveTradingDataFeed

        /********************************************************
        * CLASS CONSTRUCTOR
        *********************************************************/
        /// <summary>
        /// Live trading datafeed handler provides a base implementation of a live trading datafeed. Derived types
        /// need only implement the GetNextTicks() function to return unprocessed ticks from a data source.
        /// This creates a new data feed with a DataFeedEndpoint of LiveTrading.
        /// </summary>
        /// <param name="algorithm">Algorithm requesting data</param>
        protected LiveTradingDataFeed(IAlgorithm algorithm)
        {
            //Subscription Count:
            _subscriptions = algorithm.SubscriptionManager.Subscriptions;

            //Set Properties:
            _dataFeed = DataFeedEndpoint.LiveTrading;
            _isActive = true;
            _bridge = new ConcurrentQueue<List<BaseData>>[Subscriptions.Count];
            _endOfBridge = new bool[Subscriptions.Count];
            _subscriptionManagers = new SubscriptionDataReader[Subscriptions.Count];
            _realtimePrices = new List<decimal>();

            //Class Privates:
            _algorithm = algorithm;

            //Setup the arrays:
            for (var i = 0; i < Subscriptions.Count; i++)
            {
                _endOfBridge[i] = false;
                _bridge[i] = new ConcurrentQueue<List<BaseData>>();

                //This is quantconnect data source, store here for speed/ease of access
                _isDynamicallyLoadedData.Add(algorithm.Securities[_subscriptions[i].Symbol].IsDynamicallyLoadedData);

                //Subscription managers for downloading user data:
                _subscriptionManagers[i] = new SubscriptionDataReader(_subscriptions[i], algorithm.Securities[_subscriptions[i].Symbol], DataFeedEndpoint.LiveTrading, DateTime.MinValue, DateTime.MaxValue);

                //Set up the source file for today:
                _subscriptionManagers[i].RefreshSource(DateTime.Now.Date);

                _realtimePrices.Add(0);
            }
        }
开发者ID:intelliBrain,项目名称:Lean,代码行数:43,代码来源:LiveTradingDataFeed.cs


示例12: Run

 /// <summary>
 /// Runs this command against the specified algorithm instance
 /// </summary>
 /// <param name="algorithm">The algorithm to run this command against</param>
 public CommandResultPacket Run(IAlgorithm algorithm)
 {
     var ticket = algorithm.Transactions.CancelOrder(OrderId);
     return ticket.CancelRequest != null 
         ? new Result(this, true, ticket.QuantityFilled) 
         : new Result(this, false, ticket.QuantityFilled);
 }
开发者ID:skyfyl,项目名称:Lean,代码行数:11,代码来源:CancelOrderCommand.cs


示例13: EveryAlgorithmEndOfDay

        /// <summary>
        /// Creates a new <see cref="ScheduledEvent"/> that will fire before market close by the specified time 
        /// </summary>
        /// <param name="algorithm">The algorithm instance the event is fo</param>
        /// <param name="resultHandler">The result handler, used to communicate run time errors</param>
        /// <param name="start">The date to start the events</param>
        /// <param name="end">The date to end the events</param>
        /// <param name="endOfDayDelta">The time difference between the market close and the event, positive time will fire before market close</param>
        /// <param name="currentUtcTime">Specfies the current time in UTC, before which, no events will be scheduled. Specify null to skip this filter.</param>
        /// <returns>The new <see cref="ScheduledEvent"/> that will fire near market close each tradeable dat</returns>
        public static ScheduledEvent EveryAlgorithmEndOfDay(IAlgorithm algorithm, IResultHandler resultHandler, DateTime start, DateTime end, TimeSpan endOfDayDelta, DateTime? currentUtcTime = null)
        {
            if (endOfDayDelta >= Time.OneDay)
            {
                throw new ArgumentException("Delta must be less than a day", "endOfDayDelta");
            }

            // set up an event to fire every tradeable date for the algorithm as a whole
            var eodEventTime = Time.OneDay.Subtract(endOfDayDelta);

            // create enumerable of end of day in algorithm's time zone
            var times =
                // for every date any exchange is open in the algorithm
                from date in Time.EachTradeableDay(algorithm.Securities.Values, start, end)
                // define the time of day we want the event to fire, a little before midnight
                let eventTime = date + eodEventTime
                // convert the event time into UTC
                let eventUtcTime = eventTime.ConvertToUtc(algorithm.TimeZone)
                // perform filter to verify it's not before the current time
                where !currentUtcTime.HasValue || eventUtcTime > currentUtcTime.Value
                select eventUtcTime;

            return new ScheduledEvent(CreateEventName("Algorithm", "EndOfDay"), times, (name, triggerTime) =>
            {
                try
                {
                    algorithm.OnEndOfDay();
                }
                catch (Exception err)
                {
                    resultHandler.RuntimeError(String.Format("Runtime error in {0} event: {1}", name, err.Message), err.StackTrace);
                    Log.Error(err, string.Format("ScheduledEvent.{0}:", name));
                }
            });
        }
开发者ID:AlexCatarino,项目名称:Lean,代码行数:45,代码来源:ScheduledEventFactory.cs


示例14: BacktestingRealTimeHandler

 /********************************************************
 * PUBLIC CONSTRUCTOR
 *********************************************************/
 /// <summary>
 /// Setup the algorithm data, cash, job start end date etc.
 /// </summary>
 public BacktestingRealTimeHandler(IAlgorithm algorithm, AlgorithmNodePacket job)
 {
     //Initialize:
     _algorithm = algorithm;
     _events = new List<RealTimeEvent>();
     _job = job;
 }
开发者ID:intelliBrain,项目名称:Lean,代码行数:13,代码来源:BacktestingRealTimeHandler.cs


示例15: BaseDataFeed

        /********************************************************
        * CLASS CONSTRUCTOR
        *********************************************************/
        /// <summary>
        /// Create an instance of the base datafeed.
        /// </summary>
        public BaseDataFeed(IAlgorithm algorithm, BacktestNodePacket job)
        {
            //Save the data subscriptions
            Subscriptions = algorithm.SubscriptionManager.Subscriptions;
            _subscriptions = Subscriptions.Count;

            //Public Properties:
            DataFeed = DataFeedEndpoint.FileSystem;
            IsActive = true;
            Bridge = new ConcurrentQueue<List<BaseData>>[_subscriptions];
            EndOfBridge = new bool[_subscriptions];
            SubscriptionReaderManagers = new SubscriptionDataReader[_subscriptions];
            RealtimePrices = new List<decimal>(_subscriptions);
            _frontierTime = new DateTime[_subscriptions];

            //Class Privates:
            _job = job;
            _algorithm = algorithm;
            _endOfStreams = false;
            _bridgeMax = _bridgeMax / _subscriptions;

            //Initialize arrays:
            for (var i = 0; i < _subscriptions; i++)
            {
                _frontierTime[i] = job.PeriodStart;
                EndOfBridge[i] = false;
                Bridge[i] = new ConcurrentQueue<List<BaseData>>();
                SubscriptionReaderManagers[i] = new SubscriptionDataReader(Subscriptions[i], algorithm.Securities[Subscriptions[i].Symbol], DataFeedEndpoint.Database, job.PeriodStart, job.PeriodFinish);
            }
        }
开发者ID:sopnic,项目名称:Lean,代码行数:36,代码来源:BaseDataFeed.cs


示例16: CalculatingThread

 /// <summary>
   /// Инициализация потока для алгоритма
   /// </summary>
   /// <param name="alg">Алгоритм</param>
   /// <param name="tasks">Задания</param>
   /// <param name="function">Оптимизируемая функция</param>
   /// 
   public CalculatingThread(IAlgorithm alg,List<ITaskPackage> tasks,BlackBoxFunction function)
   {
       this.alg = alg;           
       this.tasks = tasks;
       this.function = function;
      
   }
开发者ID:unn-85m3,项目名称:project,代码行数:14,代码来源:CalculatingThread.cs


示例17: BacktestingBrokerage

 /// <summary>
 /// Creates a new BacktestingBrokerage for the specified algorithm
 /// </summary>
 /// <param name="algorithm">The algorithm instance</param>
 /// <param name="name">The name of the brokerage</param>
 protected BacktestingBrokerage(IAlgorithm algorithm, string name)
     : base(name)
 {
     _algorithm = algorithm;
     _orders = _algorithm.Transactions.Orders;
     _pending = new ConcurrentDictionary<int, Order>();
 }
开发者ID:sopnic,项目名称:Lean,代码行数:12,代码来源:BacktestingBrokerage.cs


示例18: ProcessingDialogViewModel

 public ProcessingDialogViewModel()
 {
     LoadParameters = new DelegateCommand<MassSpecStudio.Core.Domain.Algorithm>(OnLoadParameters);
     _algorithms = ServiceLocator.Current.GetAllInstances<IAlgorithm>().ToList();
     _selectedAlgorithm = _algorithms.FirstOrDefault();
     _recentAlgorithmsUsed = RecentAlgorithms.Read();
 }
开发者ID:pol,项目名称:MassSpecStudio,代码行数:7,代码来源:ProcessingDialogViewModel.cs


示例19: CreateBrokerage

        /// <summary>
        /// Creates a new IBrokerage instance and set ups the environment for the brokerage
        /// </summary>
        /// <param name="job">The job packet to create the brokerage for</param>
        /// <param name="algorithm">The algorithm instance</param>
        /// <returns>A new brokerage instance</returns>
        public override IBrokerage CreateBrokerage(LiveNodePacket job, IAlgorithm algorithm)
        {
            var errors = new List<string>();

            // read values from the brokerage datas
            var useTws = Config.GetBool("ib-use-tws");
            var port = Config.GetInt("ib-port", 4001);
            var host = Config.Get("ib-host", "127.0.0.1");
            var twsDirectory = Config.Get("ib-tws-dir", "C:\\Jts");
            var ibControllerDirectory = Config.Get("ib-controller-dir", "C:\\IBController");

            var account = Read<string>(job.BrokerageData, "ib-account", errors);
            var userID = Read<string>(job.BrokerageData, "ib-user-name", errors);
            var password = Read<string>(job.BrokerageData, "ib-password", errors);
            var agentDescription = Read<AgentDescription>(job.BrokerageData, "ib-agent-description", errors);

            if (errors.Count != 0)
            {
                // if we had errors then we can't create the instance
                throw new Exception(string.Join(Environment.NewLine, errors));
            }
            
            // launch the IB gateway
            InteractiveBrokersGatewayRunner.Start(ibControllerDirectory, twsDirectory, userID, password, useTws);

            var ib = new InteractiveBrokersBrokerage(algorithm.Transactions, algorithm.Portfolio, account, host, port, agentDescription);
            Composer.Instance.AddPart<IDataQueueHandler>(ib);
            return ib;
        }
开发者ID:pmerrill,项目名称:Lean,代码行数:35,代码来源:InteractiveBrokersBrokerageFactory.cs


示例20: ExecutionManager

        public ExecutionManager(IAlgorithm algorithm, IDataManager dataManager)
        {
            this.algorithm = algorithm;
            this.dataManager = dataManager;

            algorithm.DiagnosticsEvent += OnInternalDiagnosticsEvent;
        }
开发者ID:mkaczynski,项目名称:MED,代码行数:7,代码来源:ExecutionManager.cs



注:本文中的IAlgorithm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IAllReadyDataAccess类代码示例发布时间:2022-05-24
下一篇:
C# IAlbum类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap