public override EvaluationResult evaluate(Security security, CalculationFunctions functions, string firstToken, IList <string> remainingTokens)
        {
            MetaBean metaBean = MetaBean.of(security.GetType());

            // security
            Optional <string> securityPropertyName = metaBean.metaPropertyMap().Keys.Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (securityPropertyName.Present)
            {
                object propertyValue = metaBean.metaProperty(securityPropertyName.get()).get((Bean)security);
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // security info
            Optional <string> securityInfoPropertyName = security.Info.propertyNames().Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (securityInfoPropertyName.Present)
            {
                object propertyValue = security.Info.property(securityInfoPropertyName.get()).get();
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // security price info
            Optional <string> securityPriceInfoPropertyName = security.Info.PriceInfo.propertyNames().Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (securityPriceInfoPropertyName.Present)
            {
                object propertyValue = security.Info.PriceInfo.property(securityPriceInfoPropertyName.get()).get();
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // not found
            return(invalidTokenFailure(security, firstToken));
        }
Ejemplo n.º 2
0
        public override EvaluationResult evaluate(Trade trade, CalculationFunctions functions, string firstToken, IList <string> remainingTokens)
        {
            MetaBean metaBean = MetaBean.of(trade.GetType());

            // trade
            Optional <string> tradePropertyName = metaBean.metaPropertyMap().Keys.Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (tradePropertyName.Present)
            {
                object propertyValue = metaBean.metaProperty(tradePropertyName.get()).get((Bean)trade);
                if (propertyValue == null)
                {
                    return(EvaluationResult.failure("Property '{}' not set", firstToken));
                }
                return(EvaluationResult.success(propertyValue, remainingTokens));
            }

            // trade info
            Optional <string> tradeInfoPropertyName = trade.Info.propertyNames().Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (tradeInfoPropertyName.Present)
            {
                object propertyValue = trade.Info.property(tradeInfoPropertyName.get()).get();
                if (propertyValue == null)
                {
                    return(EvaluationResult.failure("Property '{}' not set", firstToken));
                }
                return(EvaluationResult.success(propertyValue, remainingTokens));
            }
            return(invalidTokenFailure(trade, firstToken));
        }
        public override EvaluationResult evaluate(Position position, CalculationFunctions functions, string firstToken, IList <string> remainingTokens)
        {
            MetaBean metaBean = MetaBean.of(position.GetType());

            // position
            Optional <string> positionPropertyName = metaBean.metaPropertyMap().Keys.Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (positionPropertyName.Present)
            {
                object propertyValue = metaBean.metaProperty(positionPropertyName.get()).get((Bean)position);
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // position info
            Optional <string> positionInfoPropertyName = position.Info.propertyNames().Where(p => p.equalsIgnoreCase(firstToken)).First();

            if (positionInfoPropertyName.Present)
            {
                object propertyValue = position.Info.property(positionInfoPropertyName.get()).get();
                return(propertyValue != null?EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("Property '{}' not set", firstToken));
            }

            // not found
            return(invalidTokenFailure(position, firstToken));
        }
        public override ISet <string> tokens(Security security)
        {
            MetaBean metaBean = MetaBean.of(security.GetType());

            return(Sets.union(Sets.union(metaBean.metaPropertyMap().Keys, security.Info.propertyNames()), security.Info.PriceInfo.propertyNames()));
        }
Ejemplo n.º 5
0
        public override ISet <string> tokens(Trade trade)
        {
            MetaBean metaBean = MetaBean.of(trade.GetType());

            return(Sets.union(metaBean.metaPropertyMap().Keys, trade.Info.propertyNames()));
        }
        public override ISet <string> tokens(Position position)
        {
            MetaBean metaBean = MetaBean.of(position.GetType());

            return(Sets.union(metaBean.metaPropertyMap().Keys, position.Info.propertyNames()));
        }