docs: update copilot-instructions for ATR trailing + dynamic runner% + rate limits
Updated .github/copilot-instructions.md to reflect recent system improvements: **ATR-Based Trailing Stop:** - Dynamic trailing calculation formula documented - Configurable runner % (default 25%, adjustable via TAKE_PROFIT_1_SIZE_PERCENT) - All UI displays now dynamically calculate runner% as 100 - TP1_SIZE - Removed hardcoded '25%' references, replaced with dynamic language **Rate Limit Monitoring:** - NEW Section #4: Rate Limit Monitoring - Exponential backoff mechanism (2s→4s→8s) - Database logging (3 event types: hit/recovered/exhausted) - Analytics endpoint for monitoring - Links to RATE_LIMIT_MONITORING.md for SQL queries **Section Renumbering:** - Old Section #4 (Order Placement) → Section #5 - Old Section #5 (Database) → Section #6 - Maintains logical flow and consistency **Updated References:** - Exit Strategy: Dynamic runner% description - Position Manager: ATR trailing formula + on-chain sync notes - Common Pitfalls: Dynamic runner % configuration notes - Roadmap: Phase 5 shows configurable runner with formula All documentation now accurately reflects user's 70/30 TP1/Runner split and recent infrastructure improvements (ATR trailing, rate limits). Related: settings UI updated in previous commit (app/settings/page.tsx)
This commit is contained in:
@@ -205,7 +205,8 @@ export default function SettingsPage() {
|
||||
const maxLoss = size * lev * (Math.abs(settings.STOP_LOSS_PERCENT) / 100)
|
||||
// Calculate gains/losses for risk calculator
|
||||
const tp1Gain = size * lev * (settings.TAKE_PROFIT_1_PERCENT / 100) * (settings.TAKE_PROFIT_1_SIZE_PERCENT / 100)
|
||||
const tp2RunnerSize = size * (1 - settings.TAKE_PROFIT_1_SIZE_PERCENT / 100) // 25% remaining after TP1
|
||||
const tp2RunnerSize = size * (1 - settings.TAKE_PROFIT_1_SIZE_PERCENT / 100) // Remaining % after TP1
|
||||
const runnerPercent = 100 - settings.TAKE_PROFIT_1_SIZE_PERCENT // Calculate runner % for display
|
||||
|
||||
// Use ATR-based TP2 if enabled, otherwise use static
|
||||
const tp2Percent = settings.USE_ATR_BASED_TARGETS
|
||||
@@ -217,10 +218,10 @@ export default function SettingsPage() {
|
||||
? settings.MAX_TP2_PERCENT
|
||||
: settings.TAKE_PROFIT_2_PERCENT
|
||||
|
||||
const runnerValue = tp2RunnerSize * lev * (tp2CalcPercent / 100) // Full 25% runner value at TP2
|
||||
const runnerValue = tp2RunnerSize * lev * (tp2CalcPercent / 100) // Runner value at TP2
|
||||
const fullWin = tp1Gain + runnerValue
|
||||
|
||||
return { maxLoss, tp1Gain, runnerValue, fullWin, tp2Percent }
|
||||
return { maxLoss, tp1Gain, runnerValue, fullWin, tp2Percent, runnerPercent }
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
@@ -276,7 +277,7 @@ export default function SettingsPage() {
|
||||
<div className="text-white text-2xl font-bold">+${risk.tp1Gain.toFixed(2)}</div>
|
||||
</div>
|
||||
<div className="bg-green-500/10 border border-green-500/50 rounded-lg p-4">
|
||||
<div className="text-green-400 text-sm mb-1">Runner Value (25%)</div>
|
||||
<div className="text-green-400 text-sm mb-1">Runner Value ({risk.runnerPercent}%)</div>
|
||||
<div className="text-white text-2xl font-bold">+${risk.runnerValue.toFixed(2)}</div>
|
||||
<div className="text-xs text-green-300 mt-1">{risk.tp2Percent}</div>
|
||||
</div>
|
||||
@@ -594,11 +595,14 @@ export default function SettingsPage() {
|
||||
</Section>
|
||||
|
||||
{/* Trailing Stop */}
|
||||
<Section title="🏃 Trailing Stop (25% Runner)" description="TP2 activates trailing stop on full remaining 25%">
|
||||
<Section
|
||||
title={`🏃 Trailing Stop (${100 - settings.TAKE_PROFIT_1_SIZE_PERCENT}% Runner)`}
|
||||
description={`TP2 activates trailing stop on full ${100 - settings.TAKE_PROFIT_1_SIZE_PERCENT}% remaining`}
|
||||
>
|
||||
<div className="mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg">
|
||||
<p className="text-sm text-blue-400">
|
||||
NEW SYSTEM: When TP2 price is hit, no position is closed. Instead, trailing stop activates on the full 25% remaining position for maximum runner potential.
|
||||
This gives you a 5x larger runner (25% vs 5%) to capture extended moves.
|
||||
NEW SYSTEM: When TP2 price is hit, no position is closed. Instead, trailing stop activates on the full {100 - settings.TAKE_PROFIT_1_SIZE_PERCENT}% remaining position for maximum runner potential.
|
||||
Current split: {settings.TAKE_PROFIT_1_SIZE_PERCENT}% at TP1, {100 - settings.TAKE_PROFIT_1_SIZE_PERCENT}% becomes runner.
|
||||
</p>
|
||||
</div>
|
||||
<Setting
|
||||
@@ -608,7 +612,7 @@ export default function SettingsPage() {
|
||||
min={0}
|
||||
max={1}
|
||||
step={1}
|
||||
description="Enable trailing stop for 25% runner position when TP2 triggers. 0 = disabled, 1 = enabled."
|
||||
description={`Enable trailing stop for ${100 - settings.TAKE_PROFIT_1_SIZE_PERCENT}% runner position when TP2 triggers. 0 = disabled, 1 = enabled.`}
|
||||
/>
|
||||
<Setting
|
||||
label="Trailing Stop Distance (%) [FALLBACK]"
|
||||
@@ -653,7 +657,7 @@ export default function SettingsPage() {
|
||||
min={0.1}
|
||||
max={5}
|
||||
step={0.1}
|
||||
description="25% runner must reach this profit % before trailing stop activates. Prevents premature stops. Example: 0.5% = wait until runner is +0.5% profit."
|
||||
description={`${100 - settings.TAKE_PROFIT_1_SIZE_PERCENT}% runner must reach this profit % before trailing stop activates. Prevents premature stops. Example: 0.5% = wait until runner is +0.5% profit.`}
|
||||
/>
|
||||
</Section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user