mindesbunister
96d1667ae6
feat: Complete pyramiding/position stacking implementation (ALL 7 phases)
Phase 1: Configuration
- Added pyramiding config to trading.ts interface and defaults
- Added 6 ENV variables: ENABLE_PYRAMIDING, BASE_LEVERAGE, STACK_LEVERAGE,
MAX_LEVERAGE_TOTAL, MAX_PYRAMID_LEVELS, STACKING_WINDOW_MINUTES
Phase 2: Database Schema
- Added 5 Trade fields: pyramidLevel, parentTradeId, stackedAt,
totalLeverageAtEntry, isStackedPosition
- Added index on parentTradeId for pyramid group queries
Phase 3: Execute Endpoint
- Added findExistingPyramidBase() - finds active base trade within window
- Added canAddPyramidLevel() - validates pyramid conditions
- Stores pyramid metadata on new trades
Phase 4: Position Manager Core
- Added pyramidGroups Map for trade ID grouping
- Added addToPyramidGroup() - groups stacked trades by parent
- Added closeAllPyramidLevels() - unified exit for all levels
- Added getTotalPyramidLeverage() - calculates combined leverage
- All exit triggers now close entire pyramid group
Phase 5: Telegram Notifications
- Added sendPyramidStackNotification() - notifies on stack entry
- Added sendPyramidCloseNotification() - notifies on unified exit
Phase 6: Testing (25 tests, ALL PASSING)
- Pyramid Detection: 5 tests
- Pyramid Group Tracking: 4 tests
- Unified Exit: 4 tests
- Leverage Calculation: 4 tests
- Notification Context: 2 tests
- Edge Cases: 6 tests
Phase 7: Documentation
- Updated .github/copilot-instructions.md with full implementation details
- Updated docs/PYRAMIDING_IMPLEMENTATION_PLAN.md status to COMPLETE
Parameters: 4h window, 7x base/stack leverage, 14x max total, 2 max levels
Data-driven: 100% win rate for signals ≤72 bars apart in backtesting
2026-01-09 13:53:05 +01:00
..
2025-12-01 16:04:42 +01:00
2025-12-12 15:54:03 +01:00
2025-12-26 11:40:12 +01:00
2025-12-26 11:40:12 +01:00
2025-12-26 11:40:12 +01:00
2025-12-26 11:40:12 +01:00
2025-11-09 17:59:50 +01:00
2025-12-12 15:54:03 +01:00
2025-11-27 08:53:28 +01:00
2026-01-09 13:53:05 +01:00
2026-01-07 08:39:24 +01:00
2026-01-01 15:47:33 +01:00
2026-01-01 15:47:33 +01:00
2025-12-12 15:54:03 +01:00
2025-12-04 11:19:04 +01:00
2025-11-18 10:57:37 +01:00
2025-11-18 11:11:52 +01:00
2025-11-26 10:50:25 +01:00
2025-11-26 10:50:25 +01:00
2025-12-08 15:43:54 +01:00
2025-12-05 10:15:39 +01:00
2025-12-16 22:06:43 +01:00
2025-12-26 11:40:12 +01:00
2026-01-02 19:37:49 +01:00
2026-01-06 14:16:21 +01:00
2026-01-07 08:39:24 +01:00
2026-01-09 13:53:05 +01:00
2025-12-17 10:59:04 +01:00
2025-12-26 11:40:12 +01:00
2025-12-26 11:40:12 +01:00
2025-12-08 07:51:28 +01:00