Refactor indicator management to a data-driven approach

- Introduced dynamic generation of parameter fields and callback handling for indicators, enhancing modularity and maintainability.
- Updated `config_utils.py` with new utility functions to load indicator templates and generate dynamic outputs and states for parameter fields.
- Refactored `indicators.py` to utilize these utilities, streamlining the callback logic and improving user experience by reducing hardcoded elements.
- Modified `indicator_modal.py` to create parameter fields dynamically based on JSON templates, eliminating the need for manual updates when adding new indicators.
- Added documentation outlining the new data-driven architecture for indicators, improving clarity and guidance for future development.

These changes significantly enhance the flexibility and scalability of the indicator system, aligning with project goals for maintainability and performance.
This commit is contained in:
Vasily.onl
2025-06-11 19:09:52 +08:00
parent 89b071230e
commit 3e0e89b826
8 changed files with 406 additions and 249 deletions

View File

@@ -202,35 +202,7 @@ SUBPLOT_REGISTRY = {
### 3. Add UI Components
Update `dashboard/components/indicator_modal.py`:
```python
def create_parameter_fields():
return html.Div([
# ... existing fields ...
html.Div([
dbc.Row([
dbc.Col([
dbc.Label("%K Period:"),
dcc.Input(
id='stochastic-k-period-input',
type='number',
value=14
)
], width=6),
dbc.Col([
dbc.Label("%D Period:"),
dcc.Input(
id='stochastic-d-period-input',
type='number',
value=3
)
], width=6),
]),
dbc.FormText("Stochastic oscillator periods")
], id='stochastic-parameters', style={'display': 'none'})
])
```
***(No longer needed - UI is dynamically generated from JSON templates)***
## Best Practices