Ejemplo n.º 1
0
 /// <summary>
 /// Specifies the order in which definitions are evaluated. Definitions evaluated sooner are more likely to
 /// find matches than ones evaluated later.
 /// </summary>
 public OptionStrategyMatcherOptions WithDefinitionEnumerator(IOptionStrategyDefinitionEnumerator enumerator)
 {
     return(new OptionStrategyMatcherOptions(
                _definitions,
                MaximumCountPerLeg,
                MaximumDuration,
                MaximumSolutionCount,
                enumerator,
                ObjectiveFunction,
                _positionEnumerator
                ));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="OptionStrategyMatcherOptions"/> class, providing
        /// options that control the behavior of the <see cref="OptionStrategyMatcher"/>
        /// </summary>
        public OptionStrategyMatcherOptions(
            IReadOnlyList <OptionStrategyDefinition> definitions,
            IReadOnlyList <int> maximumCountPerLeg,
            TimeSpan maximumDuration = default(TimeSpan),
            int maximumSolutionCount = 100,
            IOptionStrategyDefinitionEnumerator definitionEnumerator = null,
            IOptionStrategyMatchObjectiveFunction objectiveFunction  = null,
            IOptionPositionCollectionEnumerator positionEnumerator   = null
            )
        {
            if (maximumDuration == default(TimeSpan))
            {
                maximumDuration = Time.OneMinute;
            }

            if (definitionEnumerator == null)
            {
                // by default we want more complex option strategies to have matching priority
                definitionEnumerator = new DescendingByLegCountOptionStrategyDefinitionEnumerator();
            }

            if (objectiveFunction == null)
            {
                objectiveFunction = new UnmatchedPositionCountOptionStrategyMatchObjectiveFunction();
            }

            if (positionEnumerator == null)
            {
                positionEnumerator = new DefaultOptionPositionCollectionEnumerator();
            }

            _definitions          = definitions;
            MaximumDuration       = maximumDuration;
            ObjectiveFunction     = objectiveFunction;
            MaximumCountPerLeg    = maximumCountPerLeg;
            _positionEnumerator   = positionEnumerator;
            _definitionEnumerator = definitionEnumerator;
            MaximumSolutionCount  = maximumSolutionCount;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OptionStrategyMatcherOptions"/> class, providing
        /// options that control the behavior of the <see cref="OptionStrategyMatcher"/>
        /// </summary>
        public OptionStrategyMatcherOptions(
            IReadOnlyList <OptionStrategyDefinition> definitions,
            IReadOnlyList <int> maximumCountPerLeg,
            TimeSpan maximumDuration = default(TimeSpan),
            int maximumSolutionCount = 100,
            IOptionStrategyDefinitionEnumerator definitionEnumerator = null,
            IOptionStrategyMatchObjectiveFunction objectiveFunction  = null,
            IOptionPositionCollectionEnumerator positionEnumerator   = null
            )
        {
            if (maximumDuration == default(TimeSpan))
            {
                maximumDuration = Time.OneMinute;
            }

            if (definitionEnumerator == null)
            {
                definitionEnumerator = new IdentityOptionStrategyDefinitionEnumerator();
            }

            if (objectiveFunction == null)
            {
                objectiveFunction = new UnmatchedPositionCountOptionStrategyMatchObjectiveFunction();
            }

            if (positionEnumerator == null)
            {
                positionEnumerator = new DefaultOptionPositionCollectionEnumerator();
            }

            _definitions          = definitions;
            MaximumDuration       = maximumDuration;
            ObjectiveFunction     = objectiveFunction;
            MaximumCountPerLeg    = maximumCountPerLeg;
            _positionEnumerator   = positionEnumerator;
            _definitionEnumerator = definitionEnumerator;
            MaximumSolutionCount  = maximumSolutionCount;
        }