Enhance StochasticCross integration in CustomScenario and TradeChart components
- Refined StochasticCross indicator implementation in CustomScenario, adding new parameters and labels. - Improved TradeChart visualization for StochasticCross, including %K and %D series representation. - Updated API and types to ensure kFactor and dFactor properties are correctly integrated. - Adjusted backtest and scenario pages to reflect StochasticCross in indicator lists and parameter mappings.
This commit is contained in:
294
.cursor/commands/generate-kaigen-prompt.md
Normal file
294
.cursor/commands/generate-kaigen-prompt.md
Normal file
@@ -0,0 +1,294 @@
|
||||
# generate-kaigen-prompt
|
||||
|
||||
## When to Use
|
||||
|
||||
Use this command when:
|
||||
- You have completed backend indicator integration
|
||||
- You need to generate a prompt for Kaigen frontend indicator integration
|
||||
- The indicator is fully implemented in the backend (class, enum, configurations)
|
||||
- You want a comprehensive integration guide with all necessary details
|
||||
|
||||
## Usage
|
||||
|
||||
**Command Format:**
|
||||
```
|
||||
/generate-kaigen-prompt {IndicatorName}
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```
|
||||
/generate-kaigen-prompt StochasticCross
|
||||
```
|
||||
|
||||
**What it does:**
|
||||
1. Finds the indicator class file in `src/Managing.Domain/Indicators/`
|
||||
2. Extracts all parameters, defaults, and ranges from configuration files
|
||||
3. Analyzes signal generation logic and triggers
|
||||
4. Determines chart visualization requirements
|
||||
5. Generates a complete markdown prompt ready for Kaigen frontend integration
|
||||
|
||||
**Output:**
|
||||
A comprehensive markdown document with all information needed to integrate the indicator into the Kaigen frontend, including:
|
||||
- Complete parameter specifications
|
||||
- API integration details
|
||||
- Chart visualization code
|
||||
- Form input patterns
|
||||
- Integration checklist
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Backend indicator class exists in `src/Managing.Domain/Indicators/`
|
||||
- Indicator is registered in `IndicatorType` enum
|
||||
- Indicator is configured in `ScenarioHelpers.cs` and `GeneticService.cs`
|
||||
- Indicator implementation is complete and tested
|
||||
|
||||
## Execution Steps
|
||||
|
||||
### Step 1: Identify Indicator Class
|
||||
|
||||
**Find the indicator class file:**
|
||||
- Search for indicator class: `grep -r "class.*Indicator.*IndicatorBase" src/Managing.Domain/Indicators/`
|
||||
- Or search by enum name: `grep -r "IndicatorType\.{IndicatorName}" src/Managing.Domain/`
|
||||
|
||||
**Determine indicator location:**
|
||||
- Signal indicators: `src/Managing.Domain/Indicators/Signals/{IndicatorName}Indicator.cs`
|
||||
- Trend indicators: `src/Managing.Domain/Indicators/Trends/{IndicatorName}IndicatorBase.cs`
|
||||
- Context indicators: `src/Managing.Domain/Indicators/Context/{IndicatorName}.cs`
|
||||
|
||||
**Read the indicator class file to extract:**
|
||||
- Class name
|
||||
- Constructor parameters
|
||||
- Skender method used (e.g., `GetStoch`, `GetRsi`, `GetMacd`)
|
||||
- Result type (e.g., `StochResult`, `RsiResult`, `MacdResult`)
|
||||
- Signal generation logic and triggers
|
||||
- Parameter types (int, double, etc.)
|
||||
|
||||
### Step 2: Extract Configuration Data
|
||||
|
||||
**Read ScenarioHelpers.cs:**
|
||||
- Find `BuildIndicator()` method case for the indicator
|
||||
- Extract constructor call with parameter mapping
|
||||
- Find `GetSignalType()` method case to determine SignalType (Signal/Trend/Context)
|
||||
|
||||
**Read GeneticService.cs:**
|
||||
- Find `DefaultIndicatorValues` entry for the indicator
|
||||
- Extract default parameter values
|
||||
- Find `IndicatorParameterRanges` entry for the indicator
|
||||
- Extract parameter ranges (min, max)
|
||||
- Find `IndicatorParamMapping` entry for the indicator
|
||||
- Extract parameter names in order
|
||||
|
||||
**Read Enums.cs:**
|
||||
- Find `IndicatorType` enum value
|
||||
- Verify exact enum name
|
||||
|
||||
### Step 3: Analyze Signal Logic
|
||||
|
||||
**From indicator class, extract:**
|
||||
- Long signal trigger conditions (from comments and code)
|
||||
- Short signal trigger conditions (from comments and code)
|
||||
- Confidence levels used
|
||||
- Any thresholds or constants (e.g., oversold: 20, overbought: 80)
|
||||
|
||||
**From ProcessSignals method or similar:**
|
||||
- Crossover logic
|
||||
- Threshold checks
|
||||
- Zone conditions (oversold/overbought)
|
||||
|
||||
### Step 4: Determine Chart Visualization
|
||||
|
||||
**From GetIndicatorValues method:**
|
||||
- Result type returned (e.g., `Stoch`, `Rsi`, `Macd`, `Ema`)
|
||||
- Properties available in result (e.g., `K`, `D`, `Rsi`, `Macd`, `Signal`)
|
||||
|
||||
**From indicator class:**
|
||||
- Check if multiple series are needed (e.g., %K and %D lines)
|
||||
- Determine chart type (line, baseline, histogram)
|
||||
- Check if thresholds should be displayed (e.g., 20/80 lines)
|
||||
|
||||
### Step 5: Generate Kaigen Integration Prompt
|
||||
|
||||
**Format the prompt with the following sections:**
|
||||
|
||||
1. **Indicator Specification**
|
||||
- Type (Signal/Trend/Context)
|
||||
- Label (display name)
|
||||
- Enum name (exact IndicatorType value)
|
||||
|
||||
2. **Core Logic**
|
||||
- Technical description
|
||||
- What the indicator measures/calculates
|
||||
|
||||
3. **Signal Triggers**
|
||||
- Long signal conditions
|
||||
- Short signal conditions
|
||||
- Confidence levels
|
||||
|
||||
4. **Parameters**
|
||||
- Required parameters with types, defaults, ranges
|
||||
- Optional parameters with types, defaults, ranges
|
||||
- Parameter descriptions
|
||||
|
||||
5. **API Integration**
|
||||
- Result type name (e.g., `StochResult`, `RsiResult`)
|
||||
- Properties to access (e.g., `k`, `d`, `rsi`, `macd`)
|
||||
- Data path in `IndicatorsResultBase` (e.g., `indicatorsValues.StochasticCross.stoch`)
|
||||
|
||||
6. **Chart Visualization**
|
||||
- Series to display (e.g., %K line, %D line)
|
||||
- Chart types (line, baseline, histogram)
|
||||
- Colors and styles
|
||||
- Thresholds to display
|
||||
- Precision settings
|
||||
|
||||
7. **Form Inputs**
|
||||
- Input types (number, number with step)
|
||||
- Placeholders
|
||||
- Validation rules
|
||||
|
||||
8. **Integration Checklist**
|
||||
- All files that need updates
|
||||
- All components that need changes
|
||||
|
||||
## Output Format
|
||||
|
||||
Generate plain text (no code blocks) using the following structure:
|
||||
|
||||
### Indicator Specification
|
||||
- Type: {Signal/Trend/Context}
|
||||
- Label: {Display Name}
|
||||
- Enum Name: {IndicatorType.EnumName}
|
||||
- Class Name: {ClassName}
|
||||
|
||||
### Core Logic
|
||||
- Paragraph describing the indicator’s purpose and behavior.
|
||||
|
||||
### Signal Triggers
|
||||
- Long Signal: Describe trigger conditions in prose, then include the exact boolean condition on the next line prefixed with `Conditions:`.
|
||||
- Short Signal: Same structure as Long Signal.
|
||||
- Confidence: {confidence level}
|
||||
- Fixed Thresholds: List key threshold values (e.g., Oversold 20, Overbought 80).
|
||||
|
||||
### Parameters
|
||||
- **Required Parameters**: Present as a four-column inline table header `Parameter Type Default Range Description` followed by one row per parameter using spaces for separation (no Markdown table syntax).
|
||||
- **Optional Parameters**: Same inline table structure for optional parameters.
|
||||
|
||||
No additional sections (API Integration, Chart Visualization, Form Inputs, etc.) should be included in the output.
|
||||
|
||||
## Integration Checklist
|
||||
|
||||
- [ ] Add `{EnumName}` to `ALL_INDICATORS` arrays in genetic backtest pages
|
||||
- [ ] Add parameter mapping to `INDICATOR_PARAM_MAPPING` dictionaries
|
||||
- [ ] Add case to parameter switch in `CustomScenario.tsx`
|
||||
- [ ] Add case to label switch in `CustomScenario.tsx`
|
||||
- [ ] Create complete parameter form in `indicatorList.tsx`
|
||||
- [ ] Add chart visualization logic in `TradeChart.tsx`
|
||||
- [ ] Verify API types are correctly generated
|
||||
- [ ] Test form submission with all parameters
|
||||
- [ ] Test form submission with optional parameters omitted
|
||||
- [ ] Verify chart displays correctly
|
||||
- [ ] Test in genetic algorithm optimization flows
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
1. **Property Names**: Use `w.{property}` not `w.{PropertyName}` (check Skender result structure)
|
||||
2. **Missing Pane Increment**: Always increment `paneCount++` after adding series
|
||||
3. **Type Mismatches**: Ensure result type matches backend structure
|
||||
4. **Optional Parameters**: Allow null/empty values for optional parameters
|
||||
5. **Chart Precision**: Use appropriate precision for indicator type (0-100 range = precision: 2)
|
||||
```
|
||||
|
||||
## Example Execution
|
||||
|
||||
**User input:** `/generate-kaigen-prompt StochasticCross`
|
||||
|
||||
**AI execution:**
|
||||
|
||||
1. **Find indicator class:**
|
||||
- Search: `grep -r "StochasticCross" src/Managing.Domain/Indicators/`
|
||||
- Found: `src/Managing.Domain/Indicators/Signals/StochasticCrossIndicator.cs`
|
||||
- Read file to extract constructor, parameters, logic
|
||||
|
||||
2. **Extract configuration:**
|
||||
- Read `ScenarioHelpers.cs` → Find `IndicatorType.StochasticCross` case
|
||||
- Read `GeneticService.cs` → Find default values, ranges, parameter mapping
|
||||
- Read `Enums.cs` → Verify enum name
|
||||
|
||||
3. **Analyze signal logic:**
|
||||
- From `ProcessStochasticSignals` method
|
||||
- Extract: Long = %K crosses above %D in oversold (< 20)
|
||||
- Extract: Short = %K crosses below %D in overbought (> 80)
|
||||
|
||||
4. **Determine chart visualization:**
|
||||
- From `GetIndicatorValues` → Returns `Stoch` property
|
||||
- From code → Uses `StochResult` with `K` and `D` properties
|
||||
- Need two line series: %K (solid) and %D (dotted)
|
||||
|
||||
5. **Generate prompt:**
|
||||
- Format all extracted information
|
||||
- Include complete code examples
|
||||
- Add integration checklist
|
||||
- Output formatted markdown
|
||||
|
||||
## Error Handling
|
||||
|
||||
**If indicator class not found:**
|
||||
- Search for similar names: `grep -ri "stochastic" src/Managing.Domain/Indicators/`
|
||||
- Check if indicator is in different folder (Signals/Trends/Context)
|
||||
- Verify enum name matches class name pattern
|
||||
|
||||
**If configuration missing:**
|
||||
- Check `ScenarioHelpers.cs` for `BuildIndicator` case
|
||||
- Check `GeneticService.cs` for all three dictionaries
|
||||
- Verify enum exists in `Enums.cs`
|
||||
|
||||
**If signal logic unclear:**
|
||||
- Read method comments in indicator class
|
||||
- Check `ProcessSignals` or similar method
|
||||
- Look for `AddSignal` calls to understand conditions
|
||||
|
||||
**If chart visualization unclear:**
|
||||
- Check `GetIndicatorValues` return type
|
||||
- Look at similar indicators for patterns
|
||||
- Check Skender.Stock.Indicators documentation for result structure
|
||||
|
||||
## Important Notes
|
||||
|
||||
- ✅ **Extract exact enum name** - Must match `IndicatorType` enum exactly
|
||||
- ✅ **Verify parameter types** - int vs double matters for form inputs
|
||||
- ✅ **Check Skender result structure** - Property names may differ (e.g., `K` not `PercentK`)
|
||||
- ✅ **Include all parameters** - Both required and optional
|
||||
- ✅ **Provide complete code examples** - Make it easy to copy/paste
|
||||
- ✅ **Add validation rules** - Include parameter constraints
|
||||
- ⚠️ **Check for thresholds** - Some indicators have fixed thresholds (20/80, 25/75, etc.)
|
||||
- ⚠️ **Multiple series** - Some indicators need multiple chart series
|
||||
- ⚠️ **Optional parameters** - Handle defaults correctly in forms
|
||||
|
||||
## Quick Reference - Common Patterns
|
||||
|
||||
**Single Line Indicator** (e.g., RSI, EMA):
|
||||
- One `addLineSeries`
|
||||
- Access single property (e.g., `w.rsi`, `w.ema`)
|
||||
|
||||
**Dual Line Indicator** (e.g., Stochastic, MACD):
|
||||
- Two `addLineSeries` (different colors/styles)
|
||||
- Access multiple properties (e.g., `w.k`, `w.d`)
|
||||
|
||||
**Baseline Indicator** (e.g., STC, RSI with thresholds):
|
||||
- `addBaselineSeries` with baseValue
|
||||
- Add price lines for thresholds
|
||||
|
||||
**Histogram Indicator** (e.g., MACD histogram):
|
||||
- `addHistogramSeries` for histogram
|
||||
- Additional line series for signal lines
|
||||
|
||||
**Parameter Types**:
|
||||
- `int` → `type="number"` (no step)
|
||||
- `double` → `type="number" step="0.1"` or `step="0.01"`
|
||||
|
||||
**Default Ranges** (from GeneticService patterns):
|
||||
- Periods: 5-50 or 5-300
|
||||
- Multipliers: 1.0-10.0
|
||||
- Factors: 0.1-10.0
|
||||
- Signal periods: 3-15
|
||||
|
||||
Reference in New Issue
Block a user