protected object CalculateImpl(ClosingQuantityCalculatorInput input)
 {
     return GetFinalQuantity(input.OpenQuantity,
                             input.RoundLots,
                             input.PositionSizePercentage,
                             input.MinimumPosition);
 }
        private double GetTargetQuantity()
        {
            double targetQuantity;
            ClosingQuantityCalculatorInput input = new ClosingQuantityCalculatorInput()
                                                       {
                                                           PositionSizePercentage = PositionSizePercentage,
                                                           RoundLots = RoundLots,
                                                           MinimumPosition = MinimumOrderSize
                                                       };

            QuantityCalculator qtyCalc = new QuantityCalculator(LoggingConfig);

            targetQuantity = qtyCalc.CalculateClosingQuantity(GetAbsoluteOpenQuantity(), input);
            return targetQuantity;
        }
        public double CalculateClosingQuantity(double quantity, ClosingQuantityCalculatorInput input)
        {
            double returnValue = quantity;

            returnValue = returnValue * input.PositionSizePercentage / 100;
            returnValue = Math.Round(returnValue, 0);
            if (input.RoundLots)
                returnValue = returnValue - (returnValue % 100);

            LoggingUtility.WriteInfo(
                logConfig,
                string.Format(
                    "Total quantity: {0:n2} with a position size of {1:p} = {2}",
                    quantity,
                    input.PositionSizePercentage / 100,
                    returnValue));

            if (returnValue < input.MinimumPosition)
                returnValue = input.MinimumPosition;

            return returnValue;
        }