<essential_principles> Core Principles of the Cost Density Model
1. Core Formula
All calculations are based on the following relationship:
Cost Density = (c/V + s) # 成本密度(pips 等效)
x = Cost Density / P # 負載係數
RR_net = (RR_g - x) / (1 + x) # 淨風險報酬比
WR_min = (1 + x) / (1 + RR_g) # 最低勝率
P_critical = CostDensity × (RR_g + 2) / RR_g # 效率減半點
2. Parameter Definitions
| Parameter | Definition | Unit |
|---|---|---|
| RR_g | Gross risk-reward ratio (target/stop-loss) | Unitless |
| P | Stop-loss size | pips/points |
| c | Round-turn commission (per lot) | Account currency |
| s | Round-turn spread | pips/points |
| V | Value per pip (per lot) | Account currency/pip |
| R | Fixed risk (optional, cancels out) | Account currency |
3. Key Insights
- Hyperbolic decay: As P → 0, x → ∞, RR_net → -1
- R independence: RR_net does not depend on fixed risk R
- Scissors effect: Short timeframes simultaneously increase the cost burden and reduce signal quality
4. Unit Consistency Rules
- P and s must use the same basis (both pips or both points)
- c must be round-turn commission
- V must be the value per pip per lot </essential_principles>
- Compute - Calculate the cost density and efficiency metrics for a single parameter combination
- Sweep - Scan the stop-loss range and generate an RR_net/WR_min curve table
- Analyze - Interpret the results and provide strategy recommendations
Wait for a response before continuing.
After reading the workflow, please follow its steps exactly.
<reference_index>
Reference Documents (references/)
| Document | Content |
|---|---|
| formulas.md | Complete formula derivation and mathematical proof |
| theory.md | Market microstructure theory background and literature |
| </reference_index> |
<workflows_index>
| Workflow | Purpose |
|---|---|
| compute.md | Single calculation of cost density and efficiency metrics |
| sweep.md | Grid scan and threshold search |
| analyze.md | Result interpretation and strategy recommendations |
| </workflows_index> |
<templates_index>
| Template | Purpose |
|---|---|
| output-schema.yaml | Output JSON schema |
| input-schema.yaml | Input parameter schema |
| </templates_index> |
<scripts_index>
| Script | Purpose |
|---|---|
| cost_density.py | Python calculation implementation |
| cost_density.ts | TypeScript calculation implementation |
| </scripts_index> |
<quick_start> Quick calculation (XAU/USD example):
Input:
{
"RR_g": 3.0,
"c": 7.0,
"s": 1.5,
"V": 10.0,
"P": 20
}
Calculation:
cost_density = 7.0/10.0 + 1.5 # = 2.2 pips
x = 2.2 / 20 # = 0.11
RR_net = (3.0 - 0.11) / (1 + 0.11) # = 2.60
WR_min = (1 + 0.11) / (1 + 3.0) # = 27.7%
P_critical = 2.2 * (3.0 + 2) / 3.0 # = 3.67 pips
Output:
{
"cost_density": 2.2,
"x": 0.11,
"RR_net": 2.60,
"WR_min": 0.277,
"P_critical": 3.67,
"Loss_RR": 0.133
}
</quick_start>
<success_criteria> When the Skill executes successfully:
- Input parameters pass validation (unit consistency)
- Correctly calculate cost_density, x, RR_net, WR_min
- Identify whether it is in the high-friction zone (P < P_critical)
- Output conforms to outputs_schema
- Provide zh-TW explanatory notes </success_criteria>