36 lines
3.1 KiB
Markdown
36 lines
3.1 KiB
Markdown
|
|
## Relevant Files
|
||
|
|
|
||
|
|
- `data/common/indicators.py` - This is the primary file to be refactored. The `TechnicalIndicators` class will be modified to be DataFrame-centric.
|
||
|
|
- `components/charts/utils.py` - The `prepare_chart_data` function in this file needs to be corrected to ensure it properly creates and returns a DataFrame with a `DatetimeIndex`.
|
||
|
|
- `components/charts/data_integration.py` - This file's `get_indicator_data` method will be simplified to pass the correctly prepared DataFrame to the calculation engine.
|
||
|
|
- `app_new.py` - The main application file, which will be used to run the dashboard and perform end-to-end testing.
|
||
|
|
|
||
|
|
### Notes
|
||
|
|
|
||
|
|
- The goal of this refactoring is to create a more robust and maintainable data pipeline for indicator calculations, preventing recurring data type and index errors.
|
||
|
|
- Pay close attention to ensuring that DataFrames have a consistent `DatetimeIndex` with proper timezone information throughout the pipeline.
|
||
|
|
|
||
|
|
## Tasks
|
||
|
|
|
||
|
|
- [x] 1.0 Refactor `TechnicalIndicators` Class in `data/common/indicators.py` to be DataFrame-centric.
|
||
|
|
- [x] 1.1 Modify `sma`, `ema`, `rsi`, `macd`, and `bollinger_bands` methods to accept a pre-formatted DataFrame as their primary input, not a list of candles.
|
||
|
|
- [x] 1.2 Remove the redundant `prepare_dataframe` call from within each individual indicator method.
|
||
|
|
- [x] 1.3 Rename `prepare_dataframe` to `_prepare_dataframe_from_list` to signify its new role as a private helper for converting list-based data.
|
||
|
|
- [x] 1.4 Update the main `calculate` method to be the single point of data preparation, handling both DataFrame and list inputs.
|
||
|
|
|
||
|
|
- [x] 2.0 Correct DataFrame Preparation in `components/charts/utils.py`.
|
||
|
|
- [x] 2.1 Review the `prepare_chart_data` function to identify why the `DatetimeIndex` is being dropped.
|
||
|
|
- [x] 2.2 Modify the function to ensure it returns a DataFrame with the `timestamp` column correctly set as the index, without a `reset_index()` call at the end.
|
||
|
|
|
||
|
|
- [x] 3.0 Simplify Data Flow in `components/charts/data_integration.py`.
|
||
|
|
- [x] 3.1 In the `get_indicator_data` function, remove the workaround that converts the DataFrame to a list of dictionaries (`to_dict('records')`).
|
||
|
|
- [x] 3.2 Ensure the function correctly handles both main and custom timeframes, passing the appropriate DataFrame to the calculation engine.
|
||
|
|
- [x] 3.3 Verify that the final `reindex` operation works correctly with the consistent DataFrame structure.
|
||
|
|
|
||
|
|
- [x] 4.0 End-to-End Testing and Validation.
|
||
|
|
- [x] 4.1 Run the dashboard and test the indicator plotting functionality with both matching and custom timeframes.
|
||
|
|
- [x] 4.2 Verify that no new errors appear in the console during chart interaction.
|
||
|
|
- [x] 5.0 Update Indicators documentation to reflect the new DataFrame-centric approach.
|
||
|
|
- [x] 5.1 Review the documentation in the `/docs` directory related to indicators.
|
||
|
|
- [x] 5.2 Update the documentation to explain that the calculation engine now uses DataFrames.
|
||
|
|
- [x] 5.3 Provide clear examples of how to use the refactored `TechnicalIndicators` class.
|