当前位置: 首页>>代码示例>>C#>>正文


C# Strategy类代码示例

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


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


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