3.4 Implement user-defined indicator management system and enhance chart capabilities
- Introduced a comprehensive user indicator management system in `components/charts/indicator_manager.py`, allowing users to create, edit, and manage custom indicators with JSON persistence. - Added new default indicators in `components/charts/indicator_defaults.py` to provide users with immediate options for technical analysis. - Enhanced the chart rendering capabilities by implementing the `create_chart_with_indicators` function in `components/charts/builder.py`, supporting both overlay and subplot indicators. - Updated the main application layout in `app.py` to include a modal for adding and editing indicators, improving user interaction. - Enhanced documentation to cover the new indicator system, including a quick guide for adding new indicators and detailed usage examples. - Added unit tests to ensure the reliability and functionality of the new indicator management features.
This commit is contained in:
30
config/indicators/templates/bollinger_bands_template.json
Normal file
30
config/indicators/templates/bollinger_bands_template.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "Bollinger Bands",
|
||||
"description": "Bollinger Bands volatility indicator",
|
||||
"type": "bollinger_bands",
|
||||
"display_type": "overlay",
|
||||
"default_parameters": {
|
||||
"period": 20,
|
||||
"std_dev": 2.0
|
||||
},
|
||||
"parameter_schema": {
|
||||
"period": {
|
||||
"type": "int",
|
||||
"min": 5,
|
||||
"max": 100,
|
||||
"default": 20,
|
||||
"description": "Period for middle line (SMA)"
|
||||
},
|
||||
"std_dev": {
|
||||
"type": "float",
|
||||
"min": 0.5,
|
||||
"max": 5.0,
|
||||
"default": 2.0,
|
||||
"description": "Standard deviation multiplier"
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
"color": "#6f42c1",
|
||||
"line_width": 1
|
||||
}
|
||||
}
|
||||
22
config/indicators/templates/ema_template.json
Normal file
22
config/indicators/templates/ema_template.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "Exponential Moving Average",
|
||||
"description": "Exponential Moving Average indicator",
|
||||
"type": "ema",
|
||||
"display_type": "overlay",
|
||||
"default_parameters": {
|
||||
"period": 12
|
||||
},
|
||||
"parameter_schema": {
|
||||
"period": {
|
||||
"type": "int",
|
||||
"min": 1,
|
||||
"max": 200,
|
||||
"default": 12,
|
||||
"description": "Period for EMA calculation"
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
"color": "#ff6b35",
|
||||
"line_width": 2
|
||||
}
|
||||
}
|
||||
38
config/indicators/templates/macd_template.json
Normal file
38
config/indicators/templates/macd_template.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "MACD",
|
||||
"description": "Moving Average Convergence Divergence",
|
||||
"type": "macd",
|
||||
"display_type": "subplot",
|
||||
"default_parameters": {
|
||||
"fast_period": 12,
|
||||
"slow_period": 26,
|
||||
"signal_period": 9
|
||||
},
|
||||
"parameter_schema": {
|
||||
"fast_period": {
|
||||
"type": "int",
|
||||
"min": 2,
|
||||
"max": 50,
|
||||
"default": 12,
|
||||
"description": "Fast EMA period"
|
||||
},
|
||||
"slow_period": {
|
||||
"type": "int",
|
||||
"min": 5,
|
||||
"max": 100,
|
||||
"default": 26,
|
||||
"description": "Slow EMA period"
|
||||
},
|
||||
"signal_period": {
|
||||
"type": "int",
|
||||
"min": 2,
|
||||
"max": 30,
|
||||
"default": 9,
|
||||
"description": "Signal line period"
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
"color": "#fd7e14",
|
||||
"line_width": 2
|
||||
}
|
||||
}
|
||||
22
config/indicators/templates/rsi_template.json
Normal file
22
config/indicators/templates/rsi_template.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "Relative Strength Index",
|
||||
"description": "RSI oscillator indicator",
|
||||
"type": "rsi",
|
||||
"display_type": "subplot",
|
||||
"default_parameters": {
|
||||
"period": 14
|
||||
},
|
||||
"parameter_schema": {
|
||||
"period": {
|
||||
"type": "int",
|
||||
"min": 2,
|
||||
"max": 50,
|
||||
"default": 14,
|
||||
"description": "Period for RSI calculation"
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
"color": "#20c997",
|
||||
"line_width": 2
|
||||
}
|
||||
}
|
||||
22
config/indicators/templates/sma_template.json
Normal file
22
config/indicators/templates/sma_template.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "Simple Moving Average",
|
||||
"description": "Simple Moving Average indicator",
|
||||
"type": "sma",
|
||||
"display_type": "overlay",
|
||||
"default_parameters": {
|
||||
"period": 20
|
||||
},
|
||||
"parameter_schema": {
|
||||
"period": {
|
||||
"type": "int",
|
||||
"min": 1,
|
||||
"max": 200,
|
||||
"default": 20,
|
||||
"description": "Period for SMA calculation"
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
"color": "#007bff",
|
||||
"line_width": 2
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"id": "bollinger_bands_08c5ed71",
|
||||
"name": "Bollinger Tight",
|
||||
"description": "Tight Bollinger Bands (20, 1.5) for sensitive volatility",
|
||||
"type": "bollinger_bands",
|
||||
"display_type": "overlay",
|
||||
"parameters": {
|
||||
"period": 20,
|
||||
"std_dev": 1.5
|
||||
},
|
||||
"styling": {
|
||||
"color": "#e83e8c",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.460797+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.460797+00:00"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"id": "bollinger_bands_69b378e2",
|
||||
"name": "Bollinger Bands",
|
||||
"description": "Standard Bollinger Bands (20, 2) for volatility analysis",
|
||||
"type": "bollinger_bands",
|
||||
"display_type": "overlay",
|
||||
"parameters": {
|
||||
"period": 20,
|
||||
"std_dev": 2.0
|
||||
},
|
||||
"styling": {
|
||||
"color": "#6f42c1",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.460105+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.460105+00:00"
|
||||
}
|
||||
19
config/indicators/user_indicators/ema_ca5fd53d.json
Normal file
19
config/indicators/user_indicators/ema_ca5fd53d.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "ema_ca5fd53d",
|
||||
"name": "EMA 10",
|
||||
"description": "12-period Exponential Moving Average for fast signals",
|
||||
"type": "ema",
|
||||
"display_type": "overlay",
|
||||
"parameters": {
|
||||
"period": 10
|
||||
},
|
||||
"styling": {
|
||||
"color": "#ff6b35",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.455729+00:00",
|
||||
"modified_date": "2025-06-04T04:54:49.608549+00:00"
|
||||
}
|
||||
19
config/indicators/user_indicators/ema_de4fc14c.json
Normal file
19
config/indicators/user_indicators/ema_de4fc14c.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "ema_de4fc14c",
|
||||
"name": "EMA 26",
|
||||
"description": "26-period Exponential Moving Average for slower signals",
|
||||
"type": "ema",
|
||||
"display_type": "overlay",
|
||||
"parameters": {
|
||||
"period": 26
|
||||
},
|
||||
"styling": {
|
||||
"color": "#28a745",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.456253+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.456253+00:00"
|
||||
}
|
||||
21
config/indicators/user_indicators/macd_307935a7.json
Normal file
21
config/indicators/user_indicators/macd_307935a7.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"id": "macd_307935a7",
|
||||
"name": "MACD Fast",
|
||||
"description": "Fast MACD (5, 13, 4) for quick signals",
|
||||
"type": "macd",
|
||||
"display_type": "subplot",
|
||||
"parameters": {
|
||||
"fast_period": 5,
|
||||
"slow_period": 13,
|
||||
"signal_period": 4
|
||||
},
|
||||
"styling": {
|
||||
"color": "#dc3545",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.459602+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.459602+00:00"
|
||||
}
|
||||
21
config/indicators/user_indicators/macd_7335a9bd.json
Normal file
21
config/indicators/user_indicators/macd_7335a9bd.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"id": "macd_7335a9bd",
|
||||
"name": "MACD Standard",
|
||||
"description": "Standard MACD (12, 26, 9) for trend changes",
|
||||
"type": "macd",
|
||||
"display_type": "subplot",
|
||||
"parameters": {
|
||||
"fast_period": 12,
|
||||
"slow_period": 26,
|
||||
"signal_period": 9
|
||||
},
|
||||
"styling": {
|
||||
"color": "#fd7e14",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.459030+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.459030+00:00"
|
||||
}
|
||||
19
config/indicators/user_indicators/rsi_1a0e1320.json
Normal file
19
config/indicators/user_indicators/rsi_1a0e1320.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "rsi_1a0e1320",
|
||||
"name": "RSI 21",
|
||||
"description": "21-period RSI for less sensitive momentum signals",
|
||||
"type": "rsi",
|
||||
"display_type": "subplot",
|
||||
"parameters": {
|
||||
"period": 21
|
||||
},
|
||||
"styling": {
|
||||
"color": "#17a2b8",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.458018+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.458018+00:00"
|
||||
}
|
||||
19
config/indicators/user_indicators/rsi_5d160ff7.json
Normal file
19
config/indicators/user_indicators/rsi_5d160ff7.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "rsi_5d160ff7",
|
||||
"name": "RSI 14",
|
||||
"description": "14-period RSI for momentum analysis",
|
||||
"type": "rsi",
|
||||
"display_type": "subplot",
|
||||
"parameters": {
|
||||
"period": 14
|
||||
},
|
||||
"styling": {
|
||||
"color": "#20c997",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.457515+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.457515+00:00"
|
||||
}
|
||||
19
config/indicators/user_indicators/sma_0e235df1.json
Normal file
19
config/indicators/user_indicators/sma_0e235df1.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "sma_0e235df1",
|
||||
"name": "SMA 50",
|
||||
"description": "50-period Simple Moving Average for medium-term trend",
|
||||
"type": "sma",
|
||||
"display_type": "overlay",
|
||||
"parameters": {
|
||||
"period": 50
|
||||
},
|
||||
"styling": {
|
||||
"color": "#6c757d",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.454653+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.454653+00:00"
|
||||
}
|
||||
19
config/indicators/user_indicators/sma_8c487df2.json
Normal file
19
config/indicators/user_indicators/sma_8c487df2.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "sma_8c487df2",
|
||||
"name": "SMA 20",
|
||||
"description": "20-period Simple Moving Average for short-term trend",
|
||||
"type": "sma",
|
||||
"display_type": "overlay",
|
||||
"parameters": {
|
||||
"period": 20
|
||||
},
|
||||
"styling": {
|
||||
"color": "#007bff",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.453614+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.453614+00:00"
|
||||
}
|
||||
Reference in New Issue
Block a user