@@ -56,6 +56,48 @@ def _mav_validator(mav_value):
56
56
return False
57
57
return True
58
58
59
+ def _renko_params_validator (params_dict ):
60
+ '''
61
+ Ranko params may not have > 3 parameters, their values may be:
62
+ type: must be either 'pmove' or 'pclose'
63
+ brick_size: must be either an int/float greater than 0 or 'atr'
64
+ atr_length: must only exist if brick_size is 'atr', must be an int greater than 0
65
+ '''
66
+ if len (params_dict ) > 3 :
67
+ return False
68
+
69
+ # Validate type
70
+ if 'type' in params_dict :
71
+ if params_dict ['type' ] not in ['pmove' , 'pclose' ]:
72
+ return False
73
+ else :
74
+ params_dict ['type' ] = 'pmove' # Set default value of type to price movement
75
+
76
+ # Validate brick_size and atr_length
77
+ if 'brick_size' in params_dict :
78
+ brick_size = params_dict ['brick_size' ]
79
+ if not isinstance (brick_size , int ) and not isinstance (brick_size , float ):
80
+ if brick_size != 'atr' :
81
+ return False
82
+ else :
83
+ if 'atr_length' not in params_dict :
84
+ params_dict ['atr_length' ] = 14 # Set default value of atr_length to 14
85
+ else :
86
+ if not isinstance (params_dict ['atr_length' ], int ) or params_dict ['atr_length' ] < 1 :
87
+ return False
88
+ else :
89
+ if brick_size < 0 or 'atr_length' in params_dict :
90
+ return False
91
+ else :
92
+ params_dict ['brick_size' ] = 'atr'
93
+ params_dict ['atr_length' ] = 14
94
+
95
+ return True
96
+
97
+
98
+
99
+
100
+
59
101
def _bypass_kwarg_validation (value ):
60
102
''' For some kwargs, we either don't know enough, or
61
103
the validation is too complex to make it worth while,
0 commit comments