public override BuyPriceFilteringComponentResult IsPriceAcceptable(ITradingObject tradingObject, double price)
        {
            var result = new BuyPriceFilteringComponentResult(price);

            var baseValue = _metricProxy.GetMetricValues(tradingObject)[0];
            var upLimit   = baseValue * PriceUpLimitPercentage / 100.0;
            var downLimit = baseValue * PriceDownLimitPercentage / 100.0;

            if (price < downLimit || price > upLimit)
            {
                result.Comments = string.Format(
                    "Price {0:0.000} out of [{1:0.000}%..{2:0.000}%] of metric[{3}]:{4:0.000}",
                    price,
                    PriceDownLimitPercentage,
                    PriceUpLimitPercentage,
                    RawMetric,
                    baseValue);

                if (price > upLimit && IsUpLimitPriceAcceptable)
                {
                    result.AcceptablePrice   = upLimit;
                    result.IsPriceAcceptable = true;
                }
                else
                {
                    result.IsPriceAcceptable = false;
                    result.AcceptablePrice   = double.NaN;
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public override BuyPriceFilteringComponentResult IsPriceAcceptable(ITradingObject tradingObject, double price)
        {
            var result = new BuyPriceFilteringComponentResult(price);

            double buyPriceDownLimit = GetBuyPriceLimit(tradingObject);

            if (price < buyPriceDownLimit)
            {
                result.Comments = string.Format(
                    "Price {0:0.000} lower than buy price limit {1:0.000}",
                    price,
                    buyPriceDownLimit);

                result.IsPriceAcceptable = false;
                result.AcceptablePrice   = double.NaN;
            }

            return(result);
        }