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

C# Strategy类代码示例

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

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



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

示例1: Evaluate

        internal override ThreeValuedLogic Evaluate(Strategy strategy)
        {
            var compareValue = this.compare;

            var compareRole = this.compare as IRoleType;
            if (compareRole != null)
            {
                compareValue = strategy.GetInternalizedUnitRole(compareRole);
            }
            else
            {
                if (this.roleType.ObjectType is IUnit)
                {
                    compareValue = this.roleType.Normalize(this.compare);
                }
            }

            var comparable = strategy.GetInternalizedUnitRole(this.roleType) as IComparable;

            if (comparable == null)
            {
                return ThreeValuedLogic.Unknown;
            }

            return comparable.CompareTo(compareValue) < 0
                       ? ThreeValuedLogic.True
                       : ThreeValuedLogic.False;
        }
开发者ID:whesius,项目名称:allors,代码行数:28,代码来源:RoleLessThan.cs


示例2: Evaluate

        internal override ThreeValuedLogic Evaluate(Strategy strategy)
        {
            var value = strategy.GetInternalizedUnitRole(this.roleType);

            if (value == null)
            {
                return ThreeValuedLogic.Unknown;
            }

            var equalsValue = this.equals;

            if (this.equals is IRoleType)
            {
                var equalsRole = (IRoleType)this.equals;
                equalsValue = strategy.GetInternalizedUnitRole(equalsRole);
            }
            else
            {
                if (this.roleType.ObjectType is IUnit)
                {
                    equalsValue = RoleTypeExtensions.Normalize(this.roleType, [email protected]);
                }
            }

            if (equalsValue == null)
            {
                return ThreeValuedLogic.False;
            }

            return value.Equals(equalsValue)
                       ? ThreeValuedLogic.True
                       : ThreeValuedLogic.False;
        }
开发者ID:whesius,项目名称:allors,代码行数:33,代码来源:RoleUnitEquals.cs


示例3: Evaluate

        internal override ThreeValuedLogic Evaluate(Strategy strategy)
        {
            object value = strategy.GetCompositeRole(this.roleType);

            if (value == null)
            {
                return ThreeValuedLogic.False;
            }

            object equalsValue = this.equals;

            if (this.equals is IRoleType)
            {
                var equalsRole = (IRoleType)this.equals;
                equalsValue = strategy.GetCompositeRole(equalsRole);
            }

            if (equalsValue == null)
            {
                return ThreeValuedLogic.False;
            }

            return value.Equals(equalsValue)
                       ? ThreeValuedLogic.True
                       : ThreeValuedLogic.False;
        }
开发者ID:whesius,项目名称:allors,代码行数:26,代码来源:RoleCompositeEquals.cs


示例4: OnChildStrategiesAdded

		private void OnChildStrategiesAdded(Strategy strategy)
		{
			var rule = strategy
				.WhenStopped()
				.Do(s =>
				{
					if (FinishMode == BasketStrategyFinishModes.First)
					{
						if (FirstFinishStrategy == null)
						{
							FirstFinishStrategy = s;
							Stop();
						}
					}
					else
					{
						if (ChildStrategies.SyncGet(c => c.All(child => child.ProcessState != ProcessStates.Started)))
							Stop();
					}
				})
				.Once()
				.Apply(this);

			rule.UpdateName(rule.Name + " (BasketStrategy.OnChildStrategiesAdded)");
		}
开发者ID:reddream,项目名称:StockSharp,代码行数:25,代码来源:BasketStrategy.cs


示例5: Evaluate

        internal override ThreeValuedLogic Evaluate(Strategy strategy)
        {
            if (this.associationType.IsMany)
            {
                var associations = strategy.GetCompositeAssociations(this.associationType);
                foreach (var assoc in associations)
                {
                    if (this.containingExtent.Contains(assoc))
                    {
                        return ThreeValuedLogic.True;
                    }
                }

                return ThreeValuedLogic.False;
            }

            var association = strategy.GetCompositeAssociation(this.associationType);
            if (association != null)
            {
                return this.containingExtent.Contains(association)
                           ? ThreeValuedLogic.True
                           : ThreeValuedLogic.False;
            }

            return ThreeValuedLogic.False;
        }
开发者ID:whesius,项目名称:allors,代码行数:26,代码来源:AssociationContainedInExtent.cs


示例6: Record

 public void Record(IMdsDescriptor sequence, Strategy strategy )
 {
     Total++;
     if(sequence.IsSuccessful) {
         Successful++;
     }
 }
开发者ID:kaa,项目名称:Ciliate-Gene-Assembly-Simulator,代码行数:7,代码来源:CountingRecorder.cs


示例7: BackoffRunner

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="run">Run</param>
        /// <param name="strategy">Strategy</param>
        public BackoffRunner(IDynamicRuns run, Strategy strategy = Strategy.Exponential)
            : base(run.MinimumPeriodInSeconds, run.MaximumPeriodInSeconds, strategy)
        {
            this.run = run;

            base.Name = string.Format("{0}+{1}", this.GetType(), this.run.GetType());
        }
开发者ID:modulexcite,项目名称:King.Service,代码行数:12,代码来源:BackoffRunner.cs


示例8: StrategyItem

			public StrategyItem(Strategy strategy)
			{
				if (strategy == null)
					throw new ArgumentNullException(nameof(strategy));

				Strategy = strategy;
			}
开发者ID:bbqchickenrobot,项目名称:StockSharp,代码行数:7,代码来源:StrategiesStatisticsPanel.xaml.cs


示例9: Main

        public static void Main(string[] args)
        {
            string inputname = args[0];
            string outputname = args[1];

            string[] lines = File.ReadAllLines(inputname);

            int ncases = int.Parse(lines[0]);
            IList<string> results = new List<string>();
            Strategy strat = new Strategy();
            int nline = 0;

            for (int k = 0; k < ncases; k++)
            {
                nline++;
                int nnumbers = int.Parse(lines[nline].Trim());
                nline++;
                var first = lines[nline].Trim().Split(' ').Select(n => double.Parse(n)).ToList();
                nline++;
                var second = lines[nline].Trim().Split(' ').Select(n => double.Parse(n)).ToList();

                int nwinwar = strat.CalculateWar(first, second);
                int nwindwar = strat.CalculateDeceitfulWar(first, second);

                results.Add(string.Format("Case #{0}: {1} {2}", k + 1, nwindwar, nwinwar));
            }

            File.WriteAllLines(outputname, results.ToArray());
        }
开发者ID:ajlopez,项目名称:TddRocks,代码行数:29,代码来源:Program.cs


示例10: Evaluate

 internal override ThreeValuedLogic Evaluate(Strategy strategy)
 {
     var association = strategy.GetCompositeAssociation(this.associationType);
     return (association != null && association.Equals(this.equals))
                ? ThreeValuedLogic.True
                : ThreeValuedLogic.False;
 }
开发者ID:whesius,项目名称:allors,代码行数:7,代码来源:AssociationEquals.cs


示例11: Evaluate

        internal override ThreeValuedLogic Evaluate(Strategy strategy)
        {
            bool unknown = false;
            foreach (Predicate filter in this.Filters)
            {
                if (filter.Include)
                {
                    switch (filter.Evaluate(strategy))
                    {
                        case ThreeValuedLogic.True:
                            return ThreeValuedLogic.True;
                        case ThreeValuedLogic.Unknown:
                            unknown = true;
                            break;
                    }
                }
            }

            if (unknown)
            {
                return ThreeValuedLogic.Unknown;
            }

            return ThreeValuedLogic.False;
        }
开发者ID:whesius,项目名称:allors,代码行数:25,代码来源:Or.cs


示例12: UIController

        public UIController(List<BrokerManager> b, PositionManager pos, MainWindow w)
        {
            runningStrategy = null;
            cummulativePnL = 0;
            win = w;
            brokers = b;
            pos.PositionChange += new PositionChangedEventHandler(positionChange);
            pos.TradeMatched += new TradeMatchedEventHandler(tradeMatched);
            win.StrategyStart += new StrategyStartDelegate(startStrategy);
            win.StrategyStop += new StrategyStopDelegate(stopStrategy);

            //register to receive events from brokers
            foreach (BrokerManager brk in brokers)
            {
                brk.FillUpdate += new FillEventHandler(fillReceived);
                brk.OrderConfirmed += new OrderConfirmEventHandler(orderConfirmed);
                brk.RiskFilterFailure += new RiskFilterFailureEventHandler(riskFilterFailed);
                brk.LastUpdate += new LastUpdateEventHandler(lastUpdate);
            }

            Dictionary<int, String> strategyMap = new Dictionary<int, String>();
            strategyMap.Add(0, "Buy & Hold");
            strategyMap.Add(1, "Pair Trade");
            win.availableStrategies = strategyMap;
        }
开发者ID:oag335,项目名称:IIT_MSF576_CPRICE,代码行数:25,代码来源:UIController.cs


示例13: Evaluate

        internal override ThreeValuedLogic Evaluate(Strategy strategy)
        {
            var containing = new HashSet<IObject>(this.containingEnumerable);

            if (this.associationType.IsMany)
            {
                var associations = strategy.GetCompositeAssociations(this.associationType);
                foreach (var assoc in associations)
                {
                    if (containing.Contains((IObject)assoc))
                    {
                        return ThreeValuedLogic.True;
                    }
                }

                return ThreeValuedLogic.False;
            }

            var association = strategy.GetCompositeAssociation(this.associationType);
            if (association != null)
            {
                return containing.Contains(association)
                           ? ThreeValuedLogic.True
                           : ThreeValuedLogic.False;
            }

            return ThreeValuedLogic.False;
        }
开发者ID:whesius,项目名称:allors,代码行数:28,代码来源:AssociationContainedInEnumerable.cs


示例14: StrategyNameGenerator

		/// <summary>
		/// Initializes a new instance of the <see cref="StrategyNameGenerator"/>.
		/// </summary>
		/// <param name="strategy">Strategy.</param>
		public StrategyNameGenerator(Strategy strategy)
		{
			if (strategy == null)
				throw new ArgumentNullException("strategy");

			_strategy = strategy;
			_strategy.SecurityChanged += () =>
			{
				if (_selectors.Contains("Security"))
					Refresh();
			};
			_strategy.PortfolioChanged += () =>
			{
				if (_selectors.Contains("Portfolio"))
					Refresh();
			};

			ShortName = new string(_strategy.GetType().Name.Where(char.IsUpper).ToArray());

			_formatter = Smart.CreateDefaultSmartFormat();
			_formatter.SourceExtensions.Add(new Source(_formatter, new Dictionary<string, string>
			{
				{ "FullName", _strategy.GetType().Name },
				{ "ShortName", ShortName },
			}));

			_selectors = new SynchronizedSet<string>();

			AutoGenerateStrategyName = true;
			Pattern = "{ShortName}{Security:_{0.Security}|}{Portfolio:_{0.Portfolio}|}";
		}
开发者ID:hbwjz,项目名称:StockSharp,代码行数:35,代码来源:StrategyNameGenerator.cs


示例15: Record

 public void Record(IMdsDescriptor sequence, Strategy strategy )
 {
     if(writer!=null) {
         writer.WriteLine("{0} {1} => {2}", sequence.IsSuccessful?"SUCCESS":"FAILURE", strategy, sequence);
     }
     if(wrappedLogger==null) return;
     wrappedLogger.Record(sequence,strategy);
 }
开发者ID:kaa,项目名称:Ciliate-Gene-Assembly-Simulator,代码行数:8,代码来源:TraceRecorder.cs


示例16: setStrategy

	public static void setStrategy(Strategy s ){
		BallScript.strategy = s;

		if (s.GetType()== new secondStrategy().GetType()) {
			Debug.Log("sec strategy");
			BallScript.strategy=new secondStrategy();
		}
	}
开发者ID:ArpitKhare,项目名称:Arkanoid,代码行数:8,代码来源:BallScript.cs


示例17: CalculateDeceitfulWarCaseOne

        public void CalculateDeceitfulWarCaseOne()
        {
            Strategy strat = new Strategy();

            var result = strat.CalculateDeceitfulWar(new double[] { 0.5 }, new double[] { 0.6 });

            Assert.AreEqual(0, result);
        }
开发者ID:ajlopez,项目名称:TddRocks,代码行数:8,代码来源:StrategyTests.cs


示例18: CalculateWarCaseFour

        public void CalculateWarCaseFour()
        {
            Strategy strat = new Strategy();

            var result = strat.CalculateWar(new double[] { 0.186, 0.389, 0.907, 0.832, 0.959, 0.557, 0.300, 0.992, 0.899 }, new double[] { 0.916, 0.728, 0.271, 0.520, 0.700, 0.521, 0.215, 0.341, 0.458 });

            Assert.AreEqual(4, result);
        }
开发者ID:ajlopez,项目名称:TddRocks,代码行数:8,代码来源:StrategyTests.cs


示例19: CalculateSimpleWarWin

        public void CalculateSimpleWarWin()
        {
            Strategy strat = new Strategy();

            var result = strat.CalculateWar(new double[] { 0.2 }, new double[] { 0.1 });

            Assert.AreEqual(1, result);
        }
开发者ID:ajlopez,项目名称:TddRocks,代码行数:8,代码来源:StrategyTests.cs


示例20: CalculateDeceitfulWarCaseTwo

        public void CalculateDeceitfulWarCaseTwo()
        {
            Strategy strat = new Strategy();

            var result = strat.CalculateDeceitfulWar(new double[] { 0.7, 0.2 }, new double[] { 0.8, 0.3 });

            Assert.AreEqual(1, result);
        }
开发者ID:ajlopez,项目名称:TddRocks,代码行数:8,代码来源:StrategyTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Stream类代码示例发布时间:2022-05-24
下一篇:
C# StrAccum类代码示例发布时间: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