|
4 | 4 | # @Author : sukai |
5 | 5 | from tigeropen.common.consts import SortDirection |
6 | 6 | from tigeropen.common.model import Field |
| 7 | +from tigeropen.common.util.string_utils import camel_to_underline |
7 | 8 |
|
8 | 9 | GREEKS = ['delta', 'gamma', 'theta', 'vega', 'rho'] |
9 | 10 |
|
@@ -61,23 +62,24 @@ def _min_max(self, k): |
61 | 62 |
|
62 | 63 |
|
63 | 64 | class StockFilter: |
64 | | - def __init__(self, field, min_value=None, max_value=None, sort=None, enable=True): |
| 65 | + def __init__(self, field, min_value=None, max_value=None, sort_direction=None, enable=True): |
65 | 66 | """ |
66 | 67 | stock filter |
67 | 68 | :param field: filter field. subclass of tigeropen.common.consts.Field, or field name string |
68 | 69 | :param min_value: |
69 | 70 | :param max_value: |
70 | | - :param sort: tigeropen.common.consts.SortDirection. ASC or DESC |
| 71 | + :param sort_direction: tigeropen.common.consts.SortDirection. ASC or DESC |
71 | 72 | :param enable: |
72 | 73 | """ |
73 | 74 | self.field = field |
74 | 75 | self.min_value = min_value |
75 | 76 | self.max_value = max_value |
76 | | - self.sort = sort |
| 77 | + self.sort = sort_direction |
77 | 78 | self.enable = enable |
78 | 79 |
|
79 | 80 | def to_dict(self): |
80 | | - return {'field': self.field.name if isinstance(self.field, Field) else self.field, |
| 81 | + |
| 82 | + return {'field': camel_to_underline(self.field.name if isinstance(self.field, Field) else self.field), |
81 | 83 | 'min_value': self.min_value, |
82 | 84 | 'max_value': self.max_value, |
83 | 85 | 'sort_direction': self.sort.value if isinstance(self.sort, SortDirection) else self.sort, |
|
0 commit comments