本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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)");
}
示例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;
}
示例6: Record
public void Record(IMdsDescriptor sequence, Strategy strategy )
{
Total++;
if(sequence.IsSuccessful) {
Successful++;
}
}
示例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());
}
示例8: StrategyItem
public StrategyItem(Strategy strategy)
{
if (strategy == null)
throw new ArgumentNullException(nameof(strategy));
Strategy = strategy;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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}|}";
}
示例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);
}