?> QuantXpress – Deliver high performance automated trading and connectivity solutions



Strategy Input parameter validation

This is important to validate all the inputs parameter against the constraint that is defined for the variables in the given strategy. For example a user defined parameter named UserBenchmark must have a positive value.

 
[StrategyParameter("UserBenchmark", "0.0", "Target Spread")]
private double UserBenchmark = 0;
[StrategyParameterAttribute(("VWAPPriceTillDepth", "4", "VWAP Till Depth")]
private int VWAPTillDepth = 0;
...........
...........
protected override bool ValidateStrategyParameter(string parameterName, object paramterValue, out string errorString)
{
    errorString = string.Empty;
    bool retValue = false;

    switch (parameterName)
    {
        case "UserBenchmark" :
            retValue = paramterValue is double;
            if (retValue == false || retValue < 0)
                errorString = parameterName + " value is invalid.";
            break;

        case "VWAPTillDepth" :
            retValue = paramterValue is int;
            if (retValue == false || retValue < 0)
                errorString = parameterName + " value is invalid.";
            break;
        
         default:
             retValue = base.ValidateStrategyParameter(parameterName, paramterValue, out errorString);
                                                   
             break;

        case StrategyInputParameter.BuyJumpPrice:
    }
 }