Add utility functions for managing indicator configurations
- Introduced `config_utils.py` to provide utility functions for loading and managing indicator templates, enhancing modularity and maintainability. - Implemented functions to load templates, generate dropdown options, and retrieve parameter schemas, default parameters, and styling for various indicators. - Updated the indicator modal to dynamically create parameter fields based on the loaded configurations, improving user experience and reducing redundancy. - Refactored existing parameter field creation logic to utilize the new utility functions, streamlining the codebase and adhering to project standards for clarity and maintainability. These changes significantly enhance the configuration management for indicators, aligning with project goals for modularity and performance.
This commit is contained in:
@@ -53,15 +53,15 @@ def register_indicator_callbacks(app):
|
||||
Output('ema-parameters', 'style'),
|
||||
Output('rsi-parameters', 'style'),
|
||||
Output('macd-parameters', 'style'),
|
||||
Output('bb-parameters', 'style')],
|
||||
Output('bollinger_bands-parameters', 'style')],
|
||||
Input('indicator-type-dropdown', 'value'),
|
||||
prevent_initial_call=True
|
||||
)
|
||||
def update_parameter_fields(indicator_type):
|
||||
"""Show/hide parameter input fields based on selected indicator type."""
|
||||
# Default styles
|
||||
hidden_style = {'display': 'none', 'margin-bottom': '10px'}
|
||||
visible_style = {'display': 'block', 'margin-bottom': '10px'}
|
||||
hidden_style = {'display': 'none'}
|
||||
visible_style = {'display': 'block'}
|
||||
|
||||
# Default message visibility
|
||||
message_style = {'display': 'block'} if not indicator_type else {'display': 'none'}
|
||||
@@ -110,8 +110,8 @@ def register_indicator_callbacks(app):
|
||||
State('macd-slow-period-input', 'value'),
|
||||
State('macd-signal-period-input', 'value'),
|
||||
# Bollinger Bands parameters
|
||||
State('bb-period-input', 'value'),
|
||||
State('bb-stddev-input', 'value'),
|
||||
State('bollinger_bands-period-input', 'value'),
|
||||
State('bollinger_bands-std-dev-input', 'value'),
|
||||
# Edit mode data
|
||||
State('edit-indicator-store', 'data')],
|
||||
prevent_initial_call=True
|
||||
@@ -397,8 +397,8 @@ def register_indicator_callbacks(app):
|
||||
Output('macd-fast-period-input', 'value'),
|
||||
Output('macd-slow-period-input', 'value'),
|
||||
Output('macd-signal-period-input', 'value'),
|
||||
Output('bb-period-input', 'value'),
|
||||
Output('bb-stddev-input', 'value')],
|
||||
Output('bollinger_bands-period-input', 'value'),
|
||||
Output('bollinger_bands-std-dev-input', 'value')],
|
||||
[Input({'type': 'edit-indicator-btn', 'index': dash.ALL}, 'n_clicks')],
|
||||
[State({'type': 'edit-indicator-btn', 'index': dash.ALL}, 'id')],
|
||||
prevent_initial_call=True
|
||||
@@ -493,8 +493,8 @@ def register_indicator_callbacks(app):
|
||||
Output('macd-fast-period-input', 'value', allow_duplicate=True),
|
||||
Output('macd-slow-period-input', 'value', allow_duplicate=True),
|
||||
Output('macd-signal-period-input', 'value', allow_duplicate=True),
|
||||
Output('bb-period-input', 'value', allow_duplicate=True),
|
||||
Output('bb-stddev-input', 'value', allow_duplicate=True)],
|
||||
Output('bollinger_bands-period-input', 'value', allow_duplicate=True),
|
||||
Output('bollinger_bands-std-dev-input', 'value', allow_duplicate=True)],
|
||||
[Input('cancel-indicator-btn', 'n_clicks'),
|
||||
Input('save-indicator-btn', 'n_clicks')], # Also reset on successful save
|
||||
prevent_initial_call=True
|
||||
|
||||
Reference in New Issue
Block a user