From f61d1aa0c3d32588fd9c0264e1c37463f61c1897 Mon Sep 17 00:00:00 2001 From: Bojan Kucera Date: Tue, 3 Jun 2025 17:52:02 -0400 Subject: [PATCH] changed types around --- .chat/Claude4-June2.json | 34104 ---------------- ARCHITECTURE.md | 2 +- CONTEXT.md | 2 +- README.md | 2 +- REFACTORING.md | 2 +- .../market-data-gateway/package.json | 2 +- .../src/services/EventPublisher.ts | 2 +- .../src/services/MarketDataService.ts | 2 +- .../src/types/MarketDataGateway.ts | 224 +- apps/core-services/risk-guardian/package.json | 2 +- apps/data-services/data-catalog/package.json | 2 +- .../data-services/data-processor/package.json | 2 +- apps/data-services/feature-store/package.json | 2 +- .../backtest-engine/package.json | 2 +- .../src/core/BacktestEngine.ts | 6 +- .../signal-engine/package.json | 2 +- .../strategy-orchestrator/package.json | 2 +- bun.lock | 28 +- docs/current-system-flow.md | 2 +- docs/enhanced-architecture.md | 4 +- docs/migration-guide.md | 24 +- libs/api-client/package.json | 2 +- libs/api-client/src/BacktestClient.ts | 2 +- libs/api-client/src/BaseApiClient.ts | 2 +- libs/api-client/src/StrategyClient.ts | 2 +- libs/event-bus/README.md | 4 +- libs/event-bus/package.json | 2 +- libs/event-bus/src/EventBus.ts | 2 +- libs/event-bus/tsconfig.json | 6 +- libs/http-client/src/BunHttpClient.ts | 4 +- libs/http-client/src/RetryHandler.ts | 5 +- libs/shared-types/README.md | 2 +- libs/shared-types/package.json | 2 +- libs/shared-types/src/api/api.ts | 2 +- libs/shared-types/src/communication/index.ts | 5 + .../src/communication/messages.ts | 152 + .../src/communication/protocols.ts | 163 + .../src/communication/subscriptions.ts | 200 + .../src/communication/websocket.ts | 134 + libs/shared-types/src/config/database.ts | 60 + libs/shared-types/src/config/index.ts | 6 + libs/shared-types/src/config/logging.ts | 48 + libs/shared-types/src/config/monitoring.ts | 48 + libs/shared-types/src/config/networking.ts | 50 + libs/shared-types/src/config/security.ts | 46 + libs/shared-types/src/errors/application.ts | 79 + libs/shared-types/src/errors/base.ts | 85 + libs/shared-types/src/errors/business.ts | 85 + libs/shared-types/src/errors/index.ts | 6 + libs/shared-types/src/errors/network.ts | 75 + libs/shared-types/src/errors/validation.ts | 72 + libs/shared-types/src/features/base.ts | 110 + libs/shared-types/src/features/groups.ts | 124 + libs/shared-types/src/features/index.ts | 6 + libs/shared-types/src/features/lineage.ts | 131 + libs/shared-types/src/features/monitoring.ts | 157 + libs/shared-types/src/features/serving.ts | 134 + libs/shared-types/src/governance/access.ts | 282 + libs/shared-types/src/governance/catalog.ts | 253 + .../shared-types/src/governance/compliance.ts | 183 + libs/shared-types/src/governance/index.ts | 6 + libs/shared-types/src/governance/lifecycle.ts | 160 + libs/shared-types/src/governance/quality.ts | 107 + libs/shared-types/src/index.ts | 102 +- libs/shared-types/src/market/market-data.ts | 61 + libs/shared-types/src/monitoring/alerts.ts | 83 + libs/shared-types/src/monitoring/health.ts | 52 + libs/shared-types/src/monitoring/index.ts | 5 + libs/shared-types/src/monitoring/metrics.ts | 131 + libs/shared-types/src/monitoring/system.ts | 57 + libs/utils/package.json | 2 +- package-lock.json | 16 +- scripts/build-libs.ps1 | 2 +- scripts/create-package-aliases.ps1 | 2 +- tsconfig.json | 2 +- 75 files changed, 3625 insertions(+), 34314 deletions(-) delete mode 100644 .chat/Claude4-June2.json create mode 100644 libs/shared-types/src/communication/index.ts create mode 100644 libs/shared-types/src/communication/messages.ts create mode 100644 libs/shared-types/src/communication/protocols.ts create mode 100644 libs/shared-types/src/communication/subscriptions.ts create mode 100644 libs/shared-types/src/communication/websocket.ts create mode 100644 libs/shared-types/src/config/database.ts create mode 100644 libs/shared-types/src/config/index.ts create mode 100644 libs/shared-types/src/config/logging.ts create mode 100644 libs/shared-types/src/config/monitoring.ts create mode 100644 libs/shared-types/src/config/networking.ts create mode 100644 libs/shared-types/src/config/security.ts create mode 100644 libs/shared-types/src/errors/application.ts create mode 100644 libs/shared-types/src/errors/base.ts create mode 100644 libs/shared-types/src/errors/business.ts create mode 100644 libs/shared-types/src/errors/index.ts create mode 100644 libs/shared-types/src/errors/network.ts create mode 100644 libs/shared-types/src/errors/validation.ts create mode 100644 libs/shared-types/src/features/base.ts create mode 100644 libs/shared-types/src/features/groups.ts create mode 100644 libs/shared-types/src/features/index.ts create mode 100644 libs/shared-types/src/features/lineage.ts create mode 100644 libs/shared-types/src/features/monitoring.ts create mode 100644 libs/shared-types/src/features/serving.ts create mode 100644 libs/shared-types/src/governance/access.ts create mode 100644 libs/shared-types/src/governance/catalog.ts create mode 100644 libs/shared-types/src/governance/compliance.ts create mode 100644 libs/shared-types/src/governance/index.ts create mode 100644 libs/shared-types/src/governance/lifecycle.ts create mode 100644 libs/shared-types/src/governance/quality.ts create mode 100644 libs/shared-types/src/monitoring/alerts.ts create mode 100644 libs/shared-types/src/monitoring/health.ts create mode 100644 libs/shared-types/src/monitoring/index.ts create mode 100644 libs/shared-types/src/monitoring/metrics.ts create mode 100644 libs/shared-types/src/monitoring/system.ts diff --git a/.chat/Claude4-June2.json b/.chat/Claude4-June2.json deleted file mode 100644 index f3df872..0000000 --- a/.chat/Claude4-June2.json +++ /dev/null @@ -1,34104 +0,0 @@ -{ - "requesterUsername": "bojank", - "requesterAvatarIconUri": { - "$mid": 1, - "path": "/u/667489", - "scheme": "https", - "authority": "avatars.githubusercontent.com", - "query": "v=4" - }, - "responderUsername": "GitHub Copilot", - "responderAvatarIconUri": { - "id": "copilot" - }, - "initialLocation": "panel", - "requests": [ - { - "requestId": "request_ac5ad905-9c10-46fa-9bd5-4deeeeb876af", - "message": { - "parts": [ - { - "range": { - "start": 0, - "endExclusive": 85 - }, - "editorRange": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 1, - "endColumn": 86 - }, - "text": "can you look at my iteligence-services and refactor the code to seperate the services", - "kind": "text" - } - ], - "text": "can you look at my iteligence-services and refactor the code to seperate the services" - }, - "variableData": { - "variables": [ - { - "kind": "file", - "id": "vscode.implicit.viewport", - "name": "file:StrategyController.ts", - "value": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 67, - "endColumn": 6 - } - }, - "modelDescription": "User's current visible code" - } - ] - }, - "response": [ - { - "value": "I'll examine your intelligence-services and help refactor the code to properly separate the services. Let me start by exploring the current structure of the intelligence-services. ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "cd3e3f22-3331-40d4-97e0-37badab01989", - "toolId": "copilot_listDirectory" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Searching codebase for \"intelligence services strategy orchestrator backtest signal engine architecture\"", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - "pastTenseMessage": { - "value": "Searched codebase for \"intelligence services strategy orchestrator backtest signal engine architecture\", 17 results", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - "isConfirmed": true, - "isComplete": true, - "resultDetails": [ - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 212, - "startColumn": 1, - "endLineNumber": 233, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 605, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestService.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestService.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 187, - "endColumn": 1 - } - }, - { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/execution/StrategyExecutionService.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/execution/StrategyExecutionService.ts", - "scheme": "file" - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 58, - "startColumn": 3, - "endLineNumber": 76, - "endColumn": 4 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 141, - "startColumn": 1, - "endLineNumber": 166, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 80, - "startColumn": 3, - "endLineNumber": 201, - "endColumn": 13 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 212, - "startColumn": 3, - "endLineNumber": 288, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 25, - "startColumn": 1, - "endLineNumber": 83, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 404, - "startColumn": 1, - "endLineNumber": 611, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 642, - "startColumn": 1, - "endLineNumber": 667, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 13, - "startColumn": 3, - "endLineNumber": 58, - "endColumn": 8 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 63, - "startColumn": 1, - "endLineNumber": 90, - "endColumn": 2 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 116, - "startColumn": 1, - "endLineNumber": 145, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 173, - "startColumn": 1, - "endLineNumber": 224, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\strategies\\MeanReversionStrategy.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/strategies/MeanReversionStrategy.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/strategies/MeanReversionStrategy.test.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 77, - "startColumn": 1, - "endLineNumber": 131, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\ARCHITECTURE.md", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/ARCHITECTURE.md", - "path": "/g:/repos/stock-bot/ARCHITECTURE.md", - "scheme": "file" - }, - "range": { - "startLineNumber": 167, - "startColumn": 1, - "endLineNumber": 218, - "endColumn": 1 - } - } - ], - "toolCallId": "b03a1276-72a0-4e1f-a53c-9f28d28c0454", - "toolId": "copilot_searchCodebase" - }, - { - "value": "Now let me examine the other intelligence services to understand their current structure: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/index.ts), lines 1 to 1", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/index.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/index.ts), lines 1 to 1", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/index.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "24055f61-88a5-49a7-8c15-0d82281a919a", - "toolId": "copilot_readFile" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/signal-engine/src/index.ts), lines 1 to 1", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/signal-engine/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/signal-engine/src/index.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/signal-engine/src/index.ts), lines 1 to 1", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/signal-engine/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/signal-engine/src/index.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "260b800e-0cb9-4078-9d1e-e5ea3b611ab0", - "toolId": "copilot_readFile" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json), lines 1 to 1", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json), lines 1 to 1", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "3cd302df-37a6-49bd-bd11-a804f4e58ab0", - "toolId": "copilot_readFile" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/signal-engine/package.json), lines 1 to 1", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/signal-engine/package.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/signal-engine/package.json", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/signal-engine/package.json), lines 1 to 1", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/signal-engine/package.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/signal-engine/package.json", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "8858ccaf-07ff-4dea-bf66-9413f7f24692", - "toolId": "copilot_readFile" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json), lines 1 to 25", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json), lines 1 to 25", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "2cdef94d-5007-4d47-bd0f-9ab85ad36940", - "toolId": "copilot_readFile" - }, - { - "value": "Now I can see the current state of your intelligence services. The ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "inlineReference", - "inlineReference": { - "name": "strategy-orchestrator", - "kind": 12, - "containerName": "", - "location": { - "range": { - "startLineNumber": 39, - "startColumn": 49, - "endLineNumber": 39, - "endColumn": 49 - }, - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "scheme": "file" - } - } - }, - "resolveId": "72f2581f-8554-4274-a800-6bea3cf60c70" - }, - { - "value": " is currently doing everything - backtesting, signal generation, and strategy execution. The `backtest-engine` and ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "inlineReference", - "inlineReference": { - "name": "signal-engine", - "kind": 12, - "containerName": "", - "location": { - "range": { - "startLineNumber": 483, - "startColumn": 11, - "endLineNumber": 483, - "endColumn": 11 - }, - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - } - } - }, - "resolveId": "0efa5b4a-26e4-4f2f-9350-3964ab0e9796" - }, - { - "value": " are empty placeholder services. Let me refactor this to properly separate the concerns.\n\nI'll help you refactor the intelligence services to properly separate the concerns. Here's my plan:\n\n1. **Strategy Orchestrator** - Core strategy management and coordination\n2. **Backtest Engine** - Dedicated backtesting service \n3. **Signal Engine** - Signal generation and distribution\n\nLet me start by creating the separated services:\n\n## 1. First, let's create the Backtest Engine service ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Creating [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Created [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "b1123f86-2f13-4416-8bc4-e719d75e5758", - "toolId": "copilot_createFile" - }, - { - "kind": "toolInvocationSerialized", - "presentation": "hidden", - "invocationMessage": "Using \"Replace String in File\"", - "isConfirmed": true, - "isComplete": true, - "toolCallId": "c2ad984b-f6fa-41d2-80ca-c65b3fedb678", - "toolId": "copilot_replaceString" - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "kind": "codeblockUri", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\package.json", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "scheme": "file" - }, - "isEdit": true - }, - { - "kind": "textEditGroup", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\package.json", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "scheme": "file" - }, - "edits": [ - [ - { - "text": "{\n \"name\": \"backtest-engine\",\n \"version\": \"1.0.0\",\n \"description\": \"Dedicated backtesting engine for trading strategies\",\n \"main\": \"src/index.ts\",\n \"scripts\": {\n \"dev\": \"bun run --watch src/index.ts\",\n \"start\": \"bun run src/index.ts\",\n \"test\": \"bun test --timeout 10000 src/tests/**/*.test.ts\",\n \"test:watch\": \"bun test --watch src/tests/**/*.test.ts\"\n },\n \"dependencies\": {\n \"hono\": \"^4.6.3\",\n \"ioredis\": \"^5.4.1\",\n \"@stock-bot/config\": \"*\",\n \"@stock-bot/shared-types\": \"*\",\n \"ws\": \"^8.18.0\"\n },\n \"devDependencies\": {\n \"bun-types\": \"^1.2.15\",\n \"@types/ws\": \"^8.5.12\"\n }\n}", - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 1, - "endColumn": 1 - } - } - ], - [] - ], - "done": true - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "value": "Now let me move the backtesting components from strategy-orchestrator to backtest-engine: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "5fc7dcf0-d2d0-4607-b60d-d08ca6b1a683", - "toolId": "copilot_listDirectory" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": "Using \"Run In Terminal\"", - "isConfirmed": true, - "isComplete": true, - "toolSpecificData": { - "kind": "terminal", - "language": "pwsh", - "command": "mkdir -p \"g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\"" - }, - "toolCallId": "2b09ebb9-e041-4a3a-ab72-cf984c2f1f2e", - "toolId": "copilot_runInTerminal" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": "Using \"Run In Terminal\"", - "isConfirmed": true, - "isComplete": true, - "toolSpecificData": { - "kind": "terminal", - "language": "pwsh", - "command": "mkdir -p \"g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\controllers\"" - }, - "toolCallId": "721342a2-48fa-4de0-b846-36d1349046f6", - "toolId": "copilot_runInTerminal" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": "Using \"Run In Terminal\"", - "isConfirmed": true, - "isComplete": true, - "toolSpecificData": { - "kind": "terminal", - "language": "pwsh", - "command": "mkdir -p \"g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\tests\"" - }, - "toolCallId": "c049f485-fff1-4894-80aa-830e9c688331", - "toolId": "copilot_runInTerminal" - }, - { - "value": "Now let me copy the backtesting files from strategy-orchestrator to backtest-engine: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": "Using \"Run In Terminal\"", - "isConfirmed": true, - "isComplete": true, - "toolSpecificData": { - "kind": "terminal", - "language": "pwsh", - "command": "cp \"g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\*\" \"g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\\"" - }, - "toolCallId": "c57ed505-8b75-4916-8df9-e500d3d59b0e", - "toolId": "copilot_runInTerminal" - }, - { - "value": "Let me copy the files individually: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts), lines 1 to 51", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts), lines 1 to 51", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "961095f7-c4b2-4d06-ad8c-f575320b1ff1", - "toolId": "copilot_readFile" - }, - { - "kind": "confirmation", - "title": "Continue to iterate?", - "message": "Copilot has been working on this problem for a while. It can continue to iterate, or you can send a new message to refine your prompt.", - "data": { - "copilotRequestedRoundLimit": 23 - }, - "buttons": [ - "Continue", - "Pause" - ], - "isUsed": true - } - ], - "responseId": "response_5227471e-7efe-4280-a1b3-cd1a41066d77", - "result": { - "timings": { - "firstProgress": 1336, - "totalElapsed": 59658 - }, - "metadata": { - "maxToolCallsExceeded": true, - "codeBlocks": [], - "renderedUserMessage": [ - { - "type": 1, - "text": "\n\nUser's current visible code, this should be the main focus:\nExcerpt from StrategyController.ts, lines 1 to 67:\n```typescript\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\nimport { Request, Response } from 'express';\r\nimport { StrategyRegistry, StrategyType } from '../core/strategies/StrategyRegistry';\r\nimport { BacktestRequest, BacktestService } from '../core/backtesting/BacktestService';\r\nimport { BaseStrategy } from '../core/Strategy';\r\nimport { PerformanceAnalytics } from '../core/backtesting/PerformanceAnalytics';\r\n\r\n/**\r\n * Strategy Controller\r\n * \r\n * Handles HTTP requests related to strategy management, backtesting, and execution.\r\n */\r\nexport class StrategyController {\r\n private readonly strategyRegistry: StrategyRegistry;\r\n private readonly backtestService: BacktestService;\r\n \r\n constructor(apiBaseUrl: string = 'http://localhost:3001/api') {\r\n this.strategyRegistry = StrategyRegistry.getInstance();\r\n this.backtestService = new BacktestService(apiBaseUrl);\r\n }\r\n \r\n /**\r\n * Get all available strategy types\r\n */\r\n public getStrategyTypes(req: Request, res: Response): void {\r\n const types = Object.values(StrategyType);\r\n res.json({\r\n success: true,\r\n data: types\r\n });\r\n }\r\n \r\n /**\r\n * Get all strategies\r\n */\r\n public getStrategies(req: Request, res: Response): void {\r\n const strategies = this.strategyRegistry.getAllStrategies();\r\n \r\n // Convert to array of plain objects for serialization\r\n const serializedStrategies = strategies.map(strategy => ({\r\n id: strategy.id,\r\n name: strategy.name,\r\n description: strategy.description,\r\n symbols: strategy.symbols,\r\n parameters: strategy.parameters,\r\n type: this.strategyRegistry.getStrategyType(strategy)\r\n }));\r\n \r\n res.json({\r\n success: true,\r\n data: serializedStrategies\r\n });\r\n }\r\n \r\n /**\r\n * Get a specific strategy by ID\r\n */\r\n public getStrategy(req: Request, res: Response): void {\r\n const { id } = req.params;\r\n const strategy = this.strategyRegistry.getStrategyById(id);\r\n \r\n if (!strategy) {\r\n res.status(404).json({\r\n success: false,\r\n error: `Strategy with ID ${id} not found`\r\n });\r\n return;\r\n }\n```\n\n\nUser's active file for additional context:\n```typescript\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\nimport { Request, Response } from 'express';\r\nimport { StrategyRegistry, StrategyType } from '../core/strategies/StrategyRegistry';\r\nimport { BacktestRequest, BacktestService } from '../core/backtesting/BacktestService';\r\nimport { BaseStrategy } from '../core/Strategy';\r\nimport { PerformanceAnalytics } from '../core/backtesting/PerformanceAnalytics';\r\n\r\n/**\r\n * Strategy Controller\r\n * \r\n * Handles HTTP requests related to strategy management, backtesting, and execution.\r\n */\r\nexport class StrategyController {\r\n private readonly strategyRegistry: StrategyRegistry;\r\n private readonly backtestService: BacktestService;\r\n \r\n constructor(apiBaseUrl: string = 'http://localhost:3001/api') {\r\n this.strategyRegistry = StrategyRegistry.getInstance();\r\n this.backtestService = new BacktestService(apiBaseUrl);\r\n }\r\n \r\n /**\r\n * Get all available strategy types\r\n */\r\n public getStrategyTypes(req: Request, res: Response): void {\r\n const types = Object.values(StrategyType);\r\n res.json({\r\n success: true,\r\n data: types\r\n });\r\n }\r\n \r\n /**\r\n * Get all strategies\r\n */\r\n public getStrategies(req: Request, res: Response): void {\r\n const strategies = this.strategyRegistry.getAllStrategies();\r\n \r\n // Convert to array of plain objects for serialization\r\n const serializedStrategies = strategies.map(strategy => ({\r\n id: strategy.id,\r\n name: strategy.name,\r\n description: strategy.description,\r\n symbols: strategy.symbols,\r\n parameters: strategy.parameters,\r\n type: this.strategyRegistry.getStrategyType(strategy)\r\n }));\r\n \r\n res.json({\r\n success: true,\r\n data: serializedStrategies\r\n });\r\n }\r\n \r\n /**\r\n * Get a specific strategy by ID\r\n */\r\n public getStrategy(req: Request, res: Response): void {\r\n const { id } = req.params;\r\n const strategy = this.strategyRegistry.getStrategyById(id);\r\n \r\n if (!strategy) {\r\n res.status(404).json({\r\n success: false,\r\n error: `Strategy with ID ${id} not found`\r\n });\r\n return;\r\n }\r\n \r\n const type = this.strategyRegistry.getStrategyType(strategy);\r\n \r\n res.json({\r\n success: true,\r\n data: {\r\n id: strategy.id,\r\n name: strategy.name,\r\n description: strategy.description,\r\n symbols: strategy.symbols,\r\n parameters: strategy.parameters,\r\n type\r\n }\r\n });\r\n }\r\n \r\n /**\r\n * Create a new strategy\r\n */\r\n public createStrategy(req: Request, res: Response): void {\r\n try {\r\n const { name, description, symbols, parameters, type } = req.body;\r\n \r\n if (!type || !Object.values(StrategyType).includes(type)) {\r\n res.status(400).json({\r\n success: false,\r\n error: 'Invalid strategy type'\r\n });\r\n return;\r\n }\r\n \r\n const strategy = this.strategyRegistry.createStrategy(\r\n type as StrategyType,\r\n `strategy_${Date.now()}`, // Generate an ID\r\n name || `New ${type} Strategy`,\r\n description || `Generated ${type} strategy`,\r\n symbols || [],\r\n parameters || {}\r\n );\r\n \r\n res.status(201).json({\r\n success: true,\r\n data: {\r\n id: strategy.id,\r\n name: strategy.name,\r\n description: strategy.description,\r\n symbols: strategy.symbols,\r\n parameters: strategy.parameters,\r\n type\r\n }\r\n });\r\n } catch (error) {\r\n res.status(500).json({\r\n success: false,\r\n error: (error as Error).message\r\n });\r\n }\r\n }\r\n \r\n /**\r\n * Update an existing strategy\r\n */\r\n public updateStrategy(req: Request, res: Response): void {\r\n const { id } = req.params;\r\n const { name, description, symbols, parameters } = req.body;\r\n \r\n const strategy = this.strategyRegistry.getStrategyById(id);\r\n \r\n if (!strategy) {\r\n res.status(404).json({\r\n success: false,\r\n error: `Strategy with ID ${id} not found`\r\n });\r\n return;\r\n }\r\n \r\n // Update properties\r\n if (name !== undefined) strategy.name = name;\r\n if (description !== undefined) strategy.description = description;\r\n if (symbols !== undefined) (strategy as any).symbols = symbols; // Hack since symbols is readonly\r\n if (parameters !== undefined) strategy.parameters = parameters;\r\n \r\n res.json({\r\n success: true,\r\n data: {\r\n id: strategy.id,\r\n name: strategy.name,\r\n description: strategy.description,\r\n symbols: strategy.symbols,\r\n parameters: strategy.parameters,\r\n type: this.strategyRegistry.getStrategyType(strategy)\r\n }\r\n });\r\n }\r\n \r\n /**\r\n * Delete a strategy\r\n */\r\n public deleteStrategy(req: Request, res: Response): void {\r\n const { id } = req.params;\r\n const success = this.strategyRegistry.deleteStrategy(id);\r\n \r\n if (!success) {\r\n res.status(404).json({\r\n success: false,\r\n error: `Strategy with ID ${id} not found`\r\n });\r\n return;\r\n }\r\n \r\n res.json({\r\n success: true,\r\n data: { id }\r\n });\r\n }\r\n \r\n /**\r\n * Run a backtest\r\n */\r\n public async runBacktest(req: Request, res: Response): Promise {\r\n try {\r\n const backtestRequest: BacktestRequest = req.body;\r\n \r\n // Validate request\r\n if (!backtestRequest.strategyType) {\r\n res.status(400).json({\r\n success: false,\r\n error: 'Strategy type is required'\r\n });\r\n return;\r\n }\r\n \r\n if (!backtestRequest.symbols || backtestRequest.symbols.length === 0) {\r\n res.status(400).json({\r\n success: false,\r\n error: 'At least one symbol is required'\r\n });\r\n return;\r\n }\r\n \r\n // Run the backtest\r\n const result = await this.backtestService.runBacktest(backtestRequest);\r\n \r\n // Enhance results with additional metrics\r\n const enhancedResult = PerformanceAnalytics.enhanceResults(result);\r\n \r\n // Calculate additional analytics\r\n const monthlyReturns = PerformanceAnalytics.calculateMonthlyReturns(result.dailyReturns);\r\n const drawdowns = PerformanceAnalytics.analyzeDrawdowns(result.dailyReturns);\r\n \r\n res.json({\r\n success: true,\r\n data: {\r\n ...enhancedResult,\r\n monthlyReturns,\r\n drawdowns\r\n }\r\n });\r\n } catch (error) {\r\n console.error('Backtest error:', error);\r\n res.status(500).json({\r\n success: false,\r\n error: (error as Error).message\r\n });\r\n }\r\n }\r\n \r\n /**\r\n * Optimize a strategy with grid search\r\n */\r\n public async optimizeStrategy(req: Request, res: Response): Promise {\r\n try {\r\n const { baseRequest, parameterGrid } = req.body;\r\n \r\n // Validate request\r\n if (!baseRequest || !parameterGrid) {\r\n res.status(400).json({\r\n success: false,\r\n error: 'Base request and parameter grid are required'\r\n });\r\n return;\r\n }\r\n \r\n // Run optimization\r\n const results = await this.backtestService.optimizeStrategy(baseRequest, parameterGrid);\r\n \r\n res.json({\r\n success: true,\r\n data: results\r\n });\r\n } catch (error) {\r\n res.status(500).json({\r\n success: false,\r\n error: (error as Error).message\r\n });\r\n }\r\n }\r\n}\r\n\r\nexport default StrategyController;\n```\n\n\n\n\ncan you look at my iteligence-services and refactor the code to seperate the services\n\n" - } - ], - "toolCallRounds": [ - { - "response": "I'll examine your intelligence-services and help refactor the code to properly separate the services. Let me start by exploring the current structure of the intelligence-services. ", - "toolCalls": [ - { - "name": "list_dir", - "arguments": "{\"path\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\"}", - "id": "toolu_vrtx_015ZmPMnUrix75fbTG4XKEat__vscode-1748915937080" - } - ], - "toolInputRetry": 0, - "id": "5a99aa7f-bf0c-42d2-a8bd-af5e1121c25b" - }, - { - "response": "", - "toolCalls": [ - { - "name": "semantic_search", - "arguments": "{\"query\": \"intelligence services strategy orchestrator backtest signal engine architecture\"}", - "id": "toolu_vrtx_01UDU2HfLhbSTwNXAL6z9Ga7__vscode-1748915937081" - } - ], - "toolInputRetry": 0, - "id": "d0de6709-2166-4d7c-8cde-3d9229905429" - }, - { - "response": "Now let me examine the other intelligence services to understand their current structure: ", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\index.ts\", \"startLineNumberBaseZero\": 0, \"endLineNumberBaseZero\": 50}", - "id": "toolu_vrtx_01NTkqxA6Jz66cxy9PmMAxQw__vscode-1748915937082" - } - ], - "toolInputRetry": 0, - "id": "662bc244-8d35-4c92-9a1a-b20070a4faa4" - }, - { - "response": "", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"endLineNumberBaseZero\": 50, \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\signal-engine\\\\src\\\\index.ts\", \"startLineNumberBaseZero\": 0}", - "id": "toolu_01TzJaHzc1nXQryucASEb1MX__vscode-1748915937083" - } - ], - "toolInputRetry": 0, - "id": "2829183d-381a-459d-b6b9-fe5719184228" - }, - { - "response": "", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"endLineNumberBaseZero\": 50, \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\package.json\", \"startLineNumberBaseZero\": 0}", - "id": "toolu_vrtx_01BjsFTPJuX7kc7Qyaz5updN__vscode-1748915937084" - } - ], - "toolInputRetry": 0, - "id": "5ce6d645-1001-4d03-bfa2-dce34c1f4c0f" - }, - { - "response": "", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"endLineNumberBaseZero\": 50, \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\signal-engine\\\\package.json\", \"startLineNumberBaseZero\": 0}", - "id": "toolu_vrtx_01UyZy6j15TqfPPd3jAbxijv__vscode-1748915937085" - } - ], - "toolInputRetry": 0, - "id": "2422ce40-8ee9-442e-a4f6-49fa4caf120b" - }, - { - "response": "", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"endLineNumberBaseZero\": 50, \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\strategy-orchestrator\\\\package.json\", \"startLineNumberBaseZero\": 0}", - "id": "toolu_vrtx_01DXPbYzxcHpWgdwwrBTSbpm__vscode-1748915937086" - } - ], - "toolInputRetry": 0, - "id": "5687063a-0b87-4727-882b-47c04b30fc56" - }, - { - "response": "Now I can see the current state of your intelligence services. The `strategy-orchestrator` is currently doing everything - backtesting, signal generation, and strategy execution. The `backtest-engine` and `signal-engine` are empty placeholder services. Let me refactor this to properly separate the concerns.\n\nI'll help you refactor the intelligence services to properly separate the concerns. Here's my plan:\n\n1. **Strategy Orchestrator** - Core strategy management and coordination\n2. **Backtest Engine** - Dedicated backtesting service \n3. **Signal Engine** - Signal generation and distribution\n\nLet me start by creating the separated services:\n\n## 1. First, let's create the Backtest Engine service ", - "toolCalls": [ - { - "name": "create_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\package.json\", \"content\": \"{\\n \\\"name\\\": \\\"backtest-engine\\\",\\n \\\"version\\\": \\\"1.0.0\\\",\\n \\\"description\\\": \\\"Dedicated backtesting engine for trading strategies\\\",\\n \\\"main\\\": \\\"src/index.ts\\\",\\n \\\"scripts\\\": {\\n \\\"dev\\\": \\\"bun run --watch src/index.ts\\\",\\n \\\"start\\\": \\\"bun run src/index.ts\\\",\\n \\\"test\\\": \\\"bun test --timeout 10000 src/tests/**/*.test.ts\\\",\\n \\\"test:watch\\\": \\\"bun test --watch src/tests/**/*.test.ts\\\"\\n },\\n \\\"dependencies\\\": {\\n \\\"hono\\\": \\\"^4.6.3\\\",\\n \\\"ioredis\\\": \\\"^5.4.1\\\",\\n \\\"@stock-bot/config\\\": \\\"*\\\",\\n \\\"@stock-bot/shared-types\\\": \\\"*\\\",\\n \\\"ws\\\": \\\"^8.18.0\\\"\\n },\\n \\\"devDependencies\\\": {\\n \\\"bun-types\\\": \\\"^1.2.15\\\",\\n \\\"@types/ws\\\": \\\"^8.5.12\\\"\\n }\\n}\"}", - "id": "toolu_vrtx_01SsaVY7NiwsVpTu5JjiCnCH__vscode-1748915937087" - } - ], - "toolInputRetry": 0, - "id": "9626054b-9c33-490f-82a4-4c5e74cc5504" - }, - { - "response": "", - "toolCalls": [ - { - "name": "replace_string_in_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\package.json\", \"oldString\": \"\", \"newString\": \"{\\n \\\"name\\\": \\\"backtest-engine\\\",\\n \\\"version\\\": \\\"1.0.0\\\",\\n \\\"description\\\": \\\"Dedicated backtesting engine for trading strategies\\\",\\n \\\"main\\\": \\\"src/index.ts\\\",\\n \\\"scripts\\\": {\\n \\\"dev\\\": \\\"bun run --watch src/index.ts\\\",\\n \\\"start\\\": \\\"bun run src/index.ts\\\",\\n \\\"test\\\": \\\"bun test --timeout 10000 src/tests/**/*.test.ts\\\",\\n \\\"test:watch\\\": \\\"bun test --watch src/tests/**/*.test.ts\\\"\\n },\\n \\\"dependencies\\\": {\\n \\\"hono\\\": \\\"^4.6.3\\\",\\n \\\"ioredis\\\": \\\"^5.4.1\\\",\\n \\\"@stock-bot/config\\\": \\\"*\\\",\\n \\\"@stock-bot/shared-types\\\": \\\"*\\\",\\n \\\"ws\\\": \\\"^8.18.0\\\"\\n },\\n \\\"devDependencies\\\": {\\n \\\"bun-types\\\": \\\"^1.2.15\\\",\\n \\\"@types/ws\\\": \\\"^8.5.12\\\"\\n }\\n}\"}", - "id": "toolu_vrtx_01GPTQ7BRcofTkGQGRwbggtm__vscode-1748915937088" - } - ], - "toolInputRetry": 1, - "id": "eddcec56-79d5-4443-97bd-59313efe1d0f" - }, - { - "response": "Now let me move the backtesting components from strategy-orchestrator to backtest-engine: ", - "toolCalls": [ - { - "name": "list_dir", - "arguments": "{\"path\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\"}", - "id": "toolu_vrtx_019T58Db2KYmBLHCaAjHR1DA__vscode-1748915937089" - } - ], - "toolInputRetry": 0, - "id": "5bd58aa4-84b6-472e-b017-51bf90479a74" - }, - { - "response": "", - "toolCalls": [ - { - "name": "run_in_terminal", - "arguments": "{\"command\": \"mkdir -p \\\"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\"\", \"explanation\": \"Create core directory for backtest engine\", \"isBackground\": false}", - "id": "toolu_vrtx_01X3WBXTcv2C2teccePnUmSS__vscode-1748915937090" - } - ], - "toolInputRetry": 0, - "id": "40a59dac-c70a-4b00-93ce-176bc9e27890" - }, - { - "response": "", - "toolCalls": [ - { - "name": "run_in_terminal", - "arguments": "{\"command\": \"mkdir -p \\\"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\controllers\\\"\", \"explanation\": \"Create controllers directory for backtest engine\", \"isBackground\": false}", - "id": "toolu_013RpwBHAh2Z6KCgDE3fdxdw__vscode-1748915937091" - } - ], - "toolInputRetry": 0, - "id": "9616055f-b1d8-4cd8-b364-046d67243b82" - }, - { - "response": "", - "toolCalls": [ - { - "name": "run_in_terminal", - "arguments": "{\"command\": \"mkdir -p \\\"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\tests\\\"\", \"explanation\": \"Create tests directory for backtest engine\", \"isBackground\": false}", - "id": "toolu_vrtx_011beDq6rY7g6JSgJgWF5oJf__vscode-1748915937092" - } - ], - "toolInputRetry": 0, - "id": "376cc793-530b-4bd7-9a7f-94640f7d54d1" - }, - { - "response": "Now let me copy the backtesting files from strategy-orchestrator to backtest-engine: ", - "toolCalls": [ - { - "name": "run_in_terminal", - "arguments": "{\"command\": \"cp \\\"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\strategy-orchestrator\\\\src\\\\core\\\\backtesting\\\\*\\\" \\\"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\\\\"\", \"explanation\": \"Copy backtesting files to the new backtest engine service\", \"isBackground\": false}", - "id": "toolu_vrtx_01WoPQEQFeHv9qkb5gJGtRPi__vscode-1748915937093" - } - ], - "toolInputRetry": 0, - "id": "d39730fe-9a12-464b-a055-8bc030d9c2da" - }, - { - "response": "Let me copy the files individually: ", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\strategy-orchestrator\\\\src\\\\core\\\\backtesting\\\\BacktestEngine.ts\", \"startLineNumberBaseZero\": 0, \"endLineNumberBaseZero\": 50}", - "id": "toolu_vrtx_01XZdf64Vnwy1EiUYs7NwVoK__vscode-1748915937094" - } - ], - "toolInputRetry": 0, - "id": "dcd8dc0d-0ca2-4180-aac7-e41ca8ffea11" - }, - { - "response": "", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"endLineNumberBaseZero\": 604, \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\strategy-orchestrator\\\\src\\\\core\\\\backtesting\\\\BacktestEngine.ts\", \"startLineNumberBaseZero\": 0}", - "id": "toolu_vrtx_01JwvzaTu2YCaPCVoSBuWtBY__vscode-1748915937095" - } - ], - "toolInputRetry": 0, - "id": "14709764-e474-44ee-b464-2e726bc23031" - } - ], - "toolCallResults": { - "toolu_vrtx_015ZmPMnUrix75fbTG4XKEat__vscode-1748915937080": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "v6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "backtest-engine/", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "signal-engine/", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "strategy-orchestrator/", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01UDU2HfLhbSTwNXAL6z9Ga7__vscode-1748915937081": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "e6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "JSe", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "x1", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "$T", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "dP", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts` starting at line 167:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts\n/*...*/\n/**\n * Backtesting Service\n * \n * A service that handles backtesting requests and manages backtesting sessions.\n */\nexport class BacktestService {\n /*...*/\n /**\n * Get an active backtest engine by ID\n */\n getBacktestEngine(id: string): BacktestEngine | undefined {\n return this.activeBacktests.get(id);\n }\n \n /**\n * Cancel a running backtest\n */\n cancelBacktest(id: string): boolean {\n const engine = this.activeBacktests.get(id);\n if (!engine) return false;\n \n // No explicit cancel method on engine, but we can clean up\n this.activeBacktests.delete(id);\n return true;\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.01282051282051, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 641:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\n const id = c.req.param('id');\n const data = await redis.get(`backtest:${id}`);\n \n if (!data) {\n return c.json({ success: false, error: 'Backtest not found' }, 404);\n }\n \n const result = JSON.parse(data) as BacktestResult;\n return c.json({ success: true, data: result });\n } catch (error) {\n console.error('Error fetching backtest:', error);\n return c.json({ success: false, error: 'Failed to fetch backtest' }, 500);\n }\n});\n\napp.get('/api/strategy-types', (c) => {\n const types = strategyRegistry.getStrategyTypes();\n return c.json({ success: true, data: types });\n});\n\napp.get('/api/strategy-parameters/:type', (c) => {\n try {\n const type = c.req.param('type') as any;\n \n if (!strategyRegistry.hasStrategyType(type)) {\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.01282051282051 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.02564102564102, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts` starting at line 211:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\n/*...*/\n/**\n * Strategy Controller\n * \n * Handles HTTP requests related to strategy management, backtesting, and execution.\n */\nexport class StrategyController {\n /*...*/\n /**\n * Run a backtest\n */\n public async runBacktest(req: Request, res: Response): Promise {\n /*...*/\n const enhancedResult = PerformanceAnalytics.enhanceResults(result);\n \n // Calculate additional analytics\n const monthlyReturns = PerformanceAnalytics.calculateMonthlyReturns(result.dailyReturns);\n const drawdowns = PerformanceAnalytics.analyzeDrawdowns(result.dailyReturns);\n \n res.json({\n success: true,\n data: {\n ...enhancedResult,\n monthlyReturns,\n drawdowns\n }\n });\n } catch (error) {\n console.error('Backtest error:', error);\n res.status(500).json({\n success: false,\n error: (error as Error).message\n });\n }\n }\n /*...*/\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.02564102564102 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.03846153846153, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 46:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n * Initialize WebSocket server for real-time updates\n */\n private initializeWebSocketServer(port: number): void {\n /*...*/\n }\n \n /**\n * Handle incoming WebSocket messages\n */\n private handleWebSocketMessage(ws: WebSocket, message: any): void {\n /*...*/\n }\n \n /**\n * Send a message to all connected WebSocket clients\n */\n private broadcastMessage(message: any): void {\n /*...*/\n }\n \n /**\n * Send current status of all active strategies to a specific client\n */\n private sendAllStrategyStatus(ws: WebSocket): void {\n /*...*/\n }\n \n /**\n * Start the execution service (global)\n */\n start(): void {\n /*...*/\n }\n \n /**\n * Stop the execution service (global)\n */\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.03846153846153 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.05128205128206, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 485:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async closeAllPositions(): Promise {\n for (const [symbol, position] of this.positions.entries()) {\n // Find the latest price\n const bars = this.marketData.get(symbol);\n if (!bars || bars.length === 0) continue;\n \n const lastBar = bars[bars.length - 1];\n const closePrice = lastBar.close;\n \n // Calculate P&L\n const pnl = (closePrice - position.avgPrice) * position.quantity;\n \n // Update cash\n this.currentCapital += position.quantity * closePrice;\n \n // Record the trade\n this.trades.push({\n symbol,\n entryTime: position.entryTime,\n entryPrice: position.avgPrice,\n exitTime: this.currentTime,\n exitPrice: closePrice,\n quantity: position.quantity,\n pnl,\n pnlPercent: (pnl / (position.avgPrice * position.quantity)) * 100\n });\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.05128205128206 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.06410256410257, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 512:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\n await redis.publish('trading:signals', JSON.stringify(signal));\n\n return c.json({ success: true, data: signal });\n } catch (error) {\n console.error('Error generating signal:', error);\n return c.json({ success: false, error: 'Failed to generate signal' }, 500);\n }\n});\n\n// WebSocket connection handling\nwss.on('connection', (ws) => {\n console.log('New strategy monitoring client connected');\n \n ws.send(JSON.stringify({\n type: 'CONNECTED',\n message: 'Connected to Strategy Orchestrator',\n timestamp: new Date()\n }));\n\n ws.on('close', () => {\n console.log('Strategy monitoring client disconnected');\n });\n\n ws.on('error', (error) => {\n console.error('WebSocket error:', error);\n });\n});\n\nfunction broadcastToClients(message: any) {\n /*...*/\n}\n\n// Scheduled tasks for strategy management\ncron.schedule('*/5 * * * *', async () => {\n // Every 5 minutes: Check strategy health and generate signals for active strategies\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.06410256410257 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.07692307692308, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts` starting at line 140:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts\n/*...*/\n async onBar(bar: BarData): Promise {\n /*...*/\n indicators.signals = this.computeSignals(symbol, prices, volumes);\n \n // Update Bollinger Bands if configured\n if (params.useBollingerBands) {\n const bands = TechnicalIndicators.bollingerBands(\n prices,\n params.bollingerPeriod,\n params.bollingerDeviation\n );\n indicators.bollingerUpper = bands.upper;\n indicators.bollingerLower = bands.lower;\n }\n }\n \n // Get the latest signal\n const latestSignal = indicators.signals[indicators.signals.length - 1];\n \n // Generate orders based on signals\n if (latestSignal === 1 && !this.hasPosition(symbol)) {\n // Buy signal - calculate position size\n const cash = this.getAvailableCash();\n const positionValue = cash * params.positionSize;\n const quantity = Math.floor(positionValue / bar.close);\n \n if (quantity > 0) {\n /*...*/\n }\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.07692307692308 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.08974358974359, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts` starting at line 112:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts\n/*...*/\n async start(): Promise {\n /*...*/\n }\n\n async stop(): Promise {\n /*...*/\n }\n\n // Market data management\n addBar(bar: BarData): void {\n /*...*/\n }\n\n // Portfolio management helpers\n protected getCurrentPrice(symbol: string): number | null {\n /*...*/\n }\n\n protected getPosition(symbol: string): Position | null {\n /*...*/\n }\n\n protected hasPosition(symbol: string): boolean {\n /*...*/\n }\n\n protected getAvailableCash(): number {\n /*...*/\n }\n\n protected calculatePositionValue(symbol: string): number {\n /*...*/\n }\n\n protected updatePortfolioValue(): void {\n /*...*/\n }\n\n // Order creation helpers\n protected createMarketOrder(symbol: string, side: 'BUY' | 'SELL', quantity: number): Order {\n /*...*/\n }\n\n protected createLimitOrder(\n symbol: string,\n side: 'BUY' | 'SELL',\n quantity: number,\n price: number\n ): Order {\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.08974358974359 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.1025641025641, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 114:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Send current status of all active strategies to a specific client\n */\n private sendAllStrategyStatus(ws: WebSocket): void {\n const statusList = Array.from(this.activeStrategies.entries()).map(([id, data]) => ({\n id,\n name: data.strategy.name,\n status: this.isRunning ? 'ACTIVE' : 'PAUSED',\n symbols: data.config.symbols,\n positions: Array.from(data.positions.entries()).map(([symbol, pos]) => ({\n symbol,\n quantity: pos.quantity,\n entryPrice: pos.entryPrice,\n currentValue: pos.currentValue\n }))\n }));\n \n ws.send(JSON.stringify({\n type: 'strategy_status_list',\n timestamp: new Date().toISOString(),\n data: statusList\n }));\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.1025641025641 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.11538461538461, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts` starting at line 0:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts\nimport { BaseStrategy } from '../Strategy';\nimport { BacktestConfig, BacktestEngine, BacktestResult } from './BacktestEngine';\nimport { MarketDataFeed } from './MarketDataFeed';\nimport { StrategyRegistry, StrategyType } from '../strategies/StrategyRegistry';\n\nexport interface BacktestRequest {\n /*...*/\n}\n\n/**\n * Backtesting Service\n * \n * A service that handles backtesting requests and manages backtesting sessions.\n */\nexport class BacktestService {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.11538461538461 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.12820512820512, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\strategies\\MeanReversionStrategy.test.ts` starting at line 76:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\strategies\\MeanReversionStrategy.test.ts\n/*...*/\n expect(results.positions).toBeDefined();\n // Should generate at least one trade in this artificial data\n expect(results.trades.length).toBeGreaterThan(0);\n expect(results.equityCurve.length).toBeGreaterThan(0);\n });\n \n test('should calculate correct entry and exit signals', () => {\n // Mock the indicator calculations to test logic directly\n // We'll create a simple scenario where price is 2 standard deviations away\n const mockBar: BarData = {\n symbol: 'AAPL',\n timestamp: new Date(),\n open: 100,\n high: 102,\n low: 98,\n close: 100,\n volume: 1000\n };\n \n // Mock the calculation context\n const context = {\n mean: 100,\n stdDev: 5,\n upperBand: 110,\n lowerBand: 90,\n rsi: 25, // Oversold\n shouldEnterLong: true,\n shouldExitLong: false,\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.12820512820512 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.14102564102564, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 412:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private updatePositions(currentBar: BarData): void {\n // Update the unrealized P&L for positions in this symbol\n const position = this.positions.get(currentBar.symbol);\n if (position) {\n const currentPrice = currentBar.close;\n const unrealizedPnL = (currentPrice - position.avgPrice) * position.quantity;\n position.unrealizedPnL = unrealizedPnL;\n }\n \n // Calculate total portfolio value\n const portfolioValue = this.calculatePortfolioValue();\n \n // Check for new high water mark\n if (portfolioValue > this.highWaterMark) {\n this.highWaterMark = portfolioValue;\n this.drawdownStartTime = null;\n }\n \n // Check for drawdown\n if (this.drawdownStartTime === null && portfolioValue < this.highWaterMark) {\n this.drawdownStartTime = this.currentTime;\n }\n \n // Update max drawdown\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.14102564102564 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.15384615384616, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 185:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Start a specific strategy\n */\n startStrategy(strategyId: string, config?: ExecutionConfig): boolean {\n const strategy = this.strategyRegistry.getStrategyById(strategyId);\n \n if (!strategy) {\n console.error(`Strategy with ID ${strategyId} not found`);\n return false;\n }\n \n // If strategy is already active, return false\n if (this.activeStrategies.has(strategyId)) {\n console.warn(`Strategy ${strategyId} is already active`);\n return false;\n }\n \n // Use provided config or create default\n const executionConfig: ExecutionConfig = config || {\n symbols: strategy.symbols,\n dataResolution: '1m',\n realTrading: false,\n maxPositionValue: 10000,\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.15384615384616 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.16666666666667, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 204:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Start a specific strategy\n */\n startStrategy(strategyId: string, config?: ExecutionConfig): boolean {\n /*...*/\n maxOrdersPerMinute: 5,\n stopLossPercentage: 0.02\n };\n \n // Initialize strategy data\n const strategyData = {\n strategy,\n config: executionConfig,\n positions: new Map(),\n lastBar: new Map()\n };\n \n this.activeStrategies.set(strategyId, strategyData);\n \n // If execution service is running, start data polling for this strategy\n if (this.isRunning) {\n this.startDataPollingForStrategy(strategyId, strategyData);\n }\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.16666666666667 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.17948717948718, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts` starting at line 57:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts\n/*...*/\n async initialize(): Promise {\n // Initialize state for each symbol\n for (const symbol of this.symbols) {\n this.indicators.set(symbol, {\n prices: [],\n signals: [],\n stopLevels: [],\n profitLevels: []\n });\n }\n \n // Validate parameters\n const params = this.parameters as VectorizedStrategyParams;\n \n if (params.positionSize <= 0 || params.positionSize > 1) {\n console.warn('Position size should be between 0 and 1');\n params.positionSize = 0.2; // Reset to default\n }\n }\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.17948717948718 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.1923076923077, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 71:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Initialize WebSocket server for real-time updates\n */\n private initializeWebSocketServer(port: number): void {\n /*...*/\n this.sendAllStrategyStatus(ws);\n });\n \n console.log(`WebSocket server started on port ${port}`);\n } catch (error) {\n console.error('Failed to initialize WebSocket server:', error);\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.1923076923077 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.2051282051282, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts` starting at line 28:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts\n/*...*/\n/**\n * Backtesting Service\n * \n * A service that handles backtesting requests and manages backtesting sessions.\n */\nexport class BacktestService {\n /*...*/\n constructor(apiBaseUrl: string = 'http://localhost:3001/api') {\n this.strategyRegistry = StrategyRegistry.getInstance();\n this.dataFeed = new MarketDataFeed(apiBaseUrl);\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.2051282051282 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.21794871794872, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 300:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async processOrder(order: Order): Promise {\n /*...*/\n fillPrice = bar.close * slippageFactor;\n } else if (order.type === 'LIMIT' && order.price !== undefined) {\n // For limit orders, check if the price was reached\n if ((order.side === 'BUY' && bar.low <= order.price) ||\n (order.side === 'SELL' && bar.high >= order.price)) {\n fillPrice = order.price;\n } else {\n // Limit price not reached\n return;\n }\n } else {\n // Other order types not implemented\n order.status = 'REJECTED';\n this.emit('orderRejected', { order, reason: 'Order type not supported' });\n return;\n }\n \n // Calculate commission\n const orderValue = order.quantity * fillPrice;\n const commission = orderValue * this.config.commission;\n \n // Check if we have enough cash for BUY orders\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.21794871794872 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.23076923076923, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts` starting at line 211:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts\n/*...*/\n }\n\n protected createStopOrder(\n symbol: string,\n side: 'BUY' | 'SELL',\n quantity: number,\n stopPrice: number\n ): Order {\n /*...*/\n }\n\n private generateOrderId(): string {\n /*...*/\n }\n\n // Utility methods for common strategy patterns\n protected getBarsSince(symbol: string, periods: number): BarData[] {\n /*...*/\n }\n\n protected getReturns(symbol: string, periods: number): number[] {\n /*...*/\n }\n\n protected getVolatility(symbol: string, periods: number): number {\n /*...*/\n }\n\n // Parameter validation\n protected validateParameters(): boolean {\n /*...*/\n }\n\n // Get strategy state for serialization\n getState() {\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.23076923076923 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.24358974358974, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 38:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n constructor(apiBaseUrl: string = 'http://localhost:3001/api', wsPort: number = 8082) {\n super();\n this.strategyRegistry = StrategyRegistry.getInstance();\n this.marketDataFeed = new MarketDataFeed(apiBaseUrl);\n this.initializeWebSocketServer(wsPort);\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.24358974358974 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.25641025641026, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 549:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private generateResults(): BacktestResult {\n const currentPortfolioValue = this.calculatePortfolioValue();\n const totalReturn = (currentPortfolioValue - this.initialCapital) / this.initialCapital;\n \n // Calculate annualized return\n const days = (this.config.endDate.getTime() - this.config.startDate.getTime()) / (1000 * 60 * 60 * 24);\n const annualizedReturn = Math.pow(1 + totalReturn, 365 / days) - 1;\n \n // Calculate Sharpe Ratio\n let sharpeRatio = 0;\n if (this.dailyReturns.length > 1) {\n const dailyReturnValues = this.dailyReturns.map(dr => dr.return);\n const avgDailyReturn = dailyReturnValues.reduce((sum, ret) => sum + ret, 0) / dailyReturnValues.length;\n const stdDev = Math.sqrt(\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.25641025641026 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.26923076923077, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\strategies\\MeanReversionStrategy.test.ts` starting at line 104:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\strategies\\MeanReversionStrategy.test.ts\n/*...*/\n shouldEnterShort: false,\n shouldExitShort: false\n };\n \n // Call the internal signal generation logic via a protected method\n // (For testing purposes, we're accessing a protected method)\n const result = (strategy as any).calculateSignals('AAPL', mockBar, context);\n \n // Assert the signals based on our scenario\n expect(result).toBeDefined();\n expect(result.action).toBe('BUY'); // Should buy in oversold condition\n });\n \n test('should handle empty data correctly', async () => {\n // Act & Assert\n await expect(async () => {\n await strategy.runVectorized({\n symbols: ['AAPL'],\n data: { 'AAPL': [] },\n initialCapital: 10000,\n startIndex: 0,\n endIndex: 0\n });\n }).not.toThrow();\n });\n});\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.26923076923077 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.28205128205128, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 15:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport interface BacktestResult {\n strategyId: string;\n startDate: Date;\n endDate: Date;\n duration: number; // In milliseconds\n initialCapital: number;\n finalCapital: number;\n totalReturn: number;\n annualizedReturn: number;\n sharpeRatio: number;\n maxDrawdown: number;\n maxDrawdownDuration: number; // In days\n winRate: number;\n totalTrades: number;\n winningTrades: number;\n losingTrades: number;\n averageWinningTrade: number;\n averageLosingTrade: number;\n profitFactor: number;\n dailyReturns: Array<{ date: Date; return: number }>;\n trades: Array<{\n symbol: string;\n entryTime: Date;\n entryPrice: number;\n exitTime: Date;\n exitPrice: number;\n quantity: number;\n pnl: number;\n pnlPercent: number;\n }>;\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.28205128205128 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.2948717948718, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 510:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.2948717948718 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.3076923076923, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\ARCHITECTURE.md` starting at line 199:\n````md\n// filepath: g:\\repos\\stock-bot\\ARCHITECTURE.md\n# 🏗️ Stock Bot Trading System - Architecture Documentation\n...\n## 🔧 Service Breakdown\n...\n### **2. Core Services**\n...\n#### **Strategy Orchestrator** (`apps/intelligence-services/strategy-orchestrator`)\n...\n│ │ └── TechnicalIndicators.ts # Technical analysis\n│ ├── controllers/\n│ │ └── StrategyController.ts # API endpoints\n│ └── index.ts # Main entry point\n```\n\n**API Endpoints:**\n```\nGET /health # Health check\nGET /api/strategies # List strategies\nPOST /api/strategies # Create strategy\nPUT /api/strategies/:id # Update strategy\nPOST /api/strategies/:id/:action # Start/stop/pause strategy\nGET /api/strategies/:id/signals # Get strategy signals\nPOST /api/strategies/:id/backtest # Run backtest\nGET /api/strategies/:id/performance # Get performance metrics\nWS /ws # WebSocket for strategy updates\n```\n...\n````\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.3076923076923 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.32051282051282, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\ARCHITECTURE.md` starting at line 188:\n```md\n// filepath: g:\\repos\\stock-bot\\ARCHITECTURE.md\n# 🏗️ Stock Bot Trading System - Architecture Documentation\n...\n## 🔧 Service Breakdown\n...\n### **2. Core Services**\n...\n#### **Strategy Orchestrator** (`apps/intelligence-services/strategy-orchestrator`)\n...\n│ │ │ └── PerformanceAnalytics.ts # Performance metrics\n│ │ ├── execution/\n│ │ │ └── StrategyExecutionService.ts # Real-time execution\n│ │ ├── strategies/\n│ │ │ ├── Strategy.ts # Base strategy interface\n│ │ │ ├── StrategyRegistry.ts # Strategy management\n│ │ │ ├── BaseStrategy.ts # Abstract base class\n│ │ │ ├── VectorizedStrategy.ts # Vectorized base class\n│ │ │ ├── MovingAverageCrossover.ts # MA strategy\n│ │ │ └── MeanReversionStrategy.ts # Mean reversion\n│ │ └── indicators/\n...\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.32051282051282 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.33333333333333, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts` starting at line 79:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts\n/*...*/\n constructor(\n id: string,\n name: string,\n description: string,\n symbols: string[],\n parameters: StrategyParameters = {}\n ) {\n super();\n this.id = id;\n this.name = name;\n this.description = description;\n this.symbols = symbols;\n this.parameters = parameters;\n \n this.context = {\n currentTime: new Date(),\n portfolio: {\n cash: 100000, // Default starting capital\n positions: new Map(),\n totalValue: 100000\n },\n marketData: new Map(),\n indicators: new Map()\n };\n }\n /*...*/\n // Lifecycle methods\n async start(): Promise {\n if (!this.isInitialized) {\n await this.initialize();\n this.isInitialized = true;\n }\n this.emit('started', { strategyId: this.id });\n }\n\n async stop(): Promise {\n await this.cleanup();\n this.emit('stopped', { strategyId: this.id });\n }\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.33333333333333 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.34615384615384, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 472:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private calculateDailyReturn(): void {\n const portfolioValue = this.calculatePortfolioValue();\n const dailyReturn = (portfolioValue - this.previousPortfolioValue) / this.previousPortfolioValue;\n \n this.dailyReturns.push({\n date: new Date(this.currentTime),\n return: dailyReturn\n });\n \n this.previousPortfolioValue = portfolioValue;\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.34615384615384 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.35897435897436, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 562:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private generateResults(): BacktestResult {\n /*...*/\n dailyReturnValues.reduce((sum, ret) => sum + Math.pow(ret - avgDailyReturn, 2), 0) / dailyReturnValues.length\n );\n \n // Annualize\n sharpeRatio = stdDev > 0 \n ? (avgDailyReturn * 252) / (stdDev * Math.sqrt(252)) \n : 0;\n }\n \n // Calculate win rate and profit factor\n const totalTrades = this.winningTrades + this.losingTrades + this.breakEvenTrades;\n const winRate = totalTrades > 0 ? this.winningTrades / totalTrades : 0;\n const profitFactor = this.totalLosses > 0 ? this.totalProfits / this.totalLosses : (this.totalProfits > 0 ? Infinity : 0);\n \n // Calculate average winning and losing trade\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.35897435897436 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.37179487179488, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 596:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private generateResults(): BacktestResult {\n /*...*/\n averageWinningTrade: avgWinningTrade,\n averageLosingTrade: avgLosingTrade,\n profitFactor,\n dailyReturns: this.dailyReturns,\n trades: this.trades\n };\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.37179487179488 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.38461538461539, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts` starting at line 62:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts\n/*...*/\n// Mock strategy for testing\nclass MockStrategy extends BaseStrategy {\n name = 'MockStrategy';\n description = 'A mock strategy for testing';\n symbols = ['AAPL', 'MSFT'];\n parameters = { param1: 1, param2: 2 };\n \n constructor(id: string) {\n super(id);\n }\n \n async start(): Promise {}\n \n async stop(): Promise {}\n \n onBar(bar: BarData) {\n // Return a mock signal\n return {\n action: 'BUY',\n symbol: bar.symbol,\n price: bar.close,\n quantity: 10,\n metadata: { reason: 'Test signal' }\n };\n }\n \n async onOrderFilled(order: Order): Promise {}\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.38461538461539 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.3974358974359, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts` starting at line 77:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts\n/*...*/\n/**\n * Backtesting Service\n * \n * A service that handles backtesting requests and manages backtesting sessions.\n */\nexport class BacktestService {\n /*...*/\n /**\n * Run a backtest based on a request\n */\n async runBacktest(request: BacktestRequest): Promise {\n /*...*/\n console.log(`[Backtest ${strategyId}] ${eventName}:`, data);\n });\n };\n \n forwardEvents('started');\n forwardEvents('loading');\n forwardEvents('loaded');\n forwardEvents('progress');\n forwardEvents('orderFilled');\n forwardEvents('orderRejected');\n forwardEvents('completed');\n forwardEvents('error');\n \n // Run the backtest\n const result = await engine.run();\n \n // Clean up\n this.activeBacktests.delete(strategyId);\n \n return result;\n } catch (error) {\n this.activeBacktests.delete(strategyId);\n throw error;\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.3974358974359 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.41025641025641, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts` starting at line 5:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts\n/*...*/\nexport interface BacktestRequest {\n strategyType: StrategyType;\n strategyParams: Record;\n symbols: string[];\n startDate: Date | string;\n endDate: Date | string;\n initialCapital: number;\n dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\n commission: number;\n slippage: number;\n mode: 'event' | 'vector';\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.41025641025641 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.42307692307692, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts` starting at line 58:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts\n/*...*/\n/**\n * Backtesting Service\n * \n * A service that handles backtesting requests and manages backtesting sessions.\n */\nexport class BacktestService {\n /*...*/\n /**\n * Run a backtest based on a request\n */\n async runBacktest(request: BacktestRequest): Promise {\n /*...*/\n const config: BacktestConfig = {\n startDate,\n endDate,\n symbols: request.symbols,\n initialCapital: request.initialCapital,\n commission: request.commission,\n slippage: request.slippage,\n dataResolution: request.dataResolution,\n mode: request.mode\n };\n \n // Create and run the backtest engine\n const engine = new BacktestEngine(strategy, config, this.dataFeed);\n this.activeBacktests.set(strategyId, engine);\n \n try {\n // Set up event forwarding\n const forwardEvents = (eventName: string) => {\n engine.on(eventName, (data) => {\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.42307692307692 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.43589743589743, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 85:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private maxDrawdownDuration: number = 0;\n private winningTrades: number = 0;\n private losingTrades: number = 0;\n private breakEvenTrades: number = 0;\n private totalProfits: number = 0;\n private totalLosses: number = 0;\n\n constructor(strategy: BaseStrategy, config: BacktestConfig, dataFeed: DataFeed) {\n /*...*/\n }\n\n async run(): Promise {\n /*...*/\n }\n\n private async runEventBased(): Promise {\n /*...*/\n }\n\n private async runVectorized(): Promise {\n /*...*/\n }\n\n private async loadMarketData(): Promise {\n /*...*/\n }\n\n private createMergedTimeline(): BarData[] {\n /*...*/\n }\n\n private async processOrders(currentBar: BarData): Promise {\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.43589743589743 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.44871794871794, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts` starting at line 12:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts\n/*...*/\n class MockWebSocket extends EventEmitter {\n static OPEN = 1;\n readyState = 1;\n close = jest.fn();\n send = jest.fn();\n }\n \n class MockServer extends EventEmitter {\n clients = new Set();\n \n constructor() {\n super();\n // Add a mock client to the set\n const mockClient = new MockWebSocket();\n this.clients.add(mockClient);\n }\n \n close(callback) {\n callback();\n }\n }\n /*...*/\n async getHistoricalData(symbol, resolution, startDate, endDate) {\n // Return mock data\n return [\n {\n symbol,\n timestamp: new Date(),\n open: 100,\n high: 105,\n low: 95,\n close: 102,\n volume: 1000\n }\n ];\n }\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.44871794871794 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.46153846153847, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 49:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Initialize WebSocket server for real-time updates\n */\n private initializeWebSocketServer(port: number): void {\n try {\n this.webSocketServer = new WebSocket.Server({ port });\n \n this.webSocketServer.on('connection', (ws) => {\n console.log('New client connected to strategy execution service');\n this.wsClients.add(ws);\n \n ws.on('message', (message) => {\n try {\n const data = JSON.parse(message.toString());\n this.handleWebSocketMessage(ws, data);\n } catch (error) {\n console.error('Error handling WebSocket message:', error);\n }\n });\n \n ws.on('close', () => {\n console.log('Client disconnected from strategy execution service');\n this.wsClients.delete(ws);\n });\n \n // Send initial state\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.46153846153847 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.47435897435898, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 402:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Process a new bar with the strategy\n */ private processBar(strategyId: string, symbol: string, bar: BarData): void {\n const strategyData = this.activeStrategies.get(strategyId);\n \n if (!strategyData) {\n console.warn(`Strategy ${strategyId} not found in active strategies`);\n return;\n }\n \n const { strategy } = strategyData;\n \n // Call strategy's onBar method to get trading signals\n const signal = strategy.onBar(bar);\n \n if (signal) {\n // Create a signal object with timestamp and ID\n const signalObject = {\n id: `sig_${Date.now()}_${Math.floor(Math.random() * 10000)}`,\n strategyId,\n name: strategy.name,\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.47435897435898 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.48717948717949, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 577:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private generateResults(): BacktestResult {\n /*...*/\n const avgWinningTrade = this.winningTrades > 0 ? this.totalProfits / this.winningTrades : 0;\n const avgLosingTrade = this.losingTrades > 0 ? this.totalLosses / this.losingTrades : 0;\n \n return {\n strategyId: this.strategy.id,\n startDate: this.config.startDate,\n endDate: this.config.endDate,\n duration: Date.now() - this.startTime,\n initialCapital: this.initialCapital,\n finalCapital: currentPortfolioValue,\n totalReturn,\n annualizedReturn,\n sharpeRatio,\n maxDrawdown: this.maxDrawdown,\n maxDrawdownDuration: this.maxDrawdownDuration,\n winRate,\n totalTrades,\n winningTrades: this.winningTrades,\n losingTrades: this.losingTrades,\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.48717948717949 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.5, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 372:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async processOrder(order: Order): Promise {\n /*...*/\n // Position closed, record the trade\n this.positions.delete(order.symbol);\n \n this.trades.push({\n symbol: order.symbol,\n entryTime: position.entryTime,\n entryPrice: position.avgPrice,\n exitTime: this.currentTime,\n exitPrice: fillPrice,\n quantity: order.quantity,\n pnl: pnl,\n pnlPercent: (pnl / (position.avgPrice * order.quantity)) * 100\n });\n \n // Update statistics\n if (pnl > 0) {\n this.winningTrades++;\n this.totalProfits += pnl;\n } else if (pnl < 0) {\n this.losingTrades++;\n this.totalLosses -= pnl; // Make positive for easier calculations\n } else {\n this.breakEvenTrades++;\n }\n }\n }\n \n // Mark order as filled\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.51282051282051, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 344:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async processOrder(order: Order): Promise {\n /*...*/\n this.positions.set(order.symbol, {\n symbol: order.symbol,\n quantity: order.quantity,\n avgPrice: fillPrice,\n side: 'LONG',\n entryTime: this.currentTime\n });\n }\n } else if (order.side === 'SELL') {\n const position = this.positions.get(order.symbol);\n \n if (!position || position.quantity < order.quantity) {\n // Not enough shares to sell\n order.status = 'REJECTED';\n this.emit('orderRejected', { order, reason: 'Insufficient position' });\n return;\n }\n \n // Calculate P&L\n const pnl = (fillPrice - position.avgPrice) * order.quantity;\n \n // Update cash\n this.currentCapital += orderValue - commission;\n \n // Update position\n position.quantity -= order.quantity;\n \n if (position.quantity === 0) {\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.51282051282051 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.52564102564102, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 211:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async runVectorized(): Promise {\n /*...*/\n let maxDrawdownEndDate = new Date();\n let currentDrawdownStart = new Date();\n \n // Pre-process data (this would be implemented by the specific strategy)\n const allBars = new Map();\n for (const symbol of this.config.symbols) {\n allBars.set(symbol, this.marketData.get(symbol) || []);\n }\n \n // Apply strategy logic (vectorized implementation would be here)\n // For now, we'll just simulate the processing\n \n this.emit('completed', { message: 'Vectorized backtest completed in fast mode' });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.52564102564102 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.53846153846153, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 223:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Start a specific strategy\n */\n startStrategy(strategyId: string, config?: ExecutionConfig): boolean {\n /*...*/\n console.log(`Strategy ${strategyId} started with ${executionConfig.symbols.length} symbols`);\n \n this.broadcastMessage({\n type: 'strategy_started',\n timestamp: new Date().toISOString(),\n data: {\n strategyId,\n name: strategy.name,\n symbols: executionConfig.symbols\n }\n });\n \n return true;\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.53846153846153 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.55128205128206, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\ARCHITECTURE.md` starting at line 166:\n````md\n// filepath: g:\\repos\\stock-bot\\ARCHITECTURE.md\n# 🏗️ Stock Bot Trading System - Architecture Documentation\n...\n## 🔧 Service Breakdown\n...\n### **2. Core Services**\n...\n#### **Strategy Orchestrator** (`apps/intelligence-services/strategy-orchestrator`)\n- **Framework**: Hono + Bun\n- **Port**: 4001\n- **Purpose**: Strategy lifecycle management and execution\n- **Database**: MongoDB (strategies), PostgreSQL (trades), Redis (signals)\n\n**Responsibilities:**\n- Strategy creation and management\n- Backtesting engine (vectorized & event-based)\n- Real-time strategy execution\n- Signal generation and broadcasting\n- Performance analytics\n- Strategy optimization\n\n**Current Structure:**\n```\nstrategy-orchestrator/\n├── src/\n│ ├── core/\n│ │ ├── backtesting/\n│ │ │ ├── BacktestEngine.ts # Main backtesting engine\n│ │ │ ├── BacktestService.ts # Backtesting service layer\n│ │ │ ├── MarketDataFeed.ts # Historical data provider\n...\n````\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.55128205128206 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.56410256410257, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 322:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async processOrder(order: Order): Promise {\n /*...*/\n if (order.side === 'BUY') {\n const totalCost = orderValue + commission;\n if (totalCost > this.currentCapital) {\n // Not enough cash\n order.status = 'REJECTED';\n this.emit('orderRejected', { order, reason: 'Insufficient funds' });\n return;\n }\n \n // Update cash\n this.currentCapital -= totalCost;\n \n // Update or create position\n const existingPosition = this.positions.get(order.symbol);\n if (existingPosition) {\n // Update existing position (average down)\n const totalShares = existingPosition.quantity + order.quantity;\n const totalCost = (existingPosition.quantity * existingPosition.avgPrice) + (order.quantity * fillPrice);\n existingPosition.avgPrice = totalCost / totalShares;\n existingPosition.quantity = totalShares;\n } else {\n // Create new position\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.56410256410257 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.57692307692308, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 432:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\n data: signals.sort((a: any, b: any) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime())\n });\n } catch (error) {\n console.error('Error fetching strategy signals:', error);\n return c.json({ success: false, error: 'Failed to fetch signals' }, 500);\n }\n});\n\n// Get strategy trades\napp.get('/api/strategies/:id/trades', async (c) => {\n try {\n const id = c.req.param('id');\n const limit = parseInt(c.req.query('limit') || '50');\n \n const tradeKeys = await redis.keys(`trade:${id}:*`);\n const trades: any[] = [];\n \n for (const key of tradeKeys.slice(0, limit)) {\n const data = await redis.get(key);\n if (data) {\n trades.push(JSON.parse(data));\n }\n }\n\n return c.json({\n success: true,\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.57692307692308 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.58974358974359, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts` starting at line 115:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts\n/*...*/\n executionService = new StrategyExecutionService('http://localhost:3001/api', 8082);\n strategyRegistry = StrategyRegistry.getInstance();\n \n // Setup mock strategy\n const mockStrategy = new MockStrategy('test-strategy');\n (strategyRegistry.getStrategyById as jest.Mock).mockReturnValue(mockStrategy);\n });\n \n afterEach(() => {\n executionService.shutdown();\n });\n \n it('should initialize correctly', () => {\n expect(executionService).toBeDefined();\n });\n \n it('should start a strategy correctly', () => {\n // Arrange & Act\n const result = executionService.startStrategy('test-strategy');\n \n // Assert\n expect(result).toBe(true);\n expect(strategyRegistry.getStrategyById).toHaveBeenCalledWith('test-strategy');\n \n // Check if WebSocket broadcast happened\n const ws = executionService['webSocketServer'].clients.values().next().value;\n expect(ws.send).toHaveBeenCalled();\n \n // Check the broadcast message contains the correct type\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.58974358974359 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.6025641025641, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 226:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async loadMarketData(): Promise {\n for (const symbol of this.config.symbols) {\n this.emit('loading', { symbol, resolution: this.config.dataResolution });\n \n // Check if data is available\n const hasData = await this.dataFeed.hasDataFor(\n symbol,\n this.config.dataResolution,\n this.config.startDate,\n this.config.endDate\n );\n \n if (!hasData) {\n throw new Error(`No data available for ${symbol} at resolution ${this.config.dataResolution}`);\n }\n \n // Load data\n const data = await this.dataFeed.getHistoricalData(\n symbol,\n this.config.dataResolution,\n this.config.startDate,\n this.config.endDate\n );\n \n this.marketData.set(symbol, data);\n this.emit('loaded', { symbol, count: data.length });\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.6025641025641 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.61538461538461, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 255:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private createMergedTimeline(): BarData[] {\n const allBars: BarData[] = [];\n \n for (const [symbol, bars] of this.marketData.entries()) {\n allBars.push(...bars);\n }\n \n // Sort by timestamp\n return allBars.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());\n }\n\n private async processOrders(currentBar: BarData): Promise {\n // Find orders for the current symbol\n const ordersToProcess = this.pendingOrders.filter(order => order.symbol === currentBar.symbol);\n \n if (ordersToProcess.length === 0) return;\n \n // Remove these orders from pendingOrders\n this.pendingOrders = this.pendingOrders.filter(order => order.symbol !== currentBar.symbol);\n \n // Process each order\n for (const order of ordersToProcess) {\n await this.processOrder(order);\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.61538461538461 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.62820512820512, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 435:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Process a new bar with the strategy\n */ private processBar(strategyId: string, symbol: string, bar: BarData): void {\n /*...*/\n port: parseInt(process.env.REDIS_PORT || '6379')\n }) : null;\n \n if (redis) {\n // Store signal with TTL of 7 days\n redis.setex(\n `signal:${strategyId}:${signalObject.id}`,\n 60 * 60 * 24 * 7, // 7 days TTL\n JSON.stringify(signalObject)\n );\n }\n } catch (err) {\n console.error('Error storing signal in Redis:', err);\n }\n \n // Broadcast the signal\n this.broadcastMessage({\n type: 'strategy_signal',\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.62820512820512 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.64102564102564, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 281:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async processOrder(order: Order): Promise {\n /*...*/\n }\n\n private updatePositions(currentBar: BarData): void {\n /*...*/\n }\n\n private calculatePortfolioValue(): number {\n /*...*/\n }\n\n private calculateDailyReturn(): void {\n /*...*/\n }\n\n private async closeAllPositions(): Promise {\n /*...*/\n }\n\n private updateProgress(progress: number): void {\n /*...*/\n }\n\n private generateResults(): BacktestResult {\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.64102564102564 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.65384615384616, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 7:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\nexport interface ExecutionConfig {\n symbols: string[];\n dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\n realTrading: boolean;\n maxPositionValue: number;\n maxOrdersPerMinute: number;\n stopLossPercentage: number;\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.65384615384616 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.66666666666667, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 190:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async runVectorized(): Promise {\n // Load market data for all symbols\n await this.loadMarketData();\n \n // To implement a vectorized approach, we need to:\n // 1. Pre-compute technical indicators\n // 2. Generate buy/sell signals for the entire dataset\n // 3. Calculate portfolio values based on signals\n \n // This is a simplified implementation since specific vectorized strategies\n // will need to be implemented separately based on the strategy type\n\n const timeline = this.createMergedTimeline();\n const startTime = Date.now();\n \n // Initialize variables for tracking performance\n let currentPositions = new Map();\n let currentCash = this.initialCapital;\n let prevPortfolioValue = this.initialCapital;\n let highWaterMark = this.initialCapital;\n let maxDrawdown = 0;\n let maxDrawdownStartDate = new Date();\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.66666666666667 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.67948717948718, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 282:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async processOrder(order: Order): Promise {\n // Get the latest price for the symbol\n const latestBars = this.marketData.get(order.symbol);\n if (!latestBars || latestBars.length === 0) {\n order.status = 'REJECTED';\n this.emit('orderRejected', { order, reason: 'No market data available' });\n return;\n }\n \n // Find the bar closest to the order time\n const bar = latestBars.find(b => \n b.timestamp.getTime() >= order.timestamp.getTime()\n ) || latestBars[latestBars.length - 1];\n \n // Calculate fill price with slippage\n let fillPrice: number;\n if (order.type === 'MARKET') {\n // Apply slippage model\n const slippageFactor = 1 + (order.side === 'BUY' ? this.config.slippage : -this.config.slippage);\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.67948717948718 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.6923076923077, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 453:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Process a new bar with the strategy\n */ private processBar(strategyId: string, symbol: string, bar: BarData): void {\n /*...*/\n timestamp: new Date().toISOString(),\n data: signalObject\n });\n \n // Execute the signal if real trading is enabled\n if (strategyData.config.realTrading) {\n this.executeSignal(strategyId, signal);\n }\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.6923076923077 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.7051282051282, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts` starting at line 172:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts\n/*...*/\n executionService.startStrategy('test-strategy');\n \n // Act\n const result = executionService.pauseStrategy('test-strategy');\n \n // Assert\n expect(result).toBe(true);\n \n // Check if WebSocket broadcast happened\n const ws = executionService['webSocketServer'].clients.values().next().value;\n const lastCallIndex = ws.send.mock.calls.length - 1;\n const lastCall = ws.send.mock.calls[lastCallIndex][0];\n const message = JSON.parse(lastCall);\n \n expect(message.type).toBe('strategy_paused');\n expect(message.data.strategyId).toBe('test-strategy');\n });\n \n it('should process market data and generate signals', async () => {\n // Arrange\n executionService.startStrategy('test-strategy');\n \n // Act - Trigger market data polling manually\n await executionService['pollMarketData']('test-strategy');\n \n // Assert - Check if signal was generated and broadcast\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.7051282051282 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.71794871794872, - "text": "Here is the full text of `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts`:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\nimport { EventEmitter } from 'events';\nimport { BaseStrategy } from '../Strategy';\nimport { BarData, Order, Position } from '../Strategy';\nimport { MarketDataFeed } from '../backtesting/MarketDataFeed';\nimport { StrategyRegistry } from '../strategies/StrategyRegistry';\nimport { WebSocket } from 'ws';\n\nexport interface ExecutionConfig {\n /*...*/\n}\n\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.71794871794872 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.73076923076923, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 47:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport interface BacktestProgress {\n progress: number; // 0-100\n currentDate: Date;\n processingSpeed: number; // Bars per second\n estimatedTimeRemaining: number; // milliseconds\n currentCapital: number;\n currentReturn: number;\n currentDrawdown: number;\n}\n\nexport interface DataFeed {\n getHistoricalData(symbol: string, resolution: string, start: Date, end: Date): Promise;\n hasDataFor(symbol: string, resolution: string, start: Date, end: Date): Promise;\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.73076923076923 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.74358974358974, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 458:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\n data: trades.sort((a: any, b: any) => new Date(b.exitTime || b.timestamp).getTime() - new Date(a.exitTime || a.timestamp).getTime())\n });\n } catch (error) {\n console.error('Error fetching strategy trades:', error);\n return c.json({ success: false, error: 'Failed to fetch trades' }, 500);\n }\n});\n\n// Generate demo signal (for testing)\napp.post('/api/strategies/:id/generate-signal', async (c) => {\n try {\n const id = c.req.param('id');\n const strategy = strategies.get(id);\n \n if (!strategy) {\n return c.json({ success: false, error: 'Strategy not found' }, 404);\n }\n\n if (strategy.status !== 'ACTIVE') {\n return c.json({ success: false, error: 'Strategy is not active' }, 400);\n }\n\n // Generate demo signal\n const symbol = strategy.symbols[Math.floor(Math.random() * strategy.symbols.length)] || 'AAPL';\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.74358974358974 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.75641025641026, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 468:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Execute a trading signal\n */\n private executeSignal(strategyId: string, signal: any): void {\n // In a real implementation, this would connect to the order execution service\n // For now, just log the signal and broadcast a mock trade\n console.log(`Executing signal for strategy ${strategyId}:`, signal);\n \n const strategyData = this.activeStrategies.get(strategyId);\n if (!strategyData) return;\n \n const { strategy } = strategyData;\n \n // Broadcast mock trade execution\n this.broadcastMessage({\n type: 'strategy_trade',\n timestamp: new Date().toISOString(),\n data: {\n strategyId,\n name: strategy.name,\n symbol: signal.symbol,\n price: signal.price,\n action: signal.action,\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.75641025641026 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.76923076923077, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 4:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport interface BacktestConfig {\n startDate: Date;\n endDate: Date;\n symbols: string[];\n initialCapital: number;\n commission: number; // Per trade commission (percentage)\n slippage: number; // Slippage model (percentage)\n dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\n mode: 'event' | 'vector';\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.76923076923077 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.78205128205128, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts` starting at line 269:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts\n/*...*/\n // Get strategy state for serialization\n getState() {\n return {\n id: this.id,\n name: this.name,\n description: this.description,\n symbols: this.symbols,\n parameters: this.parameters,\n isInitialized: this.isInitialized,\n currentTime: this.context.currentTime,\n portfolio: {\n cash: this.context.portfolio.cash,\n totalValue: this.context.portfolio.totalValue,\n positions: Array.from(this.context.portfolio.positions.entries())\n }\n };\n }\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.78205128205128 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.7948717948718, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 400:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async processOrder(order: Order): Promise {\n /*...*/\n order.status = 'FILLED';\n order.fillPrice = fillPrice;\n order.fillTime = this.currentTime;\n this.filledOrders.push(order);\n \n // Notify strategy\n await this.strategy.onOrderFilled(order);\n \n this.emit('orderFilled', { order });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.7948717948718 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.8076923076923, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 104:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n async run(): Promise {\n if (this.isRunning) {\n throw new Error('Backtest is already running');\n }\n\n this.isRunning = true;\n this.startTime = Date.now();\n this.emit('started', { strategyId: this.strategy.id, config: this.config });\n\n try {\n // Load data based on configured mode\n if (this.config.mode === 'event') {\n await this.runEventBased();\n } else {\n await this.runVectorized();\n }\n\n const result = this.generateResults();\n this.emit('completed', { strategyId: this.strategy.id, result });\n this.isRunning = false;\n return result;\n } catch (error) {\n this.isRunning = false;\n this.emit('error', { strategyId: this.strategy.id, error });\n throw error;\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.8076923076923 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.82051282051282, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 63:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n private config: BacktestConfig;\n private strategy: BaseStrategy;\n private dataFeed: DataFeed;\n private isRunning: boolean = false;\n private barBuffer: Map = new Map();\n private pendingOrders: Order[] = [];\n private filledOrders: Order[] = [];\n private currentTime: Date;\n private startTime: number = 0; // For performance tracking\n private processedBars: number = 0;\n private marketData: Map = new Map();\n\n // Results tracking\n private initialCapital: number;\n private currentCapital: number;\n private positions = new Map();\n private trades: BacktestResult['trades'] = [];\n private dailyReturns: BacktestResult['dailyReturns'] = [];\n private previousPortfolioValue: number;\n private highWaterMark: number;\n private maxDrawdown: number = 0;\n private drawdownStartTime: Date | null = null;\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.82051282051282 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.83333333333333, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 26:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\n// Strategy interfaces\ninterface TradingStrategy {\n id: string;\n name: string;\n description: string;\n status: 'ACTIVE' | 'INACTIVE' | 'PAUSED' | 'ERROR';\n type: 'MOMENTUM' | 'MEAN_REVERSION' | 'ARBITRAGE' | 'CUSTOM';\n symbols: string[];\n parameters: Record;\n performance: {\n totalTrades: number;\n winRate: number;\n totalReturn: number;\n sharpeRatio: number;\n maxDrawdown: number;\n };\n createdAt: Date;\n updatedAt: Date;\n}\n\ninterface StrategySignal {\n strategyId: string;\n symbol: string;\n action: 'BUY' | 'SELL' | 'HOLD';\n confidence: number;\n price: number;\n quantity: number;\n timestamp: Date;\n metadata: Record;\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.83333333333333 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.84615384615384, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 133:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async runEventBased(): Promise {\n // Load market data for all symbols\n await this.loadMarketData();\n\n // Initialize the strategy\n await this.strategy.start();\n\n // Create a merged timeline of all bars across all symbols, sorted by timestamp\n const timeline = this.createMergedTimeline();\n\n // Process each event in chronological order\n let lastProgressUpdate = Date.now();\n let prevDate = new Date(0);\n \n for (let i = 0; i < timeline.length; i++) {\n const bar = timeline[i];\n this.currentTime = bar.timestamp;\n\n // Process any pending orders\n await this.processOrders(bar);\n\n // Update positions with current prices\n this.updatePositions(bar);\n\n // If we've crossed to a new day, calculate daily return\n if (this.currentTime.toDateString() !== prevDate.toDateString()) {\n this.calculateDailyReturn();\n prevDate = this.currentTime;\n }\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.84615384615384 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.85897435897436, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 162:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async runEventBased(): Promise {\n /*...*/\n // Send the new bar to the strategy\n const orders = await this.strategy.onBar(bar);\n \n // Add any new orders to the pending orders queue\n if (orders && orders.length > 0) {\n this.pendingOrders.push(...orders);\n }\n\n // Update progress periodically\n if (Date.now() - lastProgressUpdate > 1000) { // Update every second\n this.updateProgress(i / timeline.length);\n lastProgressUpdate = Date.now();\n }\n }\n\n // Process any remaining orders\n for (const order of this.pendingOrders) {\n await this.processOrder(order);\n }\n\n // Close any remaining positions at the last known price\n await this.closeAllPositions();\n\n // Clean up strategy\n await this.strategy.stop();\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.85897435897436 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.87179487179488, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 403:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\n data: { id, status: strategy.status, action },\n timestamp: new Date()\n });\n\n return c.json({ success: true, data: strategy });\n } catch (error) {\n console.error('Error changing strategy status:', error);\n return c.json({ success: false, error: 'Failed to change strategy status' }, 500);\n }\n});\n\n// Get strategy signals\napp.get('/api/strategies/:id/signals', async (c) => {\n try {\n const id = c.req.param('id');\n const limit = parseInt(c.req.query('limit') || '50');\n \n const signalKeys = await redis.keys(`signal:${id}:*`);\n const signals: any[] = [];\n \n for (const key of signalKeys.slice(0, limit)) {\n const data = await redis.get(key);\n if (data) {\n signals.push(JSON.parse(data));\n }\n }\n\n return c.json({\n success: true,\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.87179487179488 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.88461538461539, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 420:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Process a new bar with the strategy\n */ private processBar(strategyId: string, symbol: string, bar: BarData): void {\n /*...*/\n symbol: bar.symbol,\n price: bar.close,\n action: signal.action,\n quantity: signal.quantity,\n metadata: signal.metadata,\n timestamp: new Date().toISOString(),\n confidence: signal.confidence || 0.8 // Default confidence if not provided\n };\n \n // Store the signal in Redis (this would be in a production environment)\n try {\n // This would normally be injected as a dependency, but for simplicity:\n const redis = require('ioredis') ? \n new (require('ioredis'))({\n host: process.env.REDIS_HOST || 'localhost',\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.88461538461539 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.8974358974359, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 487:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Execute a trading signal\n */\n private executeSignal(strategyId: string, signal: any): void {\n /*...*/\n quantity: signal.quantity,\n executionTime: new Date().toISOString(),\n status: 'FILLED'\n }\n });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.8974358974359 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.91025641025641, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 577:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\n broadcastToClients({\n type: 'STRATEGY_SIGNAL',\n data: signal,\n timestamp: new Date()\n });\n\n await redis.publish('trading:signals', JSON.stringify(signal));\n }\n } catch (error) {\n console.error(`Error in scheduled task for strategy ${id}:`, error);\n }\n }\n }\n});\n\n// Backtesting API endpoints\napp.post('/api/backtest', async (c) => {\n try {\n const request = await c.req.json() as BacktestRequest;\n console.log('Received backtest request:', request);\n \n const result = await backtestService.runBacktest(request);\n const enhancedResult = PerformanceAnalytics.enhanceResults(result);\n \n // Store backtest result in Redis for persistence\n await redis.setex(\n `backtest:${result.strategyId}`,\n 86400 * 7, // 7 days TTL\n JSON.stringify(enhancedResult)\n );\n \n return c.json({ success: true, data: enhancedResult });\n } catch (error) {\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.91025641025641 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.92307692307692, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts` starting at line 198:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts\n/*...*/\n const ws = executionService['webSocketServer'].clients.values().next().value;\n \n // Find the strategy_signal message\n const signalMessages = ws.send.mock.calls\n .map(call => JSON.parse(call[0]))\n .filter(msg => msg.type === 'strategy_signal');\n \n expect(signalMessages.length).toBeGreaterThan(0);\n expect(signalMessages[0].data.action).toBe('BUY');\n expect(signalMessages[0].data.strategyId).toBe('test-strategy');\n });\n \n it('should handle WebSocket client connections', () => {\n // Arrange\n const mockWs = new WebSocket();\n const mockMessage = JSON.stringify({ type: 'get_active_strategies' });\n \n // Act - Simulate connection and message\n executionService['webSocketServer'].emit('connection', mockWs);\n mockWs.emit('message', mockMessage);\n \n // Assert\n expect(mockWs.send).toHaveBeenCalled();\n \n // Check that the response is a strategy_status_list message\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.92307692307692 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.93589743589743, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 482:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\n const signal: StrategySignal = {\n strategyId: id,\n symbol,\n action: ['BUY', 'SELL', 'HOLD'][Math.floor(Math.random() * 3)] as any,\n confidence: Math.random() * 0.4 + 0.6, // 60-100% confidence\n price: 150 + Math.random() * 50,\n quantity: Math.floor(Math.random() * 100) + 1,\n timestamp: new Date(),\n metadata: {\n indicator1: Math.random(),\n indicator2: Math.random(),\n rsi: Math.random() * 100\n }\n };\n\n // Store signal\n await redis.setex(\n `signal:${id}:${Date.now()}`,\n 3600, // 1 hour TTL\n JSON.stringify(signal)\n );\n\n // Broadcast signal\n broadcastToClients({\n type: 'STRATEGY_SIGNAL',\n data: signal,\n timestamp: new Date()\n });\n\n // Publish to trading system\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.93589743589743 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.94871794871794, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 92:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n constructor(strategy: BaseStrategy, config: BacktestConfig, dataFeed: DataFeed) {\n super();\n this.strategy = strategy;\n this.config = config;\n this.dataFeed = dataFeed;\n this.currentTime = new Date(config.startDate);\n this.initialCapital = config.initialCapital;\n this.currentCapital = config.initialCapital;\n this.previousPortfolioValue = config.initialCapital;\n this.highWaterMark = config.initialCapital;\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.94871794871794 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.96153846153847, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 24:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\nconst backtestService = new BacktestService();\n\n// Strategy interfaces\ninterface TradingStrategy {\n /*...*/\n}\n\ninterface StrategySignal {\n /*...*/\n}\n\n// In-memory strategy registry (in production, this would be persisted)\nconst strategies = new Map();\n\n// Initialize strategy controller\nconst strategyController = new StrategyController();\n\n// Health check endpoint\napp.get('/health', (c) => {\n return c.json({ \n service: 'strategy-orchestrator',\n status: 'healthy',\n timestamp: new Date(),\n version: '1.0.0',\n activeStrategies: Array.from(strategies.values()).filter(s => s.status === 'ACTIVE').length,\n registeredStrategies: strategyRegistry.getAllStrategies().length,\n connections: wss.clients.size\n });\n});\n\n// API Routes\n// Strategy management endpoints\napp.get('/api/strategy-types', async (c) => {\n try {\n const types = Object.values(strategyRegistry.getStrategyTypes());\n return c.json({ success: true, data: types });\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.96153846153847 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.97435897435898, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 0:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\nimport { EventEmitter } from 'events';\nimport { BaseStrategy } from '../Strategy';\nimport { BarData, Order, Position } from '../Strategy';\n\nexport interface BacktestConfig {\n /*...*/\n}\n\nexport interface BacktestResult {\n /*...*/\n}\n\nexport interface BacktestProgress {\n /*...*/\n}\n\nexport interface DataFeed {\n /*...*/\n}\n\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.97435897435898 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.98717948717949, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 552:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\n console.log('Running strategy health check...');\n \n for (const [id, strategy] of strategies.entries()) {\n if (strategy.status === 'ACTIVE') {\n try {\n // Generate signals for active strategies (demo mode)\n if (Math.random() > 0.7) { // 30% chance to generate a signal\n const symbol = strategy.symbols[Math.floor(Math.random() * strategy.symbols.length)] || 'AAPL';\n const signal: StrategySignal = {\n strategyId: id,\n symbol,\n action: ['BUY', 'SELL'][Math.floor(Math.random() * 2)] as any,\n confidence: Math.random() * 0.3 + 0.7,\n price: 150 + Math.random() * 50,\n quantity: Math.floor(Math.random() * 100) + 1,\n timestamp: new Date(),\n metadata: { scheduled: true }\n };\n\n await redis.setex(\n `signal:${id}:${Date.now()}`,\n 3600,\n JSON.stringify(signal)\n );\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.98717948717949 - }, - "references": [] - } - ], - "props": { - "priority": 100 - }, - "references": [ - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 24, - "character": 0 - }, - { - "line": 82, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 403, - "character": 0 - }, - { - "line": 432, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 432, - "character": 0 - }, - { - "line": 458, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 458, - "character": 0 - }, - { - "line": 482, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 482, - "character": 0 - }, - { - "line": 512, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 512, - "character": 0 - }, - { - "line": 552, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 552, - "character": 0 - }, - { - "line": 576, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 577, - "character": 0 - }, - { - "line": 610, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 641, - "character": 0 - }, - { - "line": 666, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - }, - "range": [ - { - "line": 0, - "character": 0 - }, - { - "line": 604, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": [ - { - "line": 12, - "character": 2 - }, - { - "line": 57, - "character": 7 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": [ - { - "line": 62, - "character": 0 - }, - { - "line": 89, - "character": 1 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": [ - { - "line": 115, - "character": 0 - }, - { - "line": 144, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": [ - { - "line": 172, - "character": 0 - }, - { - "line": 198, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": [ - { - "line": 198, - "character": 0 - }, - { - "line": 223, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/execution/StrategyExecutionService.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/execution/StrategyExecutionService.ts", - "scheme": "file" - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 79, - "character": 2 - }, - { - "line": 123, - "character": 3 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 112, - "character": 0 - }, - { - "line": 200, - "character": 12 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 211, - "character": 2 - }, - { - "line": 287, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\ARCHITECTURE.md", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/ARCHITECTURE.md", - "path": "/g:/repos/stock-bot/ARCHITECTURE.md", - "scheme": "file" - }, - "range": [ - { - "line": 166, - "character": 0 - }, - { - "line": 188, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\ARCHITECTURE.md", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/ARCHITECTURE.md", - "path": "/g:/repos/stock-bot/ARCHITECTURE.md", - "scheme": "file" - }, - "range": [ - { - "line": 188, - "character": 0 - }, - { - "line": 199, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\ARCHITECTURE.md", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/ARCHITECTURE.md", - "path": "/g:/repos/stock-bot/ARCHITECTURE.md", - "scheme": "file" - }, - "range": [ - { - "line": 199, - "character": 0 - }, - { - "line": 217, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestService.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestService.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestService.ts", - "scheme": "file" - }, - "range": [ - { - "line": 0, - "character": 0 - }, - { - "line": 186, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\strategies\\MeanReversionStrategy.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/strategies/MeanReversionStrategy.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/strategies/MeanReversionStrategy.test.ts", - "scheme": "file" - }, - "range": [ - { - "line": 76, - "character": 0 - }, - { - "line": 104, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\strategies\\MeanReversionStrategy.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/strategies/MeanReversionStrategy.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/strategies/MeanReversionStrategy.test.ts", - "scheme": "file" - }, - "range": [ - { - "line": 104, - "character": 0 - }, - { - "line": 130, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 57, - "character": 2 - }, - { - "line": 75, - "character": 3 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 140, - "character": 0 - }, - { - "line": 165, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "scheme": "file" - }, - "range": [ - { - "line": 211, - "character": 0 - }, - { - "line": 232, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - } - ] - } - ], - "props": { - "priority": 100 - }, - "references": [] - } - ], - "props": { - "priority": 100 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": { - "priority": 100 - }, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01NTkqxA6Jz66cxy9PmMAxQw__vscode-1748915937082": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "(The file `", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\index.ts", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "` exists, but is empty)", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_01TzJaHzc1nXQryucASEb1MX__vscode-1748915937083": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "(The file `", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "g:\\repos\\stock-bot\\apps\\intelligence-services\\signal-engine\\src\\index.ts", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "` exists, but is empty)", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01BjsFTPJuX7kc7Qyaz5updN__vscode-1748915937084": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "(The file `", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\package.json", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "` exists, but is empty)", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01UyZy6j15TqfPPd3jAbxijv__vscode-1748915937085": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "(The file `", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "g:\\repos\\stock-bot\\apps\\intelligence-services\\signal-engine\\package.json", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "` exists, but is empty)", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01DXPbYzxcHpWgdwwrBTSbpm__vscode-1748915937086": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Lines ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "0", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " to ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "50", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " (", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "25", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " lines total):", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 27, - "text": "```json\n", - "references": [ - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\package.json", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json", - "scheme": "file" - } - } - ], - "lineBreakBefore": true - } - ], - "props": { - "priority": 27 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 26, - "text": "// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\package.json\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 26 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 25, - "text": "{\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 25 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 24, - "text": " \"name\": \"strategy-orchestrator\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 24 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 23, - "text": " \"version\": \"1.0.0\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 23 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 22, - "text": " \"description\": \"Trading strategy lifecycle management service\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 22 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 21, - "text": " \"main\": \"src/index.ts\", \"scripts\": {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 21 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 20, - "text": " \"dev\": \"bun run --watch src/index.ts\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 20 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 19, - "text": " \"start\": \"bun run src/index.ts\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 19 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 18, - "text": " \"test\": \"bun test --timeout 10000 src/tests/**/*.test.ts\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 18 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 17, - "text": " \"test:watch\": \"bun test --watch src/tests/**/*.test.ts\"\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 17 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 16, - "text": " },\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 16 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 15, - "text": " \"dependencies\": {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 15 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 14, - "text": " \"hono\": \"^4.6.3\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 14 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 13, - "text": " \"ioredis\": \"^5.4.1\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 13 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 12, - "text": " \"@stock-bot/config\": \"*\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 12 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 11, - "text": " \"@stock-bot/shared-types\": \"*\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 11 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 10, - "text": " \"ws\": \"^8.18.0\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 10 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9, - "text": " \"node-cron\": \"^3.0.3\"\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 9 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 8, - "text": " },\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 8 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 7, - "text": " \"devDependencies\": {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 7 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 6, - "text": " \"bun-types\": \"^1.2.15\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 6 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 5, - "text": " \"@types/ws\": \"^8.5.12\",\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 4, - "text": " \"@types/node-cron\": \"^3.0.11\"\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 4 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 3, - "text": " }\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 3 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 2, - "text": "}\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 2 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 27, - "text": "```", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 27 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01SsaVY7NiwsVpTu5JjiCnCH__vscode-1748915937087": { - "$mid": 20, - "content": [ - { - "$mid": 21, - "value": "ERROR while calling tool: File already exists. You must use an edit tool to modify it.\nPlease check your input and try again." - } - ] - }, - "toolu_vrtx_01GPTQ7BRcofTkGQGRwbggtm__vscode-1748915937088": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "mm", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "The following files were successfully edited:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\package.json", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_019T58Db2KYmBLHCaAjHR1DA__vscode-1748915937089": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "v6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "index.ts", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01X3WBXTcv2C2teccePnUmSS__vscode-1748915937090": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "R6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\r", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\r", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": " Directory: G:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\srcMode LastWriteTime Length Name\r", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "---- ------------- ------ ----\r", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "d----- 2025-06-02 10:12 PM core", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_013RpwBHAh2Z6KCgDE3fdxdw__vscode-1748915937091": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "R6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": " Directory: G:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\srcMode LastWriteTime Length Name\r", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "---- ------------- ------ ----\r", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "d----- 2025-06-02 10:12 PM controllers", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_011beDq6rY7g6JSgJgWF5oJf__vscode-1748915937092": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "R6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": " Directory: G:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\r", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Mode LastWriteTime Length Name\r", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "---- ------------- ------ ----\r", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "d----- 2025-06-02 10:12 PM tests", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01WoPQEQFeHv9qkb5gJGtRPi__vscode-1748915937093": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "R6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01XZdf64Vnwy1EiUYs7NwVoK__vscode-1748915937094": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Lines ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "0", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " to ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "50", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " (", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "605", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " lines total):", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 54, - "text": "```typescript\n", - "references": [ - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - } - } - ], - "lineBreakBefore": true - } - ], - "props": { - "priority": 54 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 53, - "text": "// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 53 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 52, - "text": "import { EventEmitter } from 'events';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 52 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 51, - "text": "import { BaseStrategy } from '../Strategy';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 51 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 50, - "text": "import { BarData, Order, Position } from '../Strategy';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 50 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 49, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 49 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 48, - "text": "export interface BacktestConfig {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 48 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 47, - "text": " startDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 47 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 46, - "text": " endDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 46 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 45, - "text": " symbols: string[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 45 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 44, - "text": " initialCapital: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 44 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 43, - "text": " commission: number; // Per trade commission (percentage)\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 43 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 42, - "text": " slippage: number; // Slippage model (percentage)\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 42 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 41, - "text": " dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 41 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 40, - "text": " mode: 'event' | 'vector';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 40 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 39, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 39 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 38, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 38 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 37, - "text": "export interface BacktestResult {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 37 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 36, - "text": " strategyId: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 36 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 35, - "text": " startDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 35 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 34, - "text": " endDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 34 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 33, - "text": " duration: number; // In milliseconds\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 33 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 32, - "text": " initialCapital: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 32 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 31, - "text": " finalCapital: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 31 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 30, - "text": " totalReturn: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 30 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 29, - "text": " annualizedReturn: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 29 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 28, - "text": " sharpeRatio: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 28 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 27, - "text": " maxDrawdown: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 27 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 26, - "text": " maxDrawdownDuration: number; // In days\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 26 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 25, - "text": " winRate: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 25 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 24, - "text": " totalTrades: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 24 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 23, - "text": " winningTrades: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 23 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 22, - "text": " losingTrades: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 22 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 21, - "text": " averageWinningTrade: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 21 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 20, - "text": " averageLosingTrade: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 20 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 19, - "text": " profitFactor: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 19 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 18, - "text": " dailyReturns: Array<{ date: Date; return: number }>;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 18 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 17, - "text": " trades: Array<{\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 17 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 16, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 16 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 15, - "text": " entryTime: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 15 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 14, - "text": " entryPrice: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 14 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 13, - "text": " exitTime: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 13 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 12, - "text": " exitPrice: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 12 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 11, - "text": " quantity: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 11 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 10, - "text": " pnl: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 10 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9, - "text": " pnlPercent: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 9 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 8, - "text": " }>;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 8 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 7, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 7 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 6, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 6 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 5, - "text": "export interface BacktestProgress {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 4, - "text": " progress: number; // 0-100\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 4 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 3, - "text": " currentDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 3 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 2, - "text": " processingSpeed: number; // Bars per second\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 2 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 54, - "text": "```", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 54 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - } - }, - "modelMessageId": "85d8657b-7be6-49f5-bd2d-1740ca3c32ee", - "responseId": "c1a27237-a9ff-4f6d-9998-4f27b6cdc2a8", - "sessionId": "b8852c97-aefb-4e3a-a2e5-4755c925c5cc", - "agentId": "github.copilot.editsAgent" - } - }, - "followups": [], - "isCanceled": false, - "agent": { - "extensionId": { - "value": "GitHub.copilot-chat", - "_lower": "github.copilot-chat" - }, - "publisherDisplayName": "GitHub", - "extensionPublisherId": "GitHub", - "extensionDisplayName": "GitHub Copilot Chat", - "id": "github.copilot.editsAgent", - "description": "Edit files in your workspace in agent mode", - "when": "config.chat.agent.enabled && !chatAgentModeDisallowed", - "metadata": { - "themeIcon": { - "id": "tools" - }, - "hasFollowups": false, - "supportIssueReporting": false - }, - "name": "agent", - "fullName": "GitHub Copilot", - "isDefault": true, - "locations": [ - "panel" - ], - "modes": [ - "agent" - ], - "slashCommands": [], - "disambiguation": [] - }, - "contentReferences": [ - { - "kind": "reference", - "reference": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "scheme": "file" - } - } - ], - "codeCitations": [], - "timestamp": 1748916708523 - }, - { - "requestId": "request_2d112c3f-2572-4278-9a10-881ffe7eff44", - "message": { - "parts": [ - { - "range": { - "start": 0, - "endExclusive": 39 - }, - "editorRange": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 1, - "endColumn": 40 - }, - "text": "@agent Continue: \"Continue to iterate?\"", - "kind": "text" - } - ], - "text": "@agent Continue: \"Continue to iterate?\"" - }, - "variableData": { - "variables": [] - }, - "response": [ - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts), lines 1 to 605", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts), lines 1 to 605", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "64fbeb7b-06d0-45ec-b391-2d862f465b71", - "toolId": "copilot_readFile" - }, - { - "value": "I'll continue with the refactoring by creating the separated backtest engine service. Let me create the necessary files: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Creating [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Created [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "ed009286-8810-42b8-b428-684028d35103", - "toolId": "copilot_createFile" - }, - { - "kind": "toolInvocationSerialized", - "presentation": "hidden", - "invocationMessage": "Using \"Replace String in File\"", - "isConfirmed": true, - "isComplete": true, - "toolCallId": "b6176c2b-88e8-4ae5-a771-4a68d7d3b975", - "toolId": "copilot_replaceString" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts), lines 1 to 11", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts), lines 1 to 11", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "4ec46fd9-e39c-4d01-9868-2bd6c9167e6b", - "toolId": "copilot_readFile" - }, - { - "value": "I can see the file already has content. Let me update it to use the shared types properly: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "presentation": "hidden", - "invocationMessage": "Using \"Replace String in File\"", - "isConfirmed": true, - "isComplete": true, - "toolCallId": "f4df7382-15bb-4987-bb31-7951505fa95d", - "toolId": "copilot_replaceString" - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "kind": "codeblockUri", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "isEdit": true - }, - { - "kind": "textEditGroup", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "edits": [ - [ - { - "text": "import { EventEmitter } from 'events';\nimport { BarData, Order, Position } from '@stock-bot/shared-types';", - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 3, - "endColumn": 56 - } - } - ], - [] - ], - "done": true - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "value": "I need to check what types are available in the shared types and create the necessary interfaces. Let me check the shared types first: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts), lines 1 to 51", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/packages/shared-types/src/index.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts), lines 1 to 51", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/packages/shared-types/src/index.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "aa464b99-378a-46b5-b70e-eed217462338", - "toolId": "copilot_readFile" - }, - { - "value": "Now I can see the types. Let me update the BacktestEngine file to use the correct shared types and add missing properties: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "presentation": "hidden", - "invocationMessage": "Using \"Replace String in File\"", - "isConfirmed": true, - "isComplete": true, - "toolCallId": "d6dac46a-6948-4f98-ad72-e1f6eca26245", - "toolId": "copilot_replaceString" - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "kind": "codeblockUri", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "isEdit": true - }, - { - "kind": "textEditGroup", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "edits": [ - [ - { - "text": "import { EventEmitter } from 'events';\nimport { OHLCV, Order, Position } from '@stock-bot/shared-types';\n\n// Define additional types needed for backtesting\nexport interface BarData extends OHLCV {}\n\nexport interface BacktestPosition extends Position {\n entryTime: Date;\n side: 'LONG' | 'SHORT';\n avgPrice: number; // Alias for averagePrice for backward compatibility\n}\n\nexport interface StrategyInterface {\n id: string;\n start(): Promise;\n stop(): Promise;\n onBar(bar: BarData): Promise;\n onOrderFilled(order: Order): Promise;\n}", - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 2, - "endColumn": 68 - } - } - ], - [] - ], - "done": true - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "content": { - "value": "Summarized conversation history", - "isTrusted": false, - "supportThemeIcons": false, - "supportHtml": false - }, - "kind": "progressTask", - "deferred": { - "p": {}, - "d": { - "outcome": 0, - "value": "Summarized conversation history" - } - }, - "a": { - "z": 0, - "g": { - "threshold": 175, - "name": "1a76b", - "h": 0 - } - }, - "progress": [] - }, - { - "value": "I'll continue with the refactoring by fixing the TypeScript compilation errors in the ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "inlineReference", - "inlineReference": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - }, - { - "value": " file and completing the service separation. Let me start by examining the current errors and fixing them. ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Checking [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Checked [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts), 15 problems found", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "b8d0ce6f-0aec-403a-bc7d-33cb3247eca1", - "toolId": "copilot_getErrors" - }, - { - "value": "Now let me check the shared types to understand the available interfaces and fix these issues: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts), lines 1 to 101", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/packages/shared-types/src/index.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts), lines 1 to 101", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/packages/shared-types/src/index.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "687295f8-5400-4fb3-a1d9-ff962d90cfe7", - "toolId": "copilot_readFile" - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts), lines 101 to 205", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/packages/shared-types/src/index.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts), lines 101 to 205", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/packages/shared-types/src/index.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "2883ab59-ada6-42dd-8b6f-f2f804e40dbd", - "toolId": "copilot_readFile" - }, - { - "value": "Now let me check if there's a BaseStrategy or similar interface in the existing strategy-orchestrator: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Searching codebase for \"BaseStrategy class interface abstract strategy execution\"", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - "pastTenseMessage": { - "value": "Searched codebase for \"BaseStrategy class interface abstract strategy execution\", 21 results", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - "isConfirmed": true, - "isComplete": true, - "resultDetails": [ - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 179, - "startColumn": 1, - "endLineNumber": 204, - "endColumn": 1 - } - }, - { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestService.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestService.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestService.ts", - "scheme": "file" - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 13, - "startColumn": 1, - "endLineNumber": 265, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 605, - "endColumn": 1 - } - }, - { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/execution/StrategyExecutionService.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/execution/StrategyExecutionService.ts", - "scheme": "file" - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\MeanReversionStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/MeanReversionStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/MeanReversionStrategy.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 134, - "startColumn": 3, - "endLineNumber": 137, - "endColumn": 4 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/StrategyRegistry.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/StrategyRegistry.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 198, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 84, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 89, - "startColumn": 1, - "endLineNumber": 117, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 201, - "endColumn": 13 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 212, - "startColumn": 3, - "endLineNumber": 288, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 25, - "startColumn": 1, - "endLineNumber": 83, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 63, - "startColumn": 1, - "endLineNumber": 90, - "endColumn": 2 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 77, - "startColumn": 3, - "endLineNumber": 86, - "endColumn": 4 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 123, - "startColumn": 3, - "endLineNumber": 148, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 186, - "startColumn": 3, - "endLineNumber": 195, - "endColumn": 1 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 273, - "startColumn": 3, - "endLineNumber": 289, - "endColumn": 4 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 309, - "startColumn": 3, - "endLineNumber": 325, - "endColumn": 4 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 5, - "startColumn": 1, - "endLineNumber": 35, - "endColumn": 2 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 86, - "startColumn": 1, - "endLineNumber": 122, - "endColumn": 4 - } - }, - { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\ARCHITECTURE.md", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/ARCHITECTURE.md", - "path": "/g:/repos/stock-bot/ARCHITECTURE.md", - "scheme": "file" - }, - "range": { - "startLineNumber": 167, - "startColumn": 1, - "endLineNumber": 218, - "endColumn": 1 - } - } - ], - "toolCallId": "3f978017-1a41-4161-871c-bf57a8515381", - "toolId": "copilot_searchCodebase" - }, - { - "value": "Now let me check the ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "inlineReference", - "inlineReference": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - } - }, - { - "value": " file to understand the existing BaseStrategy interface and types: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts), lines 1 to 101", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts), lines 1 to 101", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "af9d0d33-8003-48d2-a7f9-c9c3f6f83a60", - "toolId": "copilot_readFile" - }, - { - "value": "Now I understand the existing structure. Let me fix the ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "inlineReference", - "inlineReference": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - }, - { - "value": " file by addressing all the compilation errors: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "presentation": "hidden", - "invocationMessage": "Using \"Replace String in File\"", - "isConfirmed": true, - "isComplete": true, - "toolCallId": "0e7b24f2-bd7d-46e6-9c81-1a17234b1605", - "toolId": "copilot_replaceString" - }, - { - "value": "Let me read the current file to see the exact content: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Reading [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts), lines 1 to 51", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Read [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts), lines 1 to 51", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "132c7e3c-98bc-4658-8bdc-d2424f337af4", - "toolId": "copilot_readFile" - }, - { - "value": "Let me completely rewrite the ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "inlineReference", - "inlineReference": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - }, - { - "value": " file with the correct fixes: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Creating [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Created [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "b80c9613-5a41-4f36-9bfb-2f93261a5dc2", - "toolId": "copilot_createFile" - }, - { - "kind": "toolInvocationSerialized", - "presentation": "hidden", - "invocationMessage": "Using \"Replace String in File\"", - "isConfirmed": true, - "isComplete": true, - "toolCallId": "e3fb3745-6017-4363-98d8-65ec096b7124", - "toolId": "copilot_replaceString" - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "kind": "codeblockUri", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "isEdit": true - }, - { - "kind": "textEditGroup", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "edits": [ - [ - { - "text": "import { EventEmitter } from 'events';\nimport { OHLCV, Order, Position } from '@stock-bot/shared-types';\n\n// Use OHLCV from shared-types as BarData equivalent\nexport type BarData = OHLCV;\n\n// Strategy interface to match existing pattern\nexport interface StrategyInterface {\n id: string;\n onBar(bar: BarData): Promise | Order[];\n stop(): Promise;\n}\n\nexport interface BacktestConfig {\n initialCapital: number;\n startDate: Date;\n endDate: Date;\n commission: number;\n slippage: number;\n}\n\nexport interface BacktestResult {\n startDate: Date;\n endDate: Date;\n initialCapital: number;\n finalCapital: number;\n totalReturn: number;\n totalTrades: number;\n winningTrades: number;\n losingTrades: number;\n winRate: number;\n avgWin: number;\n avgLoss: number;\n profitFactor: number;\n sharpeRatio: number;\n maxDrawdown: number;\n trades: Array<{\n id: string;\n symbol: string;\n side: 'BUY' | 'SELL';\n quantity: number;\n entryTime: Date;\n exitTime: Date;\n entryPrice: number;\n exitPrice: number;\n pnl: number;\n pnlPercent: number;\n }>;\n dailyReturns: Array<{\n date: Date;\n portfolioValue: number;\n dayReturn: number;\n }>;\n}\n\nexport interface BacktestProgress {\n currentDate: Date;\n progress: number; // 0-100\n portfolioValue: number;\n totalTrades: number;\n}\n\nexport interface DataFeed {\n getHistoricalData(symbol: string, startDate: Date, endDate: Date): Promise;\n}\n\n// Extended Position interface that includes additional fields needed for backtesting\nexport interface BacktestPosition {\n symbol: string;\n quantity: number;\n averagePrice: number;\n marketValue: number;\n unrealizedPnL: number;\n timestamp: Date;\n // Additional fields for backtesting\n avgPrice: number; // Alias for averagePrice\n entryTime: Date;\n}\n\n// Extended Order interface that includes additional fields needed for backtesting\nexport interface BacktestOrder extends Order {\n fillPrice?: number;\n fillTime?: Date;\n}", - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 51, - "endColumn": 55 - } - } - ], - [] - ], - "done": true - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "value": "I need to continue the replacement properly. Let me replace the entire file content section by section: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "presentation": "hidden", - "invocationMessage": "Using \"Replace String in File\"", - "isConfirmed": true, - "isComplete": true, - "toolCallId": "75f9274a-bc1b-4c34-9120-18d5f624fb1d", - "toolId": "copilot_replaceString" - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "kind": "codeblockUri", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "isEdit": true - }, - { - "kind": "textEditGroup", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "edits": [ - [ - { - "text": "export class BacktestEngine extends EventEmitter {\n private config: BacktestConfig;\n private strategy: StrategyInterface;\n private dataFeed: DataFeed;\n private isRunning: boolean = false;\n private barBuffer: Map = new Map();\n private pendingOrders: BacktestOrder[] = [];\n private filledOrders: BacktestOrder[] = [];\n private currentTime: Date;\n private startTime: number = 0; // For performance tracking\n private processedBars: number = 0;\n private marketData: Map = new Map();\n\n // Results tracking\n private initialCapital: number;\n private currentCapital: number;\n private positions = new Map();\n private trades: BacktestResult['trades'] = [];\n private dailyReturns: BacktestResult['dailyReturns'] = [];\n private previousPortfolioValue: number;\n private highWaterMark: number;\n private maxDrawdown: number = 0;\n private drawdownStartTime: Date | null = null;", - "range": { - "startLineNumber": 112, - "startColumn": 1, - "endLineNumber": 134, - "endColumn": 49 - } - } - ], - [] - ], - "done": true - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "value": "Now let me continue fixing the rest of the file: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "presentation": "hidden", - "invocationMessage": "Using \"Replace String in File\"", - "isConfirmed": true, - "isComplete": true, - "toolCallId": "39aa6961-fda4-446e-8984-04886bad6dd8", - "toolId": "copilot_replaceString" - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "kind": "codeblockUri", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "isEdit": true - }, - { - "kind": "textEditGroup", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "edits": [ - [ - { - "text": " constructor(strategy: StrategyInterface, config: BacktestConfig, dataFeed: DataFeed) {\n super();\n this.strategy = strategy;\n this.config = config;\n this.dataFeed = dataFeed;\n this.currentTime = new Date(config.startDate);\n this.initialCapital = config.initialCapital;\n this.currentCapital = config.initialCapital;\n this.previousPortfolioValue = config.initialCapital;\n this.highWaterMark = config.initialCapital;\n }", - "range": { - "startLineNumber": 141, - "startColumn": 1, - "endLineNumber": 152, - "endColumn": 4 - } - } - ], - [] - ], - "done": true - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "value": "I need to update the tsconfig.json to support iterating over Map entries, and also finish fixing the remaining issues. Let me create a proper tsconfig.json file first: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "invocationMessage": { - "value": "Creating [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/tsconfig.json)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/tsconfig.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/tsconfig.json", - "scheme": "file" - } - } - }, - "pastTenseMessage": { - "value": "Created [](file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/tsconfig.json)", - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/tsconfig.json": { - "$mid": 1, - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/tsconfig.json", - "scheme": "file" - } - } - }, - "isConfirmed": true, - "isComplete": true, - "toolCallId": "2cefefc9-74f0-4edb-aa09-51df5b0ade07", - "toolId": "copilot_createFile" - }, - { - "value": "Let me check the existing tsconfig.json and then continue fixing the ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "inlineReference", - "inlineReference": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - }, - { - "value": " file by addressing the remaining issues: ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "toolInvocationSerialized", - "presentation": "hidden", - "invocationMessage": "Using \"Replace String in File\"", - "isConfirmed": true, - "isComplete": true, - "toolCallId": "79cdbe71-18ae-4b75-83a1-b9a1fc41db6e", - "toolId": "copilot_replaceString" - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - }, - { - "kind": "codeblockUri", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "isEdit": true - }, - { - "kind": "textEditGroup", - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "edits": [ - [ - { - "text": " async run(): Promise {\n if (this.isRunning) {\n throw new Error('Backtest is already running');\n }\n\n this.isRunning = true;\n this.startTime = Date.now();\n this.emit('started', { strategyId: this.strategy.id, config: this.config });\n\n try {\n await this.runEventBased();\n const result = this.generateResults();\n this.emit('completed', { strategyId: this.strategy.id, result });\n this.isRunning = false;\n return result;\n } catch (error) {\n this.isRunning = false;\n this.emit('error', { strategyId: this.strategy.id, error });\n throw error;\n }\n }", - "range": { - "startLineNumber": 152, - "startColumn": 1, - "endLineNumber": 179, - "endColumn": 4 - } - } - ], - [] - ], - "done": true - }, - { - "value": "\n```\n", - "supportThemeIcons": false, - "supportHtml": false, - "uris": {} - } - ], - "responseId": "response_3c6adf87-985b-45bc-ac6a-802def81257b", - "result": { - "errorDetails": { - "message": "Sorry, you have exhausted the agent mode usage limit. Please switch to ask mode and try again later.", - "level": 0, - "responseIsIncomplete": true - }, - "timings": { - "firstProgress": 2914, - "totalElapsed": 251254 - }, - "metadata": { - "toolCallRounds": [ - { - "response": "I'll continue with the refactoring by creating the separated backtest engine service. Let me create the necessary files: ", - "toolCalls": [ - { - "name": "create_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"content\": \"import { EventEmitter } from 'events';\\nimport { BarData, Order, Position } from '@stock-bot/shared-types';\\n\\nexport interface BacktestConfig {\\n startDate: Date;\\n endDate: Date;\\n symbols: string[];\\n initialCapital: number;\\n commission: number; // Per trade commission (percentage)\\n slippage: number; // Slippage model (percentage)\\n dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\\n mode: 'event' | 'vector';\\n}\\n\\nexport interface BacktestResult {\\n strategyId: string;\\n startDate: Date;\\n endDate: Date;\\n duration: number; // In milliseconds\\n initialCapital: number;\\n finalCapital: number;\\n totalReturn: number;\\n annualizedReturn: number;\\n sharpeRatio: number;\\n maxDrawdown: number;\\n maxDrawdownDuration: number; // In days\\n winRate: number;\\n totalTrades: number;\\n winningTrades: number;\\n losingTrades: number;\\n averageWinningTrade: number;\\n averageLosingTrade: number;\\n profitFactor: number;\\n dailyReturns: Array<{ date: Date; return: number }>;\\n trades: Array<{\\n symbol: string;\\n entryTime: Date;\\n entryPrice: number;\\n exitTime: Date;\\n exitPrice: number;\\n quantity: number;\\n pnl: number;\\n pnlPercent: number;\\n }>;\\n}\\n\\nexport interface BacktestProgress {\\n progress: number; // 0-100\\n currentDate: Date;\\n processingSpeed: number; // Bars per second\\n estimatedTimeRemaining: number; // milliseconds\\n currentCapital: number;\\n currentReturn: number;\\n currentDrawdown: number;\\n}\\n\\nexport interface DataFeed {\\n getHistoricalData(symbol: string, resolution: string, start: Date, end: Date): Promise;\\n hasDataFor(symbol: string, resolution: string, start: Date, end: Date): Promise;\\n}\\n\\nexport interface StrategyInterface {\\n id: string;\\n start(): Promise;\\n stop(): Promise;\\n onBar(bar: BarData): Promise;\\n onOrderFilled(order: Order): Promise;\\n}\\n\\nexport class BacktestEngine extends EventEmitter {\\n private config: BacktestConfig;\\n private strategy: StrategyInterface;\\n private dataFeed: DataFeed;\\n private isRunning: boolean = false;\\n private barBuffer: Map = new Map();\\n private pendingOrders: Order[] = [];\\n private filledOrders: Order[] = [];\\n private currentTime: Date;\\n private startTime: number = 0;\\n private processedBars: number = 0;\\n private marketData: Map = new Map();\\n\\n // Results tracking\\n private initialCapital: number;\\n private currentCapital: number;\\n private positions = new Map();\\n private trades: BacktestResult['trades'] = [];\\n private dailyReturns: BacktestResult['dailyReturns'] = [];\\n private previousPortfolioValue: number;\\n private highWaterMark: number;\\n private maxDrawdown: number = 0;\\n private drawdownStartTime: Date | null = null;\\n private maxDrawdownDuration: number = 0;\\n private winningTrades: number = 0;\\n private losingTrades: number = 0;\\n private breakEvenTrades: number = 0;\\n private totalProfits: number = 0;\\n private totalLosses: number = 0;\\n\\n constructor(strategy: StrategyInterface, config: BacktestConfig, dataFeed: DataFeed) {\\n super();\\n this.strategy = strategy;\\n this.config = config;\\n this.dataFeed = dataFeed;\\n this.currentTime = new Date(config.startDate);\\n this.initialCapital = config.initialCapital;\\n this.currentCapital = config.initialCapital;\\n this.previousPortfolioValue = config.initialCapital;\\n this.highWaterMark = config.initialCapital;\\n }\\n\\n async run(): Promise {\\n if (this.isRunning) {\\n throw new Error('Backtest is already running');\\n }\\n\\n this.isRunning = true;\\n this.startTime = Date.now();\\n this.emit('started', { strategyId: this.strategy.id, config: this.config });\\n\\n try {\\n if (this.config.mode === 'event') {\\n await this.runEventBased();\\n } else {\\n await this.runVectorized();\\n }\\n\\n const result = this.generateResults();\\n this.emit('completed', { strategyId: this.strategy.id, result });\\n this.isRunning = false;\\n return result;\\n } catch (error) {\\n this.isRunning = false;\\n this.emit('error', { strategyId: this.strategy.id, error });\\n throw error;\\n }\\n }\\n\\n private async runEventBased(): Promise {\\n await this.loadMarketData();\\n await this.strategy.start();\\n\\n const timeline = this.createMergedTimeline();\\n let lastProgressUpdate = Date.now();\\n let prevDate = new Date(0);\\n \\n for (let i = 0; i < timeline.length; i++) {\\n const bar = timeline[i];\\n this.currentTime = bar.timestamp;\\n\\n await this.processOrders(bar);\\n this.updatePositions(bar);\\n\\n if (this.currentTime.toDateString() !== prevDate.toDateString()) {\\n this.calculateDailyReturn();\\n prevDate = this.currentTime;\\n }\\n\\n const orders = await this.strategy.onBar(bar);\\n \\n if (orders && orders.length > 0) {\\n this.pendingOrders.push(...orders);\\n }\\n\\n if (Date.now() - lastProgressUpdate > 1000) {\\n this.updateProgress(i / timeline.length);\\n lastProgressUpdate = Date.now();\\n }\\n }\\n\\n for (const order of this.pendingOrders) {\\n await this.processOrder(order);\\n }\\n\\n await this.closeAllPositions();\\n await this.strategy.stop();\\n }\\n\\n private async runVectorized(): Promise {\\n await this.loadMarketData();\\n \\n const timeline = this.createMergedTimeline();\\n \\n const allBars = new Map();\\n for (const symbol of this.config.symbols) {\\n allBars.set(symbol, this.marketData.get(symbol) || []);\\n }\\n \\n this.emit('completed', { message: 'Vectorized backtest completed in fast mode' });\\n }\\n\\n private async loadMarketData(): Promise {\\n for (const symbol of this.config.symbols) {\\n this.emit('loading', { symbol, resolution: this.config.dataResolution });\\n \\n const hasData = await this.dataFeed.hasDataFor(\\n symbol,\\n this.config.dataResolution,\\n this.config.startDate,\\n this.config.endDate\\n );\\n \\n if (!hasData) {\\n throw new Error(`No data available for ${symbol} at resolution ${this.config.dataResolution}`);\\n }\\n \\n const data = await this.dataFeed.getHistoricalData(\\n symbol,\\n this.config.dataResolution,\\n this.config.startDate,\\n this.config.endDate\\n );\\n \\n this.marketData.set(symbol, data);\\n this.emit('loaded', { symbol, count: data.length });\\n }\\n }\\n\\n private createMergedTimeline(): BarData[] {\\n const allBars: BarData[] = [];\\n \\n for (const [symbol, bars] of this.marketData.entries()) {\\n allBars.push(...bars);\\n }\\n \\n return allBars.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());\\n }\\n\\n private async processOrders(currentBar: BarData): Promise {\\n const ordersToProcess = this.pendingOrders.filter(order => order.symbol === currentBar.symbol);\\n \\n if (ordersToProcess.length === 0) return;\\n \\n this.pendingOrders = this.pendingOrders.filter(order => order.symbol !== currentBar.symbol);\\n \\n for (const order of ordersToProcess) {\\n await this.processOrder(order);\\n }\\n }\\n\\n private async processOrder(order: Order): Promise {\\n const latestBars = this.marketData.get(order.symbol);\\n if (!latestBars || latestBars.length === 0) {\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'No market data available' });\\n return;\\n }\\n \\n const bar = latestBars.find(b => \\n b.timestamp.getTime() >= order.timestamp.getTime()\\n ) || latestBars[latestBars.length - 1];\\n \\n let fillPrice: number;\\n if (order.type === 'MARKET') {\\n const slippageFactor = 1 + (order.side === 'BUY' ? this.config.slippage : -this.config.slippage);\\n fillPrice = bar.close * slippageFactor;\\n } else if (order.type === 'LIMIT' && order.price !== undefined) {\\n if ((order.side === 'BUY' && bar.low <= order.price) ||\\n (order.side === 'SELL' && bar.high >= order.price)) {\\n fillPrice = order.price;\\n } else {\\n return;\\n }\\n } else {\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'Order type not supported' });\\n return;\\n }\\n \\n const orderValue = order.quantity * fillPrice;\\n const commission = orderValue * this.config.commission;\\n \\n if (order.side === 'BUY') {\\n const totalCost = orderValue + commission;\\n if (totalCost > this.currentCapital) {\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'Insufficient funds' });\\n return;\\n }\\n \\n this.currentCapital -= totalCost;\\n \\n const existingPosition = this.positions.get(order.symbol);\\n if (existingPosition) {\\n const totalShares = existingPosition.quantity + order.quantity;\\n const totalCost = (existingPosition.quantity * existingPosition.avgPrice) + (order.quantity * fillPrice);\\n existingPosition.avgPrice = totalCost / totalShares;\\n existingPosition.quantity = totalShares;\\n } else {\\n this.positions.set(order.symbol, {\\n symbol: order.symbol,\\n quantity: order.quantity,\\n avgPrice: fillPrice,\\n side: 'LONG',\\n entryTime: this.currentTime\\n });\\n }\\n } else if (order.side === 'SELL') {\\n const position = this.positions.get(order.symbol);\\n \\n if (!position || position.quantity < order.quantity) {\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'Insufficient position' });\\n return;\\n }\\n \\n const pnl = (fillPrice - position.avgPrice) * order.quantity;\\n \\n this.currentCapital += orderValue - commission;\\n \\n position.quantity -= order.quantity;\\n \\n if (position.quantity === 0) {\\n this.positions.delete(order.symbol);\\n \\n this.trades.push({\\n symbol: order.symbol,\\n entryTime: position.entryTime,\\n entryPrice: position.avgPrice,\\n exitTime: this.currentTime,\\n exitPrice: fillPrice,\\n quantity: order.quantity,\\n pnl: pnl,\\n pnlPercent: (pnl / (position.avgPrice * order.quantity)) * 100\\n });\\n \\n if (pnl > 0) {\\n this.winningTrades++;\\n this.totalProfits += pnl;\\n } else if (pnl < 0) {\\n this.losingTrades++;\\n this.totalLosses -= pnl;\\n } else {\\n this.breakEvenTrades++;\\n }\\n }\\n }\\n \\n order.status = 'FILLED';\\n order.fillPrice = fillPrice;\\n order.fillTime = this.currentTime;\\n this.filledOrders.push(order);\\n \\n await this.strategy.onOrderFilled(order);\\n \\n this.emit('orderFilled', { order });\\n }\\n\\n private updatePositions(currentBar: BarData): void {\\n const position = this.positions.get(currentBar.symbol);\\n if (position) {\\n const currentPrice = currentBar.close;\\n const unrealizedPnL = (currentPrice - position.avgPrice) * position.quantity;\\n position.unrealizedPnL = unrealizedPnL;\\n }\\n \\n const portfolioValue = this.calculatePortfolioValue();\\n \\n if (portfolioValue > this.highWaterMark) {\\n this.highWaterMark = portfolioValue;\\n this.drawdownStartTime = null;\\n }\\n \\n if (this.drawdownStartTime === null && portfolioValue < this.highWaterMark) {\\n this.drawdownStartTime = this.currentTime;\\n }\\n \\n if (this.highWaterMark > 0) {\\n const currentDrawdown = (this.highWaterMark - portfolioValue) / this.highWaterMark;\\n if (currentDrawdown > this.maxDrawdown) {\\n this.maxDrawdown = currentDrawdown;\\n \\n if (this.drawdownStartTime !== null) {\\n const drawdownDuration = (this.currentTime.getTime() - this.drawdownStartTime.getTime()) / (1000 * 60 * 60 * 24);\\n if (drawdownDuration > this.maxDrawdownDuration) {\\n this.maxDrawdownDuration = drawdownDuration;\\n }\\n }\\n }\\n }\\n \\n this.previousPortfolioValue = portfolioValue;\\n }\\n\\n private calculatePortfolioValue(): number {\\n let totalValue = this.currentCapital;\\n \\n for (const [symbol, position] of this.positions.entries()) {\\n const bars = this.marketData.get(symbol);\\n if (bars && bars.length > 0) {\\n const latestBar = bars[bars.length - 1];\\n totalValue += position.quantity * latestBar.close;\\n } else {\\n totalValue += position.quantity * position.avgPrice;\\n }\\n }\\n \\n return totalValue;\\n }\\n\\n private calculateDailyReturn(): void {\\n const portfolioValue = this.calculatePortfolioValue();\\n const dailyReturn = (portfolioValue - this.previousPortfolioValue) / this.previousPortfolioValue;\\n \\n this.dailyReturns.push({\\n date: new Date(this.currentTime),\\n return: dailyReturn\\n });\\n \\n this.previousPortfolioValue = portfolioValue;\\n }\\n\\n private async closeAllPositions(): Promise {\\n for (const [symbol, position] of this.positions.entries()) {\\n const bars = this.marketData.get(symbol);\\n if (!bars || bars.length === 0) continue;\\n \\n const lastBar = bars[bars.length - 1];\\n const closePrice = lastBar.close;\\n \\n const pnl = (closePrice - position.avgPrice) * position.quantity;\\n \\n this.currentCapital += position.quantity * closePrice;\\n \\n this.trades.push({\\n symbol,\\n entryTime: position.entryTime,\\n entryPrice: position.avgPrice,\\n exitTime: this.currentTime,\\n exitPrice: closePrice,\\n quantity: position.quantity,\\n pnl,\\n pnlPercent: (pnl / (position.avgPrice * position.quantity)) * 100\\n });\\n \\n if (pnl > 0) {\\n this.winningTrades++;\\n this.totalProfits += pnl;\\n } else if (pnl < 0) {\\n this.losingTrades++;\\n this.totalLosses -= pnl;\\n } else {\\n this.breakEvenTrades++;\\n }\\n }\\n \\n this.positions.clear();\\n }\\n\\n private updateProgress(progress: number): void {\\n const currentPortfolioValue = this.calculatePortfolioValue();\\n const currentDrawdown = this.highWaterMark > 0 \\n ? (this.highWaterMark - currentPortfolioValue) / this.highWaterMark\\n : 0;\\n \\n const elapsedMs = Date.now() - this.startTime;\\n const totalEstimatedMs = elapsedMs / progress;\\n const remainingMs = totalEstimatedMs - elapsedMs;\\n \\n this.emit('progress', {\\n progress: progress * 100,\\n currentDate: this.currentTime,\\n processingSpeed: this.processedBars / (elapsedMs / 1000),\\n estimatedTimeRemaining: remainingMs,\\n currentCapital: this.currentCapital,\\n currentReturn: (currentPortfolioValue - this.initialCapital) / this.initialCapital,\\n currentDrawdown\\n } as BacktestProgress);\\n }\\n\\n private generateResults(): BacktestResult {\\n const currentPortfolioValue = this.calculatePortfolioValue();\\n const totalReturn = (currentPortfolioValue - this.initialCapital) / this.initialCapital;\\n \\n const days = (this.config.endDate.getTime() - this.config.startDate.getTime()) / (1000 * 60 * 60 * 24);\\n const annualizedReturn = Math.pow(1 + totalReturn, 365 / days) - 1;\\n \\n let sharpeRatio = 0;\\n if (this.dailyReturns.length > 1) {\\n const dailyReturnValues = this.dailyReturns.map(dr => dr.return);\\n const avgDailyReturn = dailyReturnValues.reduce((sum, ret) => sum + ret, 0) / dailyReturnValues.length;\\n const stdDev = Math.sqrt(\\n dailyReturnValues.reduce((sum, ret) => sum + Math.pow(ret - avgDailyReturn, 2), 0) / dailyReturnValues.length\\n );\\n \\n sharpeRatio = stdDev > 0 \\n ? (avgDailyReturn * 252) / (stdDev * Math.sqrt(252)) \\n : 0;\\n }\\n \\n const totalTrades = this.winningTrades + this.losingTrades + this.breakEvenTrades;\\n const winRate = totalTrades > 0 ? this.winningTrades / totalTrades : 0;\\n const profitFactor = this.totalLosses > 0 ? this.totalProfits / this.totalLosses : (this.totalProfits > 0 ? Infinity : 0);\\n \\n const avgWinningTrade = this.winningTrades > 0 ? this.totalProfits / this.winningTrades : 0;\\n const avgLosingTrade = this.losingTrades > 0 ? this.totalLosses / this.losingTrades : 0;\\n \\n return {\\n strategyId: this.strategy.id,\\n startDate: this.config.startDate,\\n endDate: this.config.endDate,\\n duration: Date.now() - this.startTime,\\n initialCapital: this.initialCapital,\\n finalCapital: currentPortfolioValue,\\n totalReturn,\\n annualizedReturn,\\n sharpeRatio,\\n maxDrawdown: this.maxDrawdown,\\n maxDrawdownDuration: this.maxDrawdownDuration,\\n winRate,\\n totalTrades,\\n winningTrades: this.winningTrades,\\n losingTrades: this.losingTrades,\\n averageWinningTrade: avgWinningTrade,\\n averageLosingTrade: avgLosingTrade,\\n profitFactor,\\n dailyReturns: this.dailyReturns,\\n trades: this.trades\\n };\\n }\\n}\"}", - "id": "toolu_vrtx_01Fw8SFDySQgWVfqEtxnuqpv__vscode-1748915937096" - } - ], - "toolInputRetry": 0, - "id": "cdc376b7-946d-4e5a-aa07-8c23c2d862da" - }, - { - "response": "", - "toolCalls": [ - { - "name": "replace_string_in_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"newString\": \"import { EventEmitter } from 'events';\\nimport { BarData, Order, Position } from '@stock-bot/shared-types';\\n\\nexport interface BacktestConfig {\\n startDate: Date;\\n endDate: Date;\\n symbols: string[];\\n initialCapital: number;\\n commission: number; // Per trade commission (percentage)\\n slippage: number; // Slippage model (percentage)\\n dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\\n mode: 'event' | 'vector';\\n}\\n\\nexport interface BacktestResult {\\n strategyId: string;\\n startDate: Date;\\n endDate: Date;\\n duration: number; // In milliseconds\\n initialCapital: number;\\n finalCapital: number;\\n totalReturn: number;\\n annualizedReturn: number;\\n sharpeRatio: number;\\n maxDrawdown: number;\\n maxDrawdownDuration: number; // In days\\n winRate: number;\\n totalTrades: number;\\n winningTrades: number;\\n losingTrades: number;\\n averageWinningTrade: number;\\n averageLosingTrade: number;\\n profitFactor: number;\\n dailyReturns: Array<{ date: Date; return: number }>;\\n trades: Array<{\\n symbol: string;\\n entryTime: Date;\\n entryPrice: number;\\n exitTime: Date;\\n exitPrice: number;\\n quantity: number;\\n pnl: number;\\n pnlPercent: number;\\n }>;\\n}\\n\\nexport interface BacktestProgress {\\n progress: number; // 0-100\\n currentDate: Date;\\n processingSpeed: number; // Bars per second\\n estimatedTimeRemaining: number; // milliseconds\\n currentCapital: number;\\n currentReturn: number;\\n currentDrawdown: number;\\n}\\n\\nexport interface DataFeed {\\n getHistoricalData(symbol: string, resolution: string, start: Date, end: Date): Promise;\\n hasDataFor(symbol: string, resolution: string, start: Date, end: Date): Promise;\\n}\\n\\nexport interface StrategyInterface {\\n id: string;\\n start(): Promise;\\n stop(): Promise;\\n onBar(bar: BarData): Promise;\\n onOrderFilled(order: Order): Promise;\\n}\\n\\nexport class BacktestEngine extends EventEmitter {\\n private config: BacktestConfig;\\n private strategy: StrategyInterface;\\n private dataFeed: DataFeed;\\n private isRunning: boolean = false;\\n private barBuffer: Map = new Map();\\n private pendingOrders: Order[] = [];\\n private filledOrders: Order[] = [];\\n private currentTime: Date;\\n private startTime: number = 0;\\n private processedBars: number = 0;\\n private marketData: Map = new Map();\\n\\n // Results tracking\\n private initialCapital: number;\\n private currentCapital: number;\\n private positions = new Map();\\n private trades: BacktestResult['trades'] = [];\\n private dailyReturns: BacktestResult['dailyReturns'] = [];\\n private previousPortfolioValue: number;\\n private highWaterMark: number;\\n private maxDrawdown: number = 0;\\n private drawdownStartTime: Date | null = null;\\n private maxDrawdownDuration: number = 0;\\n private winningTrades: number = 0;\\n private losingTrades: number = 0;\\n private breakEvenTrades: number = 0;\\n private totalProfits: number = 0;\\n private totalLosses: number = 0;\\n\\n constructor(strategy: StrategyInterface, config: BacktestConfig, dataFeed: DataFeed) {\\n super();\\n this.strategy = strategy;\\n this.config = config;\\n this.dataFeed = dataFeed;\\n this.currentTime = new Date(config.startDate);\\n this.initialCapital = config.initialCapital;\\n this.currentCapital = config.initialCapital;\\n this.previousPortfolioValue = config.initialCapital;\\n this.highWaterMark = config.initialCapital;\\n }\\n\\n async run(): Promise {\\n if (this.isRunning) {\\n throw new Error('Backtest is already running');\\n }\\n\\n this.isRunning = true;\\n this.startTime = Date.now();\\n this.emit('started', { strategyId: this.strategy.id, config: this.config });\\n\\n try {\\n if (this.config.mode === 'event') {\\n await this.runEventBased();\\n } else {\\n await this.runVectorized();\\n }\\n\\n const result = this.generateResults();\\n this.emit('completed', { strategyId: this.strategy.id, result });\\n this.isRunning = false;\\n return result;\\n } catch (error) {\\n this.isRunning = false;\\n this.emit('error', { strategyId: this.strategy.id, error });\\n throw error;\\n }\\n }\\n\\n private async runEventBased(): Promise {\\n await this.loadMarketData();\\n await this.strategy.start();\\n\\n const timeline = this.createMergedTimeline();\\n let lastProgressUpdate = Date.now();\\n let prevDate = new Date(0);\\n \\n for (let i = 0; i < timeline.length; i++) {\\n const bar = timeline[i];\\n this.currentTime = bar.timestamp;\\n\\n await this.processOrders(bar);\\n this.updatePositions(bar);\\n\\n if (this.currentTime.toDateString() !== prevDate.toDateString()) {\\n this.calculateDailyReturn();\\n prevDate = this.currentTime;\\n }\\n\\n const orders = await this.strategy.onBar(bar);\\n \\n if (orders && orders.length > 0) {\\n this.pendingOrders.push(...orders);\\n }\\n\\n if (Date.now() - lastProgressUpdate > 1000) {\\n this.updateProgress(i / timeline.length);\\n lastProgressUpdate = Date.now();\\n }\\n }\\n\\n for (const order of this.pendingOrders) {\\n await this.processOrder(order);\\n }\\n\\n await this.closeAllPositions();\\n await this.strategy.stop();\\n }\\n\\n private async runVectorized(): Promise {\\n await this.loadMarketData();\\n \\n const timeline = this.createMergedTimeline();\\n \\n const allBars = new Map();\\n for (const symbol of this.config.symbols) {\\n allBars.set(symbol, this.marketData.get(symbol) || []);\\n }\\n \\n this.emit('completed', { message: 'Vectorized backtest completed in fast mode' });\\n }\\n\\n private async loadMarketData(): Promise {\\n for (const symbol of this.config.symbols) {\\n this.emit('loading', { symbol, resolution: this.config.dataResolution });\\n \\n const hasData = await this.dataFeed.hasDataFor(\\n symbol,\\n this.config.dataResolution,\\n this.config.startDate,\\n this.config.endDate\\n );\\n \\n if (!hasData) {\\n throw new Error(`No data available for ${symbol} at resolution ${this.config.dataResolution}`);\\n }\\n \\n const data = await this.dataFeed.getHistoricalData(\\n symbol,\\n this.config.dataResolution,\\n this.config.startDate,\\n this.config.endDate\\n );\\n \\n this.marketData.set(symbol, data);\\n this.emit('loaded', { symbol, count: data.length });\\n }\\n }\\n\\n private createMergedTimeline(): BarData[] {\\n const allBars: BarData[] = [];\\n \\n for (const [symbol, bars] of this.marketData.entries()) {\\n allBars.push(...bars);\\n }\\n \\n return allBars.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());\\n }\\n\\n private async processOrders(currentBar: BarData): Promise {\\n const ordersToProcess = this.pendingOrders.filter(order => order.symbol === currentBar.symbol);\\n \\n if (ordersToProcess.length === 0) return;\\n \\n this.pendingOrders = this.pendingOrders.filter(order => order.symbol !== currentBar.symbol);\\n \\n for (const order of ordersToProcess) {\\n await this.processOrder(order);\\n }\\n }\\n\\n private async processOrder(order: Order): Promise {\\n const latestBars = this.marketData.get(order.symbol);\\n if (!latestBars || latestBars.length === 0) {\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'No market data available' });\\n return;\\n }\\n \\n const bar = latestBars.find(b => \\n b.timestamp.getTime() >= order.timestamp.getTime()\\n ) || latestBars[latestBars.length - 1];\\n \\n let fillPrice: number;\\n if (order.type === 'MARKET') {\\n const slippageFactor = 1 + (order.side === 'BUY' ? this.config.slippage : -this.config.slippage);\\n fillPrice = bar.close * slippageFactor;\\n } else if (order.type === 'LIMIT' && order.price !== undefined) {\\n if ((order.side === 'BUY' && bar.low <= order.price) ||\\n (order.side === 'SELL' && bar.high >= order.price)) {\\n fillPrice = order.price;\\n } else {\\n return;\\n }\\n } else {\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'Order type not supported' });\\n return;\\n }\\n \\n const orderValue = order.quantity * fillPrice;\\n const commission = orderValue * this.config.commission;\\n \\n if (order.side === 'BUY') {\\n const totalCost = orderValue + commission;\\n if (totalCost > this.currentCapital) {\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'Insufficient funds' });\\n return;\\n }\\n \\n this.currentCapital -= totalCost;\\n \\n const existingPosition = this.positions.get(order.symbol);\\n if (existingPosition) {\\n const totalShares = existingPosition.quantity + order.quantity;\\n const totalCost = (existingPosition.quantity * existingPosition.avgPrice) + (order.quantity * fillPrice);\\n existingPosition.avgPrice = totalCost / totalShares;\\n existingPosition.quantity = totalShares;\\n } else {\\n this.positions.set(order.symbol, {\\n symbol: order.symbol,\\n quantity: order.quantity,\\n avgPrice: fillPrice,\\n side: 'LONG',\\n entryTime: this.currentTime\\n });\\n }\\n } else if (order.side === 'SELL') {\\n const position = this.positions.get(order.symbol);\\n \\n if (!position || position.quantity < order.quantity) {\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'Insufficient position' });\\n return;\\n }\\n \\n const pnl = (fillPrice - position.avgPrice) * order.quantity;\\n \\n this.currentCapital += orderValue - commission;\\n \\n position.quantity -= order.quantity;\\n \\n if (position.quantity === 0) {\\n this.positions.delete(order.symbol);\\n \\n this.trades.push({\\n symbol: order.symbol,\\n entryTime: position.entryTime,\\n entryPrice: position.avgPrice,\\n exitTime: this.currentTime,\\n exitPrice: fillPrice,\\n quantity: order.quantity,\\n pnl: pnl,\\n pnlPercent: (pnl / (position.avgPrice * order.quantity)) * 100\\n });\\n \\n if (pnl > 0) {\\n this.winningTrades++;\\n this.totalProfits += pnl;\\n } else if (pnl < 0) {\\n this.losingTrades++;\\n this.totalLosses -= pnl;\\n } else {\\n this.breakEvenTrades++;\\n }\\n }\\n }\\n \\n order.status = 'FILLED';\\n order.fillPrice = fillPrice;\\n order.fillTime = this.currentTime;\\n this.filledOrders.push(order);\\n \\n await this.strategy.onOrderFilled(order);\\n \\n this.emit('orderFilled', { order });\\n }\\n\\n private updatePositions(currentBar: BarData): void {\\n const position = this.positions.get(currentBar.symbol);\\n if (position) {\\n const currentPrice = currentBar.close;\\n const unrealizedPnL = (currentPrice - position.avgPrice) * position.quantity;\\n position.unrealizedPnL = unrealizedPnL;\\n }\\n \\n const portfolioValue = this.calculatePortfolioValue();\\n \\n if (portfolioValue > this.highWaterMark) {\\n this.highWaterMark = portfolioValue;\\n this.drawdownStartTime = null;\\n }\\n \\n if (this.drawdownStartTime === null && portfolioValue < this.highWaterMark) {\\n this.drawdownStartTime = this.currentTime;\\n }\\n \\n if (this.highWaterMark > 0) {\\n const currentDrawdown = (this.highWaterMark - portfolioValue) / this.highWaterMark;\\n if (currentDrawdown > this.maxDrawdown) {\\n this.maxDrawdown = currentDrawdown;\\n \\n if (this.drawdownStartTime !== null) {\\n const drawdownDuration = (this.currentTime.getTime() - this.drawdownStartTime.getTime()) / (1000 * 60 * 60 * 24);\\n if (drawdownDuration > this.maxDrawdownDuration) {\\n this.maxDrawdownDuration = drawdownDuration;\\n }\\n }\\n }\\n }\\n \\n this.previousPortfolioValue = portfolioValue;\\n }\\n\\n private calculatePortfolioValue(): number {\\n let totalValue = this.currentCapital;\\n \\n for (const [symbol, position] of this.positions.entries()) {\\n const bars = this.marketData.get(symbol);\\n if (bars && bars.length > 0) {\\n const latestBar = bars[bars.length - 1];\\n totalValue += position.quantity * latestBar.close;\\n } else {\\n totalValue += position.quantity * position.avgPrice;\\n }\\n }\\n \\n return totalValue;\\n }\\n\\n private calculateDailyReturn(): void {\\n const portfolioValue = this.calculatePortfolioValue();\\n const dailyReturn = (portfolioValue - this.previousPortfolioValue) / this.previousPortfolioValue;\\n \\n this.dailyReturns.push({\\n date: new Date(this.currentTime),\\n return: dailyReturn\\n });\\n \\n this.previousPortfolioValue = portfolioValue;\\n }\\n\\n private async closeAllPositions(): Promise {\\n for (const [symbol, position] of this.positions.entries()) {\\n const bars = this.marketData.get(symbol);\\n if (!bars || bars.length === 0) continue;\\n \\n const lastBar = bars[bars.length - 1];\\n const closePrice = lastBar.close;\\n \\n const pnl = (closePrice - position.avgPrice) * position.quantity;\\n \\n this.currentCapital += position.quantity * closePrice;\\n \\n this.trades.push({\\n symbol,\\n entryTime: position.entryTime,\\n entryPrice: position.avgPrice,\\n exitTime: this.currentTime,\\n exitPrice: closePrice,\\n quantity: position.quantity,\\n pnl,\\n pnlPercent: (pnl / (position.avgPrice * position.quantity)) * 100\\n });\\n \\n if (pnl > 0) {\\n this.winningTrades++;\\n this.totalProfits += pnl;\\n } else if (pnl < 0) {\\n this.losingTrades++;\\n this.totalLosses -= pnl;\\n } else {\\n this.breakEvenTrades++;\\n }\\n }\\n \\n this.positions.clear();\\n }\\n\\n private updateProgress(progress: number): void {\\n const currentPortfolioValue = this.calculatePortfolioValue();\\n const currentDrawdown = this.highWaterMark > 0 \\n ? (this.highWaterMark - currentPortfolioValue) / this.highWaterMark\\n : 0;\\n \\n const elapsedMs = Date.now() - this.startTime;\\n const totalEstimatedMs = elapsedMs / progress;\\n const remainingMs = totalEstimatedMs - elapsedMs;\\n \\n this.emit('progress', {\\n progress: progress * 100,\\n currentDate: this.currentTime,\\n processingSpeed: this.processedBars / (elapsedMs / 1000),\\n estimatedTimeRemaining: remainingMs,\\n currentCapital: this.currentCapital,\\n currentReturn: (currentPortfolioValue - this.initialCapital) / this.initialCapital,\\n currentDrawdown\\n } as BacktestProgress);\\n }\\n\\n private generateResults(): BacktestResult {\\n const currentPortfolioValue = this.calculatePortfolioValue();\\n const totalReturn = (currentPortfolioValue - this.initialCapital) / this.initialCapital;\\n \\n const days = (this.config.endDate.getTime() - this.config.startDate.getTime()) / (1000 * 60 * 60 * 24);\\n const annualizedReturn = Math.pow(1 + totalReturn, 365 / days) - 1;\\n \\n let sharpeRatio = 0;\\n if (this.dailyReturns.length > 1) {\\n const dailyReturnValues = this.dailyReturns.map(dr => dr.return);\\n const avgDailyReturn = dailyReturnValues.reduce((sum, ret) => sum + ret, 0) / dailyReturnValues.length;\\n const stdDev = Math.sqrt(\\n dailyReturnValues.reduce((sum, ret) => sum + Math.pow(ret - avgDailyReturn, 2), 0) / dailyReturnValues.length\\n );\\n \\n sharpeRatio = stdDev > 0 \\n ? (avgDailyReturn * 252) / (stdDev * Math.sqrt(252)) \\n : 0;\\n }\\n \\n const totalTrades = this.winningTrades + this.losingTrades + this.breakEvenTrades;\\n const winRate = totalTrades > 0 ? this.winningTrades / totalTrades : 0;\\n const profitFactor = this.totalLosses > 0 ? this.totalProfits / this.totalLosses : (this.totalProfits > 0 ? Infinity : 0);\\n \\n const avgWinningTrade = this.winningTrades > 0 ? this.totalProfits / this.winningTrades : 0;\\n const avgLosingTrade = this.losingTrades > 0 ? this.totalLosses / this.losingTrades : 0;\\n \\n return {\\n strategyId: this.strategy.id,\\n startDate: this.config.startDate,\\n endDate: this.config.endDate,\\n duration: Date.now() - this.startTime,\\n initialCapital: this.initialCapital,\\n finalCapital: currentPortfolioValue,\\n totalReturn,\\n annualizedReturn,\\n sharpeRatio,\\n maxDrawdown: this.maxDrawdown,\\n maxDrawdownDuration: this.maxDrawdownDuration,\\n winRate,\\n totalTrades,\\n winningTrades: this.winningTrades,\\n losingTrades: this.losingTrades,\\n averageWinningTrade: avgWinningTrade,\\n averageLosingTrade: avgLosingTrade,\\n profitFactor,\\n dailyReturns: this.dailyReturns,\\n trades: this.trades\\n };\\n }\\n}\", \"oldString\": \"\"}", - "id": "toolu_vrtx_01E8DwHCj6RwwvKdCmvmPPAF__vscode-1748915937097" - } - ], - "toolInputRetry": 1, - "id": "04995e06-df8f-4a59-bba2-97d15973e6e4" - }, - { - "response": "", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"endLineNumberBaseZero\": 10, \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"startLineNumberBaseZero\": 0}", - "id": "toolu_vrtx_01JX6gZkc5ttXkP9qKBCdmiT__vscode-1748915937098" - } - ], - "toolInputRetry": 0, - "id": "cf21659d-7117-4751-8df3-9472333aa60f" - }, - { - "response": "I can see the file already has content. Let me update it to use the shared types properly: ", - "toolCalls": [ - { - "name": "replace_string_in_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"oldString\": \"import { EventEmitter } from 'events';\\nimport { BaseStrategy } from '../Strategy';\\nimport { BarData, Order, Position } from '../Strategy';\", \"newString\": \"import { EventEmitter } from 'events';\\nimport { BarData, Order, Position } from '@stock-bot/shared-types';\"}", - "id": "toolu_01D3eZEja6q8NGsYNSrBsaAy__vscode-1748915937099" - } - ], - "toolInputRetry": 0, - "id": "d4303c12-ae34-486d-a002-b37a69a29ba7" - }, - { - "response": "I need to check what types are available in the shared types and create the necessary interfaces. Let me check the shared types first: ", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"endLineNumberBaseZero\": 50, \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\packages\\\\shared-types\\\\src\\\\index.ts\", \"startLineNumberBaseZero\": 0}", - "id": "toolu_vrtx_01RRDeqBZH8MtJateAEwocFT__vscode-1748915937100" - } - ], - "toolInputRetry": 0, - "id": "1b6a27ec-5ba5-4eab-b081-341e51f61614" - }, - { - "response": "Now I can see the types. Let me update the BacktestEngine file to use the correct shared types and add missing properties: ", - "toolCalls": [ - { - "name": "replace_string_in_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"newString\": \"import { EventEmitter } from 'events';\\nimport { OHLCV, Order, Position } from '@stock-bot/shared-types';\\n\\n// Define additional types needed for backtesting\\nexport interface BarData extends OHLCV {}\\n\\nexport interface BacktestPosition extends Position {\\n entryTime: Date;\\n side: 'LONG' | 'SHORT';\\n avgPrice: number; // Alias for averagePrice for backward compatibility\\n}\\n\\nexport interface StrategyInterface {\\n id: string;\\n start(): Promise;\\n stop(): Promise;\\n onBar(bar: BarData): Promise;\\n onOrderFilled(order: Order): Promise;\\n}\", \"oldString\": \"import { EventEmitter } from 'events';\\nimport { BarData, Order, Position } from '@stock-bot/shared-types';\"}", - "id": "toolu_vrtx_01Xud8bZYFkcXZ3gTpe7K8BS__vscode-1748915937101" - } - ], - "toolInputRetry": 0, - "id": "b7428d4b-b058-4b65-a644-9d34a97d178c", - "summary": "## Conversation Summary\n\n**TASK DESCRIPTION:** \nRefactor the intelligence-services to separate the services into distinct, focused components. The current strategy-orchestrator service is doing everything (backtesting, signal generation, and strategy execution) and needs to be split into three separate services: Strategy Orchestrator (core strategy management), Backtest Engine (dedicated backtesting), and Signal Engine (signal generation and distribution).\n\n**COMPLETED:**\n1. Analyzed the current intelligence-services structure and identified that:\n - strategy-orchestrator contains all functionality (backtesting, execution, signal generation)\n - backtest-engine and signal-engine are empty placeholder services\n2. Explored the existing codebase structure and found comprehensive backtesting, execution, and strategy management code in strategy-orchestrator\n3. Created package.json for backtest-engine service with proper dependencies\n4. Created directory structure for backtest-engine (core/, controllers/, tests/)\n5. Started creating BacktestEngine.ts file but encountered TypeScript compilation errors\n\n**PENDING:**\n1. Fix TypeScript compilation errors in BacktestEngine.ts (missing interfaces, incompatible types)\n2. Complete the backtest-engine service implementation:\n - BacktestService.ts\n - MarketDataFeed.ts \n - PerformanceAnalytics.ts\n - Controller and API endpoints\n3. Create the signal-engine service implementation\n4. Refactor strategy-orchestrator to remove backtesting and signal generation code\n5. Update inter-service communication between the three services\n6. Create proper shared interfaces and types\n7. Update API routing and service coordination\n\n**CODE STATE:**\n- `g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\package.json` - Created\n- `g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts` - Started but has compilation errors\n- `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\` - Contains all existing code that needs to be split\n- `g:\\repos\\stock-bot\\packages\\shared-types\\src\\index.ts` - Examined for type definitions\n\n**CHANGES:**\n1. Created backtest-engine package.json with dependencies: hono, ioredis, @stock-bot/config, @stock-bot/shared-types, ws\n2. Attempted to create BacktestEngine.ts with proper imports from @stock-bot/shared-types\n3. Discovered type mismatches between existing code and shared-types (Position interface differences, missing BarData type)\n4. Created directory structure for backtest-engine service\n\n**CURRENT ISSUES:**\n- BacktestEngine.ts has compilation errors due to:\n - Missing BarData type in shared-types (using OHLCV instead)\n - Position interface differences (avgPrice vs averagePrice)\n - Missing properties on Order interface (fillPrice, fillTime)\n - TypeScript iteration issues with Map objects\n - Missing StrategyInterface definition\n\nThe refactoring is approximately 15% complete. Next steps require fixing the type system and completing the service separation." - }, - { - "response": "I'll continue with the refactoring by fixing the TypeScript compilation errors in the BacktestEngine.ts file and completing the service separation. Let me start by examining the current errors and fixing them. ", - "toolCalls": [ - { - "name": "get_errors", - "arguments": "{\"filePaths\": [\"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\"]}", - "id": "toolu_vrtx_01Hf58S3fB8hVKm5pYBemJGr__vscode-1748915937102" - } - ], - "toolInputRetry": 0, - "id": "0299902c-e81c-46f2-81f2-2522d0b6300d" - }, - { - "response": "Now let me check the shared types to understand the available interfaces and fix these issues: ", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\packages\\\\shared-types\\\\src\\\\index.ts\", \"startLineNumberBaseZero\": 0, \"endLineNumberBaseZero\": 100}", - "id": "toolu_vrtx_01AJsV3pNTFUAXYAYgKb7i5z__vscode-1748915937103" - } - ], - "toolInputRetry": 0, - "id": "bb672676-d8fe-4090-81df-28df631b45c9" - }, - { - "response": "", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"endLineNumberBaseZero\": 204, \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\packages\\\\shared-types\\\\src\\\\index.ts\", \"startLineNumberBaseZero\": 100}", - "id": "toolu_vrtx_01CaUrn4rEBSrdzoDY5wqdbm__vscode-1748915937104" - } - ], - "toolInputRetry": 0, - "id": "8b5efc29-ab78-4c0d-866d-bec83c639959" - }, - { - "response": "Now let me check if there's a BaseStrategy or similar interface in the existing strategy-orchestrator: ", - "toolCalls": [ - { - "name": "semantic_search", - "arguments": "{\"query\": \"BaseStrategy class interface abstract strategy execution\"}", - "id": "toolu_vrtx_01NhenMMWbqeQoXs7MCA2tMq__vscode-1748915937105" - } - ], - "toolInputRetry": 0, - "id": "b9e84454-358d-4378-a764-eeba966afa4e" - }, - { - "response": "Now let me check the Strategy.ts file to understand the existing BaseStrategy interface and types: ", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"endLineNumberBaseZero\": 100, \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\strategy-orchestrator\\\\src\\\\core\\\\Strategy.ts\", \"startLineNumberBaseZero\": 0}", - "id": "toolu_vrtx_01T27ynyGn19Nxp5bmEF28e9__vscode-1748915937106" - } - ], - "toolInputRetry": 0, - "id": "d0f8edc9-a0b7-4cb1-ab4a-c3c1a75c5655" - }, - { - "response": "Now I understand the existing structure. Let me fix the BacktestEngine.ts file by addressing all the compilation errors: ", - "toolCalls": [ - { - "name": "replace_string_in_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"oldString\": \"import { OHLCV, Order, Position } from '@stock-bot/shared-types';\\n\\nexport interface BacktestConfig {\\n initialCapital: number;\\n startDate: Date;\\n endDate: Date;\\n commission: number;\\n slippage: number;\\n}\\n\\nexport interface BacktestResult {\\n startDate: Date;\\n endDate: Date;\\n initialCapital: number;\\n finalCapital: number;\\n totalReturn: number;\\n totalTrades: number;\\n winningTrades: number;\\n losingTrades: number;\\n winRate: number;\\n avgWin: number;\\n avgLoss: number;\\n profitFactor: number;\\n sharpeRatio: number;\\n maxDrawdown: number;\\n trades: Array<{\\n id: string;\\n symbol: string;\\n side: 'BUY' | 'SELL';\\n quantity: number;\\n entryTime: Date;\\n exitTime: Date;\\n entryPrice: number;\\n exitPrice: number;\\n pnl: number;\\n pnlPercent: number;\\n }>;\\n dailyReturns: Array<{\\n date: Date;\\n portfolioValue: number;\\n dayReturn: number;\\n }>;\\n}\\n\\nexport interface BacktestProgress {\\n currentDate: Date;\\n progress: number; // 0-100\\n portfolioValue: number;\\n totalTrades: number;\\n}\\n\\nexport interface DataFeed {\\n getHistoricalData(symbol: string, startDate: Date, endDate: Date): Promise;\\n}\\n\\ninterface BarData {\\n symbol: string;\\n timestamp: Date;\\n open: number;\\n high: number;\\n low: number;\\n close: number;\\n volume: number;\\n}\", \"newString\": \"import { OHLCV, Order, Position } from '@stock-bot/shared-types';\\n\\n// Use OHLCV from shared-types as BarData equivalent\\nexport type BarData = OHLCV;\\n\\n// Strategy interface to match existing pattern\\nexport interface StrategyInterface {\\n onBar(bar: BarData): Promise | Order[];\\n stop(): Promise;\\n}\\n\\nexport interface BacktestConfig {\\n initialCapital: number;\\n startDate: Date;\\n endDate: Date;\\n commission: number;\\n slippage: number;\\n}\\n\\nexport interface BacktestResult {\\n startDate: Date;\\n endDate: Date;\\n initialCapital: number;\\n finalCapital: number;\\n totalReturn: number;\\n totalTrades: number;\\n winningTrades: number;\\n losingTrades: number;\\n winRate: number;\\n avgWin: number;\\n avgLoss: number;\\n profitFactor: number;\\n sharpeRatio: number;\\n maxDrawdown: number;\\n trades: Array<{\\n id: string;\\n symbol: string;\\n side: 'BUY' | 'SELL';\\n quantity: number;\\n entryTime: Date;\\n exitTime: Date;\\n entryPrice: number;\\n exitPrice: number;\\n pnl: number;\\n pnlPercent: number;\\n }>;\\n dailyReturns: Array<{\\n date: Date;\\n portfolioValue: number;\\n dayReturn: number;\\n }>;\\n}\\n\\nexport interface BacktestProgress {\\n currentDate: Date;\\n progress: number; // 0-100\\n portfolioValue: number;\\n totalTrades: number;\\n}\\n\\nexport interface DataFeed {\\n getHistoricalData(symbol: string, startDate: Date, endDate: Date): Promise;\\n}\\n\\n// Extended Position interface that includes additional fields needed for backtesting\\nexport interface BacktestPosition extends Position {\\n avgPrice: number;\\n entryTime: Date;\\n}\\n\\n// Extended Order interface that includes additional fields needed for backtesting\\nexport interface BacktestOrder extends Order {\\n fillPrice?: number;\\n fillTime?: Date;\\n}\"}", - "id": "toolu_vrtx_01Y3qjEd1BZudG2XDSmpiUPN__vscode-1748915937107" - } - ], - "toolInputRetry": 0, - "id": "9669a373-4898-47a6-88da-1abaceb07afc" - }, - { - "response": "Let me read the current file to see the exact content: ", - "toolCalls": [ - { - "name": "read_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"startLineNumberBaseZero\": 0, \"endLineNumberBaseZero\": 50}", - "id": "toolu_vrtx_01L4mieXjkwoqWM3cYa5JUvC__vscode-1748915937108" - } - ], - "toolInputRetry": 0, - "id": "8f37e559-fed7-48a9-bc70-f2ea9a4c275c" - }, - { - "response": "Let me completely rewrite the BacktestEngine.ts file with the correct fixes: ", - "toolCalls": [ - { - "name": "create_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"content\": \"import { EventEmitter } from 'events';\\nimport { OHLCV, Order, Position } from '@stock-bot/shared-types';\\n\\n// Use OHLCV from shared-types as BarData equivalent\\nexport type BarData = OHLCV;\\n\\n// Strategy interface to match existing pattern\\nexport interface StrategyInterface {\\n id: string;\\n onBar(bar: BarData): Promise | Order[];\\n stop(): Promise;\\n}\\n\\nexport interface BacktestConfig {\\n initialCapital: number;\\n startDate: Date;\\n endDate: Date;\\n commission: number;\\n slippage: number;\\n}\\n\\nexport interface BacktestResult {\\n startDate: Date;\\n endDate: Date;\\n initialCapital: number;\\n finalCapital: number;\\n totalReturn: number;\\n totalTrades: number;\\n winningTrades: number;\\n losingTrades: number;\\n winRate: number;\\n avgWin: number;\\n avgLoss: number;\\n profitFactor: number;\\n sharpeRatio: number;\\n maxDrawdown: number;\\n trades: Array<{\\n id: string;\\n symbol: string;\\n side: 'BUY' | 'SELL';\\n quantity: number;\\n entryTime: Date;\\n exitTime: Date;\\n entryPrice: number;\\n exitPrice: number;\\n pnl: number;\\n pnlPercent: number;\\n }>;\\n dailyReturns: Array<{\\n date: Date;\\n portfolioValue: number;\\n dayReturn: number;\\n }>;\\n}\\n\\nexport interface BacktestProgress {\\n currentDate: Date;\\n progress: number; // 0-100\\n portfolioValue: number;\\n totalTrades: number;\\n}\\n\\nexport interface DataFeed {\\n getHistoricalData(symbol: string, startDate: Date, endDate: Date): Promise;\\n}\\n\\n// Extended Position interface that includes additional fields needed for backtesting\\nexport interface BacktestPosition {\\n symbol: string;\\n quantity: number;\\n averagePrice: number;\\n marketValue: number;\\n unrealizedPnL: number;\\n timestamp: Date;\\n // Additional fields for backtesting\\n avgPrice: number; // Alias for averagePrice\\n entryTime: Date;\\n}\\n\\n// Extended Order interface that includes additional fields needed for backtesting\\nexport interface BacktestOrder extends Order {\\n fillPrice?: number;\\n fillTime?: Date;\\n}\\n\\nexport class BacktestEngine extends EventEmitter {\\n private config: BacktestConfig;\\n private strategy: StrategyInterface;\\n private dataFeed: DataFeed;\\n private isRunning: boolean = false;\\n private barBuffer: Map = new Map();\\n private pendingOrders: BacktestOrder[] = [];\\n private filledOrders: BacktestOrder[] = [];\\n private currentTime: Date;\\n private startTime: number = 0; // For performance tracking\\n private processedBars: number = 0;\\n private marketData: Map = new Map();\\n\\n // Results tracking\\n private initialCapital: number;\\n private currentCapital: number;\\n private positions = new Map();\\n private trades: BacktestResult['trades'] = [];\\n private dailyReturns: BacktestResult['dailyReturns'] = [];\\n private previousPortfolioValue: number;\\n private highWaterMark: number;\\n private maxDrawdown: number = 0;\\n private drawdownStartTime: Date | null = null;\\n\\n constructor(strategy: StrategyInterface, config: BacktestConfig, dataFeed: DataFeed) {\\n super();\\n this.strategy = strategy;\\n this.config = config;\\n this.dataFeed = dataFeed;\\n this.currentTime = new Date(config.startDate);\\n this.initialCapital = config.initialCapital;\\n this.currentCapital = config.initialCapital;\\n this.previousPortfolioValue = config.initialCapital;\\n this.highWaterMark = config.initialCapital;\\n }\\n\\n async run(): Promise {\\n if (this.isRunning) {\\n throw new Error('Backtest is already running');\\n }\\n\\n this.isRunning = true;\\n this.startTime = Date.now();\\n this.emit('started', { strategyId: this.strategy.id, config: this.config });\\n\\n try {\\n await this.runEventBased();\\n const result = this.generateResults();\\n this.emit('completed', { strategyId: this.strategy.id, result });\\n this.isRunning = false;\\n return result;\\n } catch (error) {\\n this.isRunning = false;\\n this.emit('error', { strategyId: this.strategy.id, error });\\n throw error;\\n }\\n }\\n\\n private async runEventBased(): Promise {\\n // Load market data for all symbols\\n await this.loadMarketData();\\n\\n // Create a merged timeline of all bars across all symbols, sorted by timestamp\\n const timeline = this.createMergedTimeline();\\n\\n // Process each event in chronological order\\n let lastProgressUpdate = Date.now();\\n \\n for (let i = 0; i < timeline.length; i++) {\\n const bar = timeline[i];\\n this.currentTime = bar.timestamp;\\n\\n // Process any pending orders\\n await this.processOrders(bar);\\n\\n // Update positions with current prices\\n this.updatePositions(bar);\\n\\n // Send the new bar to the strategy\\n const orders = await this.strategy.onBar(bar);\\n \\n // Add any new orders to the pending orders queue\\n if (orders && orders.length > 0) {\\n this.pendingOrders.push(...(orders as BacktestOrder[]));\\n }\\n\\n // Update progress periodically\\n if (Date.now() - lastProgressUpdate > 1000) { // Update every second\\n this.updateProgress(i / timeline.length);\\n lastProgressUpdate = Date.now();\\n }\\n }\\n\\n // Process any remaining orders\\n for (const order of this.pendingOrders) {\\n await this.processOrder(order);\\n }\\n\\n // Close any remaining positions at the last known price\\n await this.closeAllPositions();\\n\\n // Clean up strategy\\n await this.strategy.stop();\\n }\\n\\n private async loadMarketData(): Promise {\\n // For this implementation, we need to assume symbols are provided in config\\n // In a real implementation, this would be extracted from the strategy\\n const symbols = ['AAPL', 'MSFT']; // Placeholder\\n \\n for (const symbol of symbols) {\\n this.emit('loading', { symbol });\\n \\n const data = await this.dataFeed.getHistoricalData(\\n symbol,\\n this.config.startDate,\\n this.config.endDate\\n );\\n \\n this.marketData.set(symbol, data);\\n this.emit('loaded', { symbol, count: data.length });\\n }\\n }\\n\\n private createMergedTimeline(): BarData[] {\\n const allBars: BarData[] = [];\\n \\n // Use Array.from to iterate over Map entries properly\\n Array.from(this.marketData.entries()).forEach(([symbol, bars]) => {\\n allBars.push(...bars);\\n });\\n \\n // Sort by timestamp\\n return allBars.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());\\n }\\n\\n private async processOrders(currentBar: BarData): Promise {\\n // Find orders for the current symbol\\n const ordersToProcess = this.pendingOrders.filter(order => order.symbol === currentBar.symbol);\\n \\n if (ordersToProcess.length === 0) return;\\n \\n // Remove these orders from pendingOrders\\n this.pendingOrders = this.pendingOrders.filter(order => order.symbol !== currentBar.symbol);\\n \\n // Process each order\\n for (const order of ordersToProcess) {\\n await this.processOrder(order);\\n }\\n }\\n\\n private async processOrder(order: BacktestOrder): Promise {\\n // Get the latest price for the symbol\\n const latestBars = this.marketData.get(order.symbol);\\n if (!latestBars || latestBars.length === 0) {\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'No market data available' });\\n return;\\n }\\n \\n // Find the bar closest to the order time\\n const bar = latestBars.find(b => \\n b.timestamp.getTime() >= order.timestamp.getTime()\\n ) || latestBars[latestBars.length - 1];\\n \\n // Calculate fill price with slippage\\n let fillPrice: number;\\n if (order.type === 'MARKET') {\\n // Apply slippage model\\n const slippageFactor = 1 + (order.side === 'BUY' ? this.config.slippage : -this.config.slippage);\\n fillPrice = bar.close * slippageFactor;\\n } else if (order.type === 'LIMIT' && order.price !== undefined) {\\n // For limit orders, check if the price was reached\\n if ((order.side === 'BUY' && bar.low <= order.price) ||\\n (order.side === 'SELL' && bar.high >= order.price)) {\\n fillPrice = order.price;\\n } else {\\n // Limit price not reached\\n return;\\n }\\n } else {\\n // Other order types not implemented\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'Order type not supported' });\\n return;\\n }\\n \\n // Calculate commission\\n const orderValue = order.quantity * fillPrice;\\n const commission = orderValue * this.config.commission;\\n \\n // Check if we have enough cash for BUY orders\\n if (order.side === 'BUY') {\\n const totalCost = orderValue + commission;\\n if (totalCost > this.currentCapital) {\\n // Not enough cash\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'Insufficient funds' });\\n return;\\n }\\n \\n // Update cash\\n this.currentCapital -= totalCost;\\n \\n // Update or create position\\n const existingPosition = this.positions.get(order.symbol);\\n if (existingPosition) {\\n // Update existing position (average down)\\n const totalShares = existingPosition.quantity + order.quantity;\\n const totalCost = (existingPosition.quantity * existingPosition.averagePrice) + (order.quantity * fillPrice);\\n existingPosition.averagePrice = totalCost / totalShares;\\n existingPosition.avgPrice = existingPosition.averagePrice; // Update alias\\n existingPosition.quantity = totalShares;\\n } else {\\n // Create new position\\n this.positions.set(order.symbol, {\\n symbol: order.symbol,\\n quantity: order.quantity,\\n averagePrice: fillPrice,\\n avgPrice: fillPrice,\\n marketValue: order.quantity * fillPrice,\\n unrealizedPnL: 0,\\n timestamp: this.currentTime,\\n entryTime: this.currentTime\\n });\\n }\\n } else if (order.side === 'SELL') {\\n const position = this.positions.get(order.symbol);\\n \\n if (!position || position.quantity < order.quantity) {\\n // Not enough shares to sell\\n order.status = 'REJECTED';\\n this.emit('orderRejected', { order, reason: 'Insufficient position' });\\n return;\\n }\\n \\n // Calculate P&L\\n const pnl = (fillPrice - position.averagePrice) * order.quantity;\\n \\n // Update cash\\n this.currentCapital += orderValue - commission;\\n \\n // Update position\\n position.quantity -= order.quantity;\\n \\n if (position.quantity === 0) {\\n // Position closed, record the trade\\n this.positions.delete(order.symbol);\\n \\n this.trades.push({\\n id: `trade_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,\\n symbol: order.symbol,\\n side: order.side,\\n quantity: order.quantity,\\n entryTime: position.entryTime,\\n exitTime: this.currentTime,\\n entryPrice: position.averagePrice,\\n exitPrice: fillPrice,\\n pnl: pnl,\\n pnlPercent: (pnl / (position.averagePrice * order.quantity)) * 100\\n });\\n }\\n }\\n \\n // Mark order as filled\\n order.status = 'FILLED';\\n order.fillPrice = fillPrice;\\n order.fillTime = this.currentTime;\\n this.filledOrders.push(order);\\n \\n this.emit('orderFilled', { order });\\n }\\n\\n private updatePositions(currentBar: BarData): void {\\n // Update the unrealized P&L for positions in this symbol\\n const position = this.positions.get(currentBar.symbol);\\n if (position) {\\n const currentPrice = currentBar.close;\\n const unrealizedPnL = (currentPrice - position.averagePrice) * position.quantity;\\n position.unrealizedPnL = unrealizedPnL;\\n position.marketValue = position.quantity * currentPrice;\\n }\\n \\n // Calculate total portfolio value\\n const portfolioValue = this.calculatePortfolioValue();\\n \\n // Check for new high water mark\\n if (portfolioValue > this.highWaterMark) {\\n this.highWaterMark = portfolioValue;\\n this.drawdownStartTime = null;\\n }\\n \\n // Check for drawdown\\n if (this.drawdownStartTime === null && portfolioValue < this.highWaterMark) {\\n this.drawdownStartTime = this.currentTime;\\n }\\n \\n // Update max drawdown\\n if (this.highWaterMark > 0) {\\n const currentDrawdown = (this.highWaterMark - portfolioValue) / this.highWaterMark;\\n if (currentDrawdown > this.maxDrawdown) {\\n this.maxDrawdown = currentDrawdown;\\n }\\n }\\n \\n this.previousPortfolioValue = portfolioValue;\\n }\\n\\n private calculatePortfolioValue(): number {\\n let totalValue = this.currentCapital;\\n \\n // Add the current value of all positions\\n Array.from(this.positions.entries()).forEach(([symbol, position]) => {\\n // Find the latest price for this symbol\\n const bars = this.marketData.get(symbol);\\n if (bars && bars.length > 0) {\\n const latestBar = bars[bars.length - 1];\\n totalValue += position.quantity * latestBar.close;\\n } else {\\n // If no price data, use the average price (not ideal but better than nothing)\\n totalValue += position.quantity * position.averagePrice;\\n }\\n });\\n \\n return totalValue;\\n }\\n\\n private async closeAllPositions(): Promise {\\n Array.from(this.positions.entries()).forEach(([symbol, position]) => {\\n // Find the latest price\\n const bars = this.marketData.get(symbol);\\n if (!bars || bars.length === 0) return;\\n \\n const lastBar = bars[bars.length - 1];\\n const closePrice = lastBar.close;\\n \\n // Calculate P&L\\n const pnl = (closePrice - position.averagePrice) * position.quantity;\\n \\n // Update cash\\n this.currentCapital += position.quantity * closePrice;\\n \\n // Record the trade\\n this.trades.push({\\n id: `trade_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,\\n symbol,\\n side: 'SELL',\\n quantity: position.quantity,\\n entryTime: position.entryTime,\\n exitTime: this.currentTime,\\n entryPrice: position.averagePrice,\\n exitPrice: closePrice,\\n pnl,\\n pnlPercent: (pnl / (position.averagePrice * position.quantity)) * 100\\n });\\n });\\n \\n // Clear positions\\n this.positions.clear();\\n }\\n\\n private updateProgress(progress: number): void {\\n const currentPortfolioValue = this.calculatePortfolioValue();\\n \\n this.emit('progress', {\\n progress: progress * 100,\\n currentDate: this.currentTime,\\n portfolioValue: currentPortfolioValue,\\n totalTrades: this.trades.length\\n } as BacktestProgress);\\n }\\n\\n private generateResults(): BacktestResult {\\n const currentPortfolioValue = this.calculatePortfolioValue();\\n const totalReturn = (currentPortfolioValue - this.initialCapital) / this.initialCapital;\\n \\n // Calculate basic metrics\\n const winningTrades = this.trades.filter(t => t.pnl > 0);\\n const losingTrades = this.trades.filter(t => t.pnl < 0);\\n const winRate = this.trades.length > 0 ? winningTrades.length / this.trades.length : 0;\\n \\n const avgWin = winningTrades.length > 0 \\n ? winningTrades.reduce((sum, t) => sum + t.pnl, 0) / winningTrades.length \\n : 0;\\n \\n const avgLoss = losingTrades.length > 0 \\n ? Math.abs(losingTrades.reduce((sum, t) => sum + t.pnl, 0)) / losingTrades.length \\n : 0;\\n \\n const profitFactor = avgLoss > 0 ? avgWin / avgLoss : (avgWin > 0 ? Infinity : 0);\\n \\n // Simple Sharpe ratio calculation (would need risk-free rate in real implementation)\\n const sharpeRatio = this.dailyReturns.length > 1 ? this.calculateSharpeRatio() : 0;\\n \\n return {\\n startDate: this.config.startDate,\\n endDate: this.config.endDate,\\n initialCapital: this.initialCapital,\\n finalCapital: currentPortfolioValue,\\n totalReturn,\\n totalTrades: this.trades.length,\\n winningTrades: winningTrades.length,\\n losingTrades: losingTrades.length,\\n winRate,\\n avgWin,\\n avgLoss,\\n profitFactor,\\n sharpeRatio,\\n maxDrawdown: this.maxDrawdown,\\n trades: this.trades,\\n dailyReturns: this.dailyReturns\\n };\\n }\\n\\n private calculateSharpeRatio(): number {\\n if (this.dailyReturns.length < 2) return 0;\\n \\n const returns = this.dailyReturns.map(d => d.dayReturn);\\n const avgReturn = returns.reduce((sum, r) => sum + r, 0) / returns.length;\\n const variance = returns.reduce((sum, r) => sum + Math.pow(r - avgReturn, 2), 0) / returns.length;\\n const stdDev = Math.sqrt(variance);\\n \\n return stdDev > 0 ? avgReturn / stdDev : 0;\\n }\\n}\"}", - "id": "toolu_vrtx_01BRFpPDWcjWsQ8moAvKiNG7__vscode-1748915937109" - } - ], - "toolInputRetry": 0, - "id": "c3e20137-c9b7-4c37-8ee7-900ddda1ce4e" - }, - { - "response": "", - "toolCalls": [ - { - "name": "replace_string_in_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"newString\": \"import { EventEmitter } from 'events';\\nimport { OHLCV, Order, Position } from '@stock-bot/shared-types';\\n\\n// Use OHLCV from shared-types as BarData equivalent\\nexport type BarData = OHLCV;\\n\\n// Strategy interface to match existing pattern\\nexport interface StrategyInterface {\\n id: string;\\n onBar(bar: BarData): Promise | Order[];\\n stop(): Promise;\\n}\\n\\nexport interface BacktestConfig {\\n initialCapital: number;\\n startDate: Date;\\n endDate: Date;\\n commission: number;\\n slippage: number;\\n}\\n\\nexport interface BacktestResult {\\n startDate: Date;\\n endDate: Date;\\n initialCapital: number;\\n finalCapital: number;\\n totalReturn: number;\\n totalTrades: number;\\n winningTrades: number;\\n losingTrades: number;\\n winRate: number;\\n avgWin: number;\\n avgLoss: number;\\n profitFactor: number;\\n sharpeRatio: number;\\n maxDrawdown: number;\\n trades: Array<{\\n id: string;\\n symbol: string;\\n side: 'BUY' | 'SELL';\\n quantity: number;\\n entryTime: Date;\\n exitTime: Date;\\n entryPrice: number;\\n exitPrice: number;\\n pnl: number;\\n pnlPercent: number;\\n }>;\\n dailyReturns: Array<{\\n date: Date;\\n portfolioValue: number;\\n dayReturn: number;\\n }>;\\n}\\n\\nexport interface BacktestProgress {\\n currentDate: Date;\\n progress: number; // 0-100\\n portfolioValue: number;\\n totalTrades: number;\\n}\\n\\nexport interface DataFeed {\\n getHistoricalData(symbol: string, startDate: Date, endDate: Date): Promise;\\n}\\n\\n// Extended Position interface that includes additional fields needed for backtesting\\nexport interface BacktestPosition {\\n symbol: string;\\n quantity: number;\\n averagePrice: number;\\n marketValue: number;\\n unrealizedPnL: number;\\n timestamp: Date;\\n // Additional fields for backtesting\\n avgPrice: number; // Alias for averagePrice\\n entryTime: Date;\\n}\\n\\n// Extended Order interface that includes additional fields needed for backtesting\\nexport interface BacktestOrder extends Order {\\n fillPrice?: number;\\n fillTime?: Date;\\n}\", \"oldString\": \"import { EventEmitter } from 'events';\\nimport { OHLCV, Order, Position } from '@stock-bot/shared-types';\\n\\n// Define additional types needed for backtesting\\nexport interface BarData extends OHLCV {}\\n\\nexport interface BacktestPosition extends Position {\\n entryTime: Date;\\n side: 'LONG' | 'SHORT';\\n avgPrice: number; // Alias for averagePrice for backward compatibility\\n}\\n\\nexport interface StrategyInterface {\\n id: string;\\n start(): Promise;\\n stop(): Promise;\\n onBar(bar: BarData): Promise;\\n onOrderFilled(order: Order): Promise;\\n}\\n\\nexport interface BacktestConfig {\\n startDate: Date;\\n endDate: Date;\\n symbols: string[];\\n initialCapital: number;\\n commission: number; // Per trade commission (percentage)\\n slippage: number; // Slippage model (percentage)\\n dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\\n mode: 'event' | 'vector';\\n}\\n\\nexport interface BacktestResult {\\n strategyId: string;\\n startDate: Date;\\n endDate: Date;\\n duration: number; // In milliseconds\\n initialCapital: number;\\n finalCapital: number;\\n totalReturn: number;\\n annualizedReturn: number;\\n sharpeRatio: number;\\n maxDrawdown: number;\\n maxDrawdownDuration: number; // In days\\n winRate: number;\\n totalTrades: number;\\n winningTrades: number;\\n losingTrades: number;\\n averageWinningTrade: number;\\n averageLosingTrade: number;\\n profitFactor: number;\\n dailyReturns: Array<{ date: Date; return: number }>;\"}", - "id": "toolu_vrtx_012Fy3a1BvkNbrntkGkrTBaJ__vscode-1748915937110" - } - ], - "toolInputRetry": 1, - "id": "871d2b88-dfc9-4c0e-9ac6-af2c1fbeb55e" - }, - { - "response": "I need to continue the replacement properly. Let me replace the entire file content section by section: ", - "toolCalls": [ - { - "name": "replace_string_in_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"newString\": \"export class BacktestEngine extends EventEmitter {\\n private config: BacktestConfig;\\n private strategy: StrategyInterface;\\n private dataFeed: DataFeed;\\n private isRunning: boolean = false;\\n private barBuffer: Map = new Map();\\n private pendingOrders: BacktestOrder[] = [];\\n private filledOrders: BacktestOrder[] = [];\\n private currentTime: Date;\\n private startTime: number = 0; // For performance tracking\\n private processedBars: number = 0;\\n private marketData: Map = new Map();\\n\\n // Results tracking\\n private initialCapital: number;\\n private currentCapital: number;\\n private positions = new Map();\\n private trades: BacktestResult['trades'] = [];\\n private dailyReturns: BacktestResult['dailyReturns'] = [];\\n private previousPortfolioValue: number;\\n private highWaterMark: number;\\n private maxDrawdown: number = 0;\\n private drawdownStartTime: Date | null = null;\", \"oldString\": \"export class BacktestEngine extends EventEmitter {\\n private config: BacktestConfig;\\n private strategy: BaseStrategy;\\n private dataFeed: DataFeed;\\n private isRunning: boolean = false;\\n private barBuffer: Map = new Map();\\n private pendingOrders: Order[] = [];\\n private filledOrders: Order[] = [];\\n private currentTime: Date;\\n private startTime: number = 0; // For performance tracking\\n private processedBars: number = 0;\\n private marketData: Map = new Map();\\n\\n // Results tracking\\n private initialCapital: number;\\n private currentCapital: number;\\n private positions = new Map();\\n private trades: BacktestResult['trades'] = [];\\n private dailyReturns: BacktestResult['dailyReturns'] = [];\\n private previousPortfolioValue: number;\\n private highWaterMark: number;\\n private maxDrawdown: number = 0;\\n private drawdownStartTime: Date | null = null;\"}", - "id": "toolu_vrtx_01AsCqJnx3Wq3WLDn3a4UmDn__vscode-1748915937111" - } - ], - "toolInputRetry": 0, - "id": "4c65b826-a7ce-4242-b017-da7b7f35a674" - }, - { - "response": "Now let me continue fixing the rest of the file: ", - "toolCalls": [ - { - "name": "replace_string_in_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"newString\": \" constructor(strategy: StrategyInterface, config: BacktestConfig, dataFeed: DataFeed) {\\n super();\\n this.strategy = strategy;\\n this.config = config;\\n this.dataFeed = dataFeed;\\n this.currentTime = new Date(config.startDate);\\n this.initialCapital = config.initialCapital;\\n this.currentCapital = config.initialCapital;\\n this.previousPortfolioValue = config.initialCapital;\\n this.highWaterMark = config.initialCapital;\\n }\", \"oldString\": \" constructor(strategy: BaseStrategy, config: BacktestConfig, dataFeed: DataFeed) {\\n super();\\n this.strategy = strategy;\\n this.config = config;\\n this.dataFeed = dataFeed;\\n this.currentTime = new Date(config.startDate);\\n this.initialCapital = config.initialCapital;\\n this.currentCapital = config.initialCapital;\\n this.previousPortfolioValue = config.initialCapital;\\n this.highWaterMark = config.initialCapital;\\n }\"}", - "id": "toolu_vrtx_015o8ED2HDNYin9gv594YFuX__vscode-1748915937112" - } - ], - "toolInputRetry": 0, - "id": "82228b9e-b7f8-4cb8-8e18-31fc4959e3f5" - }, - { - "response": "I need to update the tsconfig.json to support iterating over Map entries, and also finish fixing the remaining issues. Let me create a proper tsconfig.json file first: ", - "toolCalls": [ - { - "name": "create_file", - "arguments": "{\"content\": \"{\\n \\\"compilerOptions\\\": {\\n \\\"target\\\": \\\"ES2020\\\",\\n \\\"module\\\": \\\"commonjs\\\",\\n \\\"lib\\\": [\\\"ES2020\\\", \\\"DOM\\\"],\\n \\\"allowJs\\\": true,\\n \\\"outDir\\\": \\\"./dist\\\",\\n \\\"rootDir\\\": \\\"./src\\\",\\n \\\"strict\\\": true,\\n \\\"moduleResolution\\\": \\\"node\\\",\\n \\\"baseUrl\\\": \\\".\\\",\\n \\\"esModuleInterop\\\": true,\\n \\\"experimentalDecorators\\\": true,\\n \\\"emitDecoratorMetadata\\\": true,\\n \\\"skipLibCheck\\\": true,\\n \\\"forceConsistentCasingInFileNames\\\": true,\\n \\\"declaration\\\": true,\\n \\\"declarationMap\\\": true,\\n \\\"sourceMap\\\": true,\\n \\\"downlevelIteration\\\": true\\n },\\n \\\"include\\\": [\\\"src/**/*\\\"],\\n \\\"exclude\\\": [\\\"node_modules\\\", \\\"dist\\\", \\\"**/*.test.ts\\\"]\\n}\", \"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\tsconfig.json\"}", - "id": "toolu_vrtx_01Km7ureNdH5MwEx7rpmYCre__vscode-1748915937113" - } - ], - "toolInputRetry": 0, - "id": "1f8299c8-144e-4f91-a4ea-d62eff6f4ec7" - }, - { - "response": "Let me check the existing tsconfig.json and then continue fixing the BacktestEngine.ts file by addressing the remaining issues: ", - "toolCalls": [ - { - "name": "replace_string_in_file", - "arguments": "{\"filePath\": \"g:\\\\repos\\\\stock-bot\\\\apps\\\\intelligence-services\\\\backtest-engine\\\\src\\\\core\\\\BacktestEngine.ts\", \"newString\": \" async run(): Promise {\\n if (this.isRunning) {\\n throw new Error('Backtest is already running');\\n }\\n\\n this.isRunning = true;\\n this.startTime = Date.now();\\n this.emit('started', { strategyId: this.strategy.id, config: this.config });\\n\\n try {\\n await this.runEventBased();\\n const result = this.generateResults();\\n this.emit('completed', { strategyId: this.strategy.id, result });\\n this.isRunning = false;\\n return result;\\n } catch (error) {\\n this.isRunning = false;\\n this.emit('error', { strategyId: this.strategy.id, error });\\n throw error;\\n }\\n }\", \"oldString\": \" async run(): Promise {\\n if (this.isRunning) {\\n throw new Error('Backtest is already running');\\n }\\n\\n this.isRunning = true;\\n this.startTime = Date.now();\\n this.emit('started', { strategyId: this.strategy.id, config: this.config });\\n\\n try {\\n // Load data based on configured mode\\n if (this.config.mode === 'event') {\\n await this.runEventBased();\\n } else {\\n await this.runVectorized();\\n }\\n\\n const result = this.generateResults();\\n this.emit('completed', { strategyId: this.strategy.id, result });\\n this.isRunning = false;\\n return result;\\n } catch (error) {\\n this.isRunning = false;\\n this.emit('error', { strategyId: this.strategy.id, error });\\n throw error;\\n }\\n }\"}", - "id": "toolu_vrtx_01XyVZbRQw16Z5rrtM5YeVvB__vscode-1748915937114" - } - ], - "toolInputRetry": 1, - "id": "7ad96c24-3193-4434-8733-6434c72e0a19" - }, - { - "response": "", - "toolCalls": [], - "toolInputRetry": 0, - "id": "437691a6-6194-4eba-89c8-be81eea1311d" - } - ], - "toolCallResults": { - "toolu_vrtx_01Fw8SFDySQgWVfqEtxnuqpv__vscode-1748915937096": { - "$mid": 20, - "content": [ - { - "$mid": 21, - "value": "ERROR while calling tool: File already exists. You must use an edit tool to modify it.\nPlease check your input and try again." - } - ] - }, - "toolu_vrtx_01E8DwHCj6RwwvKdCmvmPPAF__vscode-1748915937097": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "mm", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "String replacement failed: Failed to edit file: File already exists. Please provide a non-empty old_string for replacement.", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01JX6gZkc5ttXkP9qKBCdmiT__vscode-1748915937098": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Lines ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "0", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " to ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "10", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " (", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "605", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " lines total):", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 14, - "text": "```typescript\n", - "references": [ - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - ], - "lineBreakBefore": true - } - ], - "props": { - "priority": 14 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 13, - "text": "// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 13 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 12, - "text": "import { EventEmitter } from 'events';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 12 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 11, - "text": "import { BaseStrategy } from '../Strategy';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 11 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 10, - "text": "import { BarData, Order, Position } from '../Strategy';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 10 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 9 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 8, - "text": "export interface BacktestConfig {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 8 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 7, - "text": " startDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 7 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 6, - "text": " endDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 6 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 5, - "text": " symbols: string[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 4, - "text": " initialCapital: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 4 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 3, - "text": " commission: number; // Per trade commission (percentage)\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 3 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 2, - "text": " slippage: number; // Slippage model (percentage)\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 2 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 14, - "text": "```", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 14 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_01D3eZEja6q8NGsYNSrBsaAy__vscode-1748915937099": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "mm", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Applying the proposed edit resulted in the following diagnostics:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "vk", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 975 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "Ay", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\nimport { BaseStrategy } from '../Strategy';\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 976 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Module '\"@stock-bot/shared-types\"' has no exported member 'BarData'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 976 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private config: BacktestConfig;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 977 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Cannot find name 'BaseStrategy'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 977 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const totalShares = existingPosition.quantity + order.quantity;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 978 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 978 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const totalCost = (existingPosition.quantity * existingPosition.avgPrice) + (order.quantity * fillPrice);\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 979 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 979 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n quantity: order.quantity,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 980 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'avgPrice' does not exist in type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 980 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Calculate P&L\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 981 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 981 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n symbol: order.symbol,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 982 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'entryTime' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 982 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n entryTime: position.entryTime,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 983 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 983 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n pnl: pnl,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 984 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 984 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n order.status = 'FILLED';\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 985 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillPrice' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 985 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n order.fillPrice = fillPrice;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 986 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillTime' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 986 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const currentPrice = currentBar.close;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 987 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 987 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Add the current value of all positions\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 988 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, Position]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 988 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private async closeAllPositions(): Promise {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 989 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, Position]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 989 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 975 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01RRDeqBZH8MtJateAEwocFT__vscode-1748915937100": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Lines ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "0", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " to ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "50", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " (", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "205", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " lines total):", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 54, - "text": "```typescript\n", - "references": [ - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\packages\\shared-types\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts", - "path": "/g:/repos/stock-bot/packages/shared-types/src/index.ts", - "scheme": "file" - } - } - ], - "lineBreakBefore": true - } - ], - "props": { - "priority": 54 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 53, - "text": "// filepath: g:\\repos\\stock-bot\\packages\\shared-types\\src\\index.ts\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 53 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 52, - "text": "// Market Data Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 52 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 51, - "text": "export interface OHLCV {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 51 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 50, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 50 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 49, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 49 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 48, - "text": " open: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 48 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 47, - "text": " high: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 47 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 46, - "text": " low: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 46 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 45, - "text": " close: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 45 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 44, - "text": " volume: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 44 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 43, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 43 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 42, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 42 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 41, - "text": "export interface MarketData {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 41 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 40, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 40 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 39, - "text": " price: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 39 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 38, - "text": " bid: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 38 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 37, - "text": " ask: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 37 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 36, - "text": " volume: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 36 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 35, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 35 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 34, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 34 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 33, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 33 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 32, - "text": "export interface OrderBook {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 32 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 31, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 31 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 30, - "text": " bids: [number, number][]; // [price, size]\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 30 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 29, - "text": " asks: [number, number][]; // [price, size]\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 29 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 28, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 28 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 27, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 27 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 26, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 26 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 25, - "text": "// Trading Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 25 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 24, - "text": "export type OrderSide = 'BUY' | 'SELL';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 24 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 23, - "text": "export type OrderType = 'MARKET' | 'LIMIT' | 'STOP' | 'STOP_LIMIT';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 23 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 22, - "text": "export type OrderStatus = 'PENDING' | 'FILLED' | 'PARTIALLY_FILLED' | 'CANCELLED' | 'REJECTED';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 22 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 21, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 21 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 20, - "text": "export interface Order {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 20 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 19, - "text": " id: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 19 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 18, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 18 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 17, - "text": " side: OrderSide;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 17 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 16, - "text": " type: OrderType;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 16 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 15, - "text": " quantity: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 15 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 14, - "text": " price?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 14 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 13, - "text": " stopPrice?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 13 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 12, - "text": " status: OrderStatus;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 12 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 11, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 11 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 10, - "text": " strategyId: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 10 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 9 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 8, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 8 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 7, - "text": "export interface Position {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 7 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 6, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 6 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 5, - "text": " quantity: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 4, - "text": " averagePrice: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 4 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 3, - "text": " marketValue: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 3 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 2, - "text": " unrealizedPnL: number;\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 2 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 54, - "text": "```", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 54 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01Xud8bZYFkcXZ3gTpe7K8BS__vscode-1748915937101": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "mm", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Applying the proposed edit resulted in the following diagnostics:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "vk", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1077 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "Ay", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private previousPortfolioValue: number;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1078 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Cannot find name 'BaseStrategy'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1078 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n this.isRunning = true;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1079 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Cannot find name 'BaseStrategy'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1079 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Process each order\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1080 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, BarData[]]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1080 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Not enough shares to sell\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1081 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1081 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n order.status = 'REJECTED';\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1082 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1082 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n exitPrice: fillPrice,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1083 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1083 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n this.breakEvenTrades++;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1084 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'entryTime' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1084 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n }\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1085 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1085 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n order.status = 'FILLED';\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1086 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1086 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n }\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1087 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillPrice' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1087 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const dailyReturn = (portfolioValue - this.previousPortfolioValue) / this.previousPortfolioValue;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1088 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, Position]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1088 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n entryTime: position.entryTime,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1089 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, Position]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1089 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1077 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01Hf58S3fB8hVKm5pYBemJGr__vscode-1748915937102": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "vk", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1201 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "Ay", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private strategy: BaseStrategy;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1202 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Cannot find name 'BaseStrategy'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1202 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n constructor(strategy: BaseStrategy, config: BacktestConfig, dataFeed: DataFeed) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1203 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Cannot find name 'BaseStrategy'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1203 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n for (const [symbol, bars] of this.marketData.entries()) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1204 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, BarData[]]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1204 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const totalCost = (existingPosition.quantity * existingPosition.avgPrice) + (order.quantity * fillPrice);\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1205 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1205 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n existingPosition.avgPrice = totalCost / totalShares;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1206 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1206 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n avgPrice: fillPrice,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1207 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'avgPrice' does not exist in type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1207 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const pnl = (fillPrice - position.avgPrice) * order.quantity;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1208 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1208 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n entryTime: position.entryTime,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1209 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'entryTime' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1209 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n entryPrice: position.avgPrice,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1210 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1210 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n pnlPercent: (pnl / (position.avgPrice * order.quantity)) * 100\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1211 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1211 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n order.fillPrice = fillPrice;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1212 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillPrice' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1212 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n order.fillTime = this.currentTime;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1213 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillTime' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1213 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const unrealizedPnL = (currentPrice - position.avgPrice) * position.quantity;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1214 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1214 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n for (const [symbol, position] of this.positions.entries()) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1215 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, Position]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1215 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n for (const [symbol, position] of this.positions.entries()) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1216 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, Position]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1216 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1201 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01AJsV3pNTFUAXYAYgKb7i5z__vscode-1748915937103": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Lines ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "0", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " to ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "100", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " (", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "205", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " lines total):", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 104, - "text": "```typescript\n", - "references": [ - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\packages\\shared-types\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts", - "path": "/g:/repos/stock-bot/packages/shared-types/src/index.ts", - "scheme": "file" - } - } - ], - "lineBreakBefore": true - } - ], - "props": { - "priority": 104 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 103, - "text": "// filepath: g:\\repos\\stock-bot\\packages\\shared-types\\src\\index.ts\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 103 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 102, - "text": "// Market Data Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 102 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 101, - "text": "export interface OHLCV {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 101 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 99, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 99 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 98, - "text": " open: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 98 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 97, - "text": " high: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 97 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 96, - "text": " low: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 96 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 95, - "text": " close: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 95 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 94, - "text": " volume: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 94 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 93, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 93 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 92, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 92 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 91, - "text": "export interface MarketData {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 91 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 90, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 90 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 89, - "text": " price: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 89 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 88, - "text": " bid: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 88 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 87, - "text": " ask: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 87 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 86, - "text": " volume: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 86 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 85, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 85 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 84, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 84 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 83, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 83 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 82, - "text": "export interface OrderBook {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 82 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 81, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 81 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 80, - "text": " bids: [number, number][]; // [price, size]\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 80 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 79, - "text": " asks: [number, number][]; // [price, size]\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 79 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 78, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 78 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 77, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 77 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 76, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 76 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 75, - "text": "// Trading Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 75 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 74, - "text": "export type OrderSide = 'BUY' | 'SELL';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 74 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 73, - "text": "export type OrderType = 'MARKET' | 'LIMIT' | 'STOP' | 'STOP_LIMIT';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 73 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 72, - "text": "export type OrderStatus = 'PENDING' | 'FILLED' | 'PARTIALLY_FILLED' | 'CANCELLED' | 'REJECTED';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 72 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 71, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 71 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 70, - "text": "export interface Order {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 70 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 69, - "text": " id: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 69 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 68, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 68 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 67, - "text": " side: OrderSide;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 67 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 66, - "text": " type: OrderType;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 66 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 65, - "text": " quantity: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 65 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 64, - "text": " price?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 64 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 63, - "text": " stopPrice?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 63 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 62, - "text": " status: OrderStatus;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 62 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 61, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 61 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 60, - "text": " strategyId: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 60 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 59, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 59 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 58, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 58 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 57, - "text": "export interface Position {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 57 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 56, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 56 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 55, - "text": " quantity: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 55 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 54, - "text": " averagePrice: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 54 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 53, - "text": " marketValue: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 53 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 52, - "text": " unrealizedPnL: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 52 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 51, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 51 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 50, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 50 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 49, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 49 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 48, - "text": "export interface Portfolio {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 48 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 47, - "text": " cash: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 47 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 46, - "text": " totalValue: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 46 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 45, - "text": " positions: Position[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 45 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 44, - "text": " dayPnL: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 44 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 43, - "text": " totalPnL: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 43 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 42, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 42 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 41, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 41 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 40, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 40 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 39, - "text": "// Strategy Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 39 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 38, - "text": "export type SignalType = 'BUY' | 'SELL' | 'HOLD';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 38 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 37, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 37 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 36, - "text": "export interface TradingSignal {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 36 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 35, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 35 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 34, - "text": " type: SignalType;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 34 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 33, - "text": " strength: number; // 0-1\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 33 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 32, - "text": " price: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 32 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 31, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 31 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 30, - "text": " strategyId: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 30 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 29, - "text": " metadata?: Record;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 29 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 28, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 28 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 27, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 27 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 26, - "text": "export interface Strategy {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 26 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 25, - "text": " id: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 25 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 24, - "text": " name: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 24 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 23, - "text": " description: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 23 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 22, - "text": " isActive: boolean;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 22 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 21, - "text": " riskLimits: RiskLimits;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 21 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 20, - "text": " parameters: Record;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 20 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 19, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 19 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 18, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 18 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 17, - "text": "export interface RiskLimits {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 17 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 16, - "text": " maxPositionSize: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 16 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 15, - "text": " maxDailyLoss: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 15 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 14, - "text": " maxDrawdown: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 14 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 13, - "text": " allowedSymbols?: string[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 13 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 12, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 12 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 11, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 11 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 10, - "text": "// Event Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 10 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9, - "text": "export interface MarketDataEvent {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 9 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 8, - "text": " type: 'MARKET_DATA';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 8 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 7, - "text": " data: MarketData;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 7 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 6, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 6 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 5, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 4, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 4 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 3, - "text": "export interface OrderEvent {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 3 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 2, - "text": " type: 'ORDER_CREATED' | 'ORDER_FILLED' | 'ORDER_CANCELLED';\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 2 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 104, - "text": "```", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 104 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01CaUrn4rEBSrdzoDY5wqdbm__vscode-1748915937104": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Lines ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "100", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " to ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "204", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " (", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "205", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " lines total):", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 107, - "text": "```typescript\n", - "references": [ - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\packages\\shared-types\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/packages/shared-types/src/index.ts", - "path": "/g:/repos/stock-bot/packages/shared-types/src/index.ts", - "scheme": "file" - } - } - ], - "lineBreakBefore": true - } - ], - "props": { - "priority": 107 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 106, - "text": "// filepath: g:\\repos\\stock-bot\\packages\\shared-types\\src\\index.ts\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 106 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 105, - "text": "type: 'ORDER_CREATED' | 'ORDER_FILLED' | 'ORDER_CANCELLED';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 105 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 104, - "text": " order: Order;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 104 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 103, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 103 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 102, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 102 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 101, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 101 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100, - "text": "export interface SignalEvent {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 99, - "text": " type: 'SIGNAL_GENERATED';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 99 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 98, - "text": " signal: TradingSignal;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 98 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 97, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 97 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 96, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 96 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 95, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 95 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 94, - "text": "export type TradingEvent = MarketDataEvent | OrderEvent | SignalEvent;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 94 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 93, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 93 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 92, - "text": "// Service Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 92 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 91, - "text": "export interface ServiceConfig {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 91 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 90, - "text": " name: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 90 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 89, - "text": " version: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 89 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 88, - "text": " environment: 'development' | 'staging' | 'production';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 88 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 87, - "text": " port?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 87 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 86, - "text": " dependencies?: string[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 86 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 85, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 85 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 84, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 84 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 83, - "text": "export interface HealthStatus {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 83 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 82, - "text": " service: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 82 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 81, - "text": " status: 'healthy' | 'unhealthy' | 'degraded';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 81 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 80, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 80 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 79, - "text": " details?: Record;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 79 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 78, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 78 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 77, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 77 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 76, - "text": "// API Response Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 76 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 75, - "text": "export interface ApiResponse {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 75 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 74, - "text": " success: boolean;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 74 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 73, - "text": " data?: T;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 73 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 72, - "text": " error?: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 72 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 71, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 71 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 70, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 70 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 69, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 69 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 68, - "text": "export interface PaginatedResponse {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 68 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 67, - "text": " data: T[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 67 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 66, - "text": " total: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 66 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 65, - "text": " page: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 65 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 64, - "text": " limit: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 64 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 63, - "text": " hasNext: boolean;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 63 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 62, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 62 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 61, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 61 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 60, - "text": "// Fundamental Data Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 60 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 59, - "text": "export interface CompanyFundamentals {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 59 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 58, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 58 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 57, - "text": " marketCap: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 57 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 56, - "text": " peRatio?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 56 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 55, - "text": " pbRatio?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 55 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 54, - "text": " roe?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 54 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 53, - "text": " revenue: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 53 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 52, - "text": " netIncome: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 52 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 51, - "text": " lastUpdated: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 51 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 50, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 50 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 49, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 49 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 48, - "text": "export interface NewsItem {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 48 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 47, - "text": " id: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 47 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 46, - "text": " headline: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 46 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 45, - "text": " summary: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 45 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 44, - "text": " sentiment: number; // -1 to 1\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 44 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 43, - "text": " symbols: string[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 43 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 42, - "text": " source: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 42 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 41, - "text": " publishedAt: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 41 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 40, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 40 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 39, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 39 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 38, - "text": "// Configuration Types\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 38 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 37, - "text": "export interface DatabaseConfig {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 37 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 36, - "text": " questdb: {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 36 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 35, - "text": " host: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 35 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 34, - "text": " port: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 34 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 33, - "text": " database: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 33 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 32, - "text": " };\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 32 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 31, - "text": " postgres: {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 31 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 30, - "text": " host: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 30 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 29, - "text": " port: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 29 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 28, - "text": " database: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 28 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 27, - "text": " username: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 27 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 26, - "text": " password: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 26 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 25, - "text": " }; dragonfly: {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 25 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 24, - "text": " host: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 24 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 23, - "text": " port: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 23 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 22, - "text": " password?: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 22 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 21, - "text": " };\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 21 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 20, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 20 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 19, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 19 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 18, - "text": "export interface BrokerConfig {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 18 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 17, - "text": " name: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 17 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 16, - "text": " apiKey: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 16 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 15, - "text": " secretKey: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 15 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 14, - "text": " baseUrl: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 14 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 13, - "text": " sandbox: boolean;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 13 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 12, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 12 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 11, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 11 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 10, - "text": "export interface DataProviderConfig {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 10 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9, - "text": " name: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 9 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 8, - "text": " apiKey: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 8 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 7, - "text": " baseUrl: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 7 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 6, - "text": " rateLimits: {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 6 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 5, - "text": " requestsPerSecond: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 4, - "text": " requestsPerDay: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 4 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 3, - "text": " };\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 3 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 2, - "text": "}\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 2 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 107, - "text": "```", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 107 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01NhenMMWbqeQoXs7MCA2tMq__vscode-1748915937105": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "e6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "JSe", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "x1", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "$T", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "dP", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 0:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\nimport { EventEmitter } from 'events';\nimport { BaseStrategy } from '../Strategy';\nimport { BarData, Order, Position } from '../Strategy';\n\nexport interface BacktestConfig {\n /*...*/\n}\n\nexport interface BacktestResult {\n /*...*/\n}\n\nexport interface BacktestProgress {\n /*...*/\n}\n\nexport interface DataFeed {\n /*...*/\n}\n\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.01282051282051, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 63:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n private config: BacktestConfig;\n private strategy: BaseStrategy;\n private dataFeed: DataFeed;\n private isRunning: boolean = false;\n private barBuffer: Map = new Map();\n private pendingOrders: Order[] = [];\n private filledOrders: Order[] = [];\n private currentTime: Date;\n private startTime: number = 0; // For performance tracking\n private processedBars: number = 0;\n private marketData: Map = new Map();\n\n // Results tracking\n private initialCapital: number;\n private currentCapital: number;\n private positions = new Map();\n private trades: BacktestResult['trades'] = [];\n private dailyReturns: BacktestResult['dailyReturns'] = [];\n private previousPortfolioValue: number;\n private highWaterMark: number;\n private maxDrawdown: number = 0;\n private drawdownStartTime: Date | null = null;\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.01282051282051 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.02564102564102, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts` starting at line 130:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\n/*...*/\n/**\n * Strategy Controller\n * \n * Handles HTTP requests related to strategy management, backtesting, and execution.\n */\nexport class StrategyController {\n /*...*/\n /**\n * Update an existing strategy\n */\n public updateStrategy(req: Request, res: Response): void {\n const { id } = req.params;\n const { name, description, symbols, parameters } = req.body;\n \n const strategy = this.strategyRegistry.getStrategyById(id);\n \n if (!strategy) {\n res.status(404).json({\n success: false,\n error: `Strategy with ID ${id} not found`\n });\n return;\n }\n \n // Update properties\n if (name !== undefined) strategy.name = name;\n if (description !== undefined) strategy.description = description;\n if (symbols !== undefined) (strategy as any).symbols = symbols; // Hack since symbols is readonly\n if (parameters !== undefined) strategy.parameters = parameters;\n \n res.json({\n success: true,\n /*...*/\n }\n /*...*/\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.02564102564102 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.03846153846153, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts` starting at line 122:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts\n/*...*/\n@Component({\n selector: 'app-strategies',\n standalone: true,\n imports: [\n CommonModule, \n MatCardModule, \n MatIconModule,\n MatButtonModule,\n MatTabsModule,\n MatTableModule,\n MatSortModule,\n MatPaginatorModule,\n MatDialogModule,\n MatMenuModule,\n MatChipsModule,\n MatProgressBarModule,\n FormsModule,\n ReactiveFormsModule,\n StrategyDetailsComponent\n ],\n templateUrl: './strategies.component.html',\n styleUrl: './strategies.component.css'\n})\nexport class StrategiesComponent implements OnInit {\n /*...*/\n toggleStrategyStatus(strategy: TradingStrategy): void {\n this.isLoading = true;\n \n if (strategy.status === 'ACTIVE') {\n this.strategyService.pauseStrategy(strategy.id).subscribe({\n next: () => this.loadStrategies(),\n error: (error) => {\n console.error('Error pausing strategy:', error);\n this.isLoading = false;\n }\n });\n } else {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.03846153846153 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.05128205128206, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts` starting at line 83:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts\n/*...*/\n/**\n * Strategy Registry\n * \n * Manages and creates strategy instances based on strategy type.\n * Allows dynamic registration of new strategy types.\n */\nexport class StrategyRegistry {\n /*...*/\n description: string,\n symbols: string[],\n parameters: StrategyParameters = {}\n ): BaseStrategy {\n /*...*/\n }\n \n /**\n * Get default parameters for a strategy type\n */\n public getDefaultParameters(type: StrategyType): StrategyParameters {\n /*...*/\n }\n \n /**\n * Get all registered strategy types\n */\n public getStrategyTypes(): StrategyType[] {\n /*...*/\n }\n \n /**\n * Check if a strategy type is registered\n */\n public hasStrategyType(type: StrategyType): boolean {\n /*...*/\n }\n \n // Store created strategies for management\n private strategies: Map = new Map();\n \n /**\n * Store strategy instance for later retrieval\n * Used when creating strategies through registry\n */\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.05128205128206 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.06410256410257, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts` starting at line 0:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts\nimport { BaseStrategy, StrategyParameters } from '../Strategy';\nimport { MovingAverageCrossover, MovingAverageCrossoverParams } from './MovingAverageCrossover';\nimport { MeanReversionStrategy, MeanReversionParams } from './MeanReversionStrategy';\n\n// Define the strategy types\nexport type StrategyType = 'MOVING_AVERAGE_CROSSOVER' | 'MEAN_REVERSION' | 'CUSTOM';\n\n// Strategy factory function type\nexport type StrategyFactory = (\n id: string,\n name: string,\n description: string,\n symbols: string[],\n parameters: StrategyParameters\n) => BaseStrategy;\n\n/**\n * Strategy Registry\n * \n * Manages and creates strategy instances based on strategy type.\n * Allows dynamic registration of new strategy types.\n */\nexport class StrategyRegistry {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.06410256410257 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.07692307692308, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\ARCHITECTURE.md` starting at line 199:\n````md\n// filepath: g:\\repos\\stock-bot\\ARCHITECTURE.md\n# 🏗️ Stock Bot Trading System - Architecture Documentation\n...\n## 🔧 Service Breakdown\n...\n### **2. Core Services**\n...\n#### **Strategy Orchestrator** (`apps/intelligence-services/strategy-orchestrator`)\n...\n│ │ └── TechnicalIndicators.ts # Technical analysis\n│ ├── controllers/\n│ │ └── StrategyController.ts # API endpoints\n│ └── index.ts # Main entry point\n```\n\n**API Endpoints:**\n```\nGET /health # Health check\nGET /api/strategies # List strategies\nPOST /api/strategies # Create strategy\nPUT /api/strategies/:id # Update strategy\nPOST /api/strategies/:id/:action # Start/stop/pause strategy\nGET /api/strategies/:id/signals # Get strategy signals\nPOST /api/strategies/:id/backtest # Run backtest\nGET /api/strategies/:id/performance # Get performance metrics\nWS /ws # WebSocket for strategy updates\n```\n...\n````\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.07692307692308 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.08974358974359, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts` starting at line 142:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts\n/*...*/\n@Component({\n selector: 'app-strategies',\n standalone: true,\n imports: [\n CommonModule, \n MatCardModule, \n MatIconModule,\n MatButtonModule,\n MatTabsModule,\n MatTableModule,\n MatSortModule,\n MatPaginatorModule,\n MatDialogModule,\n MatMenuModule,\n MatChipsModule,\n MatProgressBarModule,\n FormsModule,\n ReactiveFormsModule,\n StrategyDetailsComponent\n ],\n templateUrl: './strategies.component.html',\n styleUrl: './strategies.component.css'\n})\nexport class StrategiesComponent implements OnInit {\n /*...*/\n }\n \n viewStrategyDetails(strategy: TradingStrategy): void {\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.08974358974359 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.1025641025641, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts` starting at line 26:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts\n/*...*/\n/**\n * Strategy Registry\n * \n * Manages and creates strategy instances based on strategy type.\n * Allows dynamic registration of new strategy types.\n */\nexport class StrategyRegistry {\n /*...*/\n /**\n * Get the singleton instance of StrategyRegistry\n */\n public static getInstance(): StrategyRegistry {\n if (!StrategyRegistry.instance) {\n StrategyRegistry.instance = new StrategyRegistry();\n }\n return StrategyRegistry.instance;\n }\n \n /**\n * Private constructor to enforce singleton pattern\n */\n private constructor() {\n this.registerBuiltInStrategies();\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.1025641025641 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.11538461538461, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts` starting at line 187:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\n/*...*/\n/**\n * Strategy Controller\n * \n * Handles HTTP requests related to strategy management, backtesting, and execution.\n */\nexport class StrategyController {\n /*...*/\n /**\n * Run a backtest\n */\n public async runBacktest(req: Request, res: Response): Promise {\n try {\n const backtestRequest: BacktestRequest = req.body;\n \n // Validate request\n if (!backtestRequest.strategyType) {\n res.status(400).json({\n success: false,\n error: 'Strategy type is required'\n });\n return;\n }\n \n if (!backtestRequest.symbols || backtestRequest.symbols.length === 0) {\n res.status(400).json({\n success: false,\n error: 'At least one symbol is required'\n });\n return;\n }\n \n // Run the backtest\n const result = await this.backtestService.runBacktest(backtestRequest);\n \n // Enhance results with additional metrics\n /*...*/\n }\n /*...*/\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.11538461538461 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.12820512820512, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts` starting at line 185:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts\n/*...*/\n@Component({\n selector: 'app-strategy-details',\n standalone: true,\n imports: [\n CommonModule,\n MatCardModule,\n MatTabsModule, \n MatIconModule,\n MatButtonModule,\n MatTableModule,\n MatChipsModule,\n MatProgressBarModule,\n MatDividerModule,\n EquityChartComponent,\n DrawdownChartComponent,\n TradesTableComponent,\n PerformanceMetricsComponent\n ],\n templateUrl: './strategy-details.component.html',\n styleUrl: './strategy-details.component.css'\n})\nexport class StrategyDetailsComponent implements OnChanges {\n /*...*/\n /**\n * Update performance metrics when new trades come in\n */\n private updatePerformanceMetrics(): void {\n if (!this.strategy || this.trades.length === 0) return;\n \n // Calculate basic metrics\n const winningTrades = this.trades.filter(t => t.pnl > 0);\n const losingTrades = this.trades.filter(t => t.pnl < 0);\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.12820512820512 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.14102564102564, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts` starting at line 23:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts\n/*...*/\n/**\n * Strategy Registry\n * \n * Manages and creates strategy instances based on strategy type.\n * Allows dynamic registration of new strategy types.\n */\nexport class StrategyRegistry {\n private static instance: StrategyRegistry;\n private factories: Map = new Map();\n \n /**\n * Get the singleton instance of StrategyRegistry\n */\n public static getInstance(): StrategyRegistry {\n /*...*/\n }\n \n /**\n * Private constructor to enforce singleton pattern\n */\n private constructor() {\n /*...*/\n }\n \n /**\n * Register built-in strategies\n */\n private registerBuiltInStrategies(): void {\n /*...*/\n }\n \n /**\n * Register a new strategy type with factory function\n */\n public registerStrategy(type: StrategyType, factory: StrategyFactory): void {\n /*...*/\n }\n /**\n * Create a strategy instance based on type and parameters\n */\n public createStrategy(\n type: StrategyType,\n id: string,\n name: string,\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.14102564102564 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.15384615384616, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 347:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Convert data resolution to polling interval\n */\n private getPollingIntervalFromResolution(resolution: string): number {\n /*...*/\n case '1d': return 24 * 60 * 60 * 1000; // 1 day\n default: return 60 * 1000; // Default to 1 minute\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.15384615384616 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.16666666666667, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts` starting at line 211:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\n/*...*/\n/**\n * Strategy Controller\n * \n * Handles HTTP requests related to strategy management, backtesting, and execution.\n */\nexport class StrategyController {\n /*...*/\n /**\n * Run a backtest\n */\n public async runBacktest(req: Request, res: Response): Promise {\n /*...*/\n const enhancedResult = PerformanceAnalytics.enhanceResults(result);\n \n // Calculate additional analytics\n const monthlyReturns = PerformanceAnalytics.calculateMonthlyReturns(result.dailyReturns);\n const drawdowns = PerformanceAnalytics.analyzeDrawdowns(result.dailyReturns);\n \n res.json({\n success: true,\n data: {\n ...enhancedResult,\n monthlyReturns,\n drawdowns\n }\n });\n } catch (error) {\n console.error('Backtest error:', error);\n res.status(500).json({\n success: false,\n error: (error as Error).message\n });\n }\n }\n /*...*/\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.16666666666667 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.17948717948718, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts` starting at line 308:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts\n/*...*/\n@Component({\n selector: 'app-strategy-details',\n standalone: true,\n imports: [\n CommonModule,\n MatCardModule,\n MatTabsModule, \n MatIconModule,\n MatButtonModule,\n MatTableModule,\n MatChipsModule,\n MatProgressBarModule,\n MatDividerModule,\n EquityChartComponent,\n DrawdownChartComponent,\n TradesTableComponent,\n PerformanceMetricsComponent\n ],\n templateUrl: './strategy-details.component.html',\n styleUrl: './strategy-details.component.css'\n})\nexport class StrategyDetailsComponent implements OnChanges {\n /*...*/\n /**\n * Stop the strategy\n */\n stopStrategy(): void {\n if (!this.strategy) return;\n \n this.strategyService.stopStrategy(this.strategy.id).subscribe({\n next: (response) => {\n if (response.success) {\n this.strategy!.status = 'INACTIVE';\n }\n },\n error: (error) => {\n console.error('Error stopping strategy:', error);\n }\n });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.17948717948718 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.1923076923077, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts` starting at line 168:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts\n/*...*/\n/**\n * Strategy Registry\n * \n * Manages and creates strategy instances based on strategy type.\n * Allows dynamic registration of new strategy types.\n */\nexport class StrategyRegistry {\n /*...*/\n /**\n * Get a strategy by ID\n */\n public getStrategyById(id: string): BaseStrategy | undefined {\n return this.strategies.get(id);\n }\n \n /**\n * Delete a strategy by ID\n */\n public deleteStrategy(id: string): boolean {\n return this.strategies.delete(id);\n }\n \n /**\n * Get the type of a strategy instance\n */\n public getStrategyType(strategy: BaseStrategy): StrategyType {\n // Determine the type based on constructor\n if (strategy instanceof MovingAverageCrossover) {\n return 'MOVING_AVERAGE_CROSSOVER';\n } else if (strategy instanceof MeanReversionStrategy) {\n return 'MEAN_REVERSION';\n }\n \n // Default to CUSTOM if we can't determine\n return 'CUSTOM';\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.1923076923077 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.2051282051282, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 340:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Convert data resolution to polling interval\n */\n private getPollingIntervalFromResolution(resolution: string): number {\n switch (resolution) {\n case '1m': return 60 * 1000; // 60 seconds\n case '5m': return 5 * 60 * 1000; // 5 minutes\n case '15m': return 15 * 60 * 1000; // 15 minutes\n case '30m': return 30 * 60 * 1000; // 30 minutes\n case '1h': return 60 * 60 * 1000; // 1 hour\n case '4h': return 4 * 60 * 60 * 1000; // 4 hours\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.2051282051282 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.21794871794872, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts` starting at line 134:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts\n/*...*/\n@Component({\n selector: 'app-strategies',\n standalone: true,\n imports: [\n CommonModule, \n MatCardModule, \n MatIconModule,\n MatButtonModule,\n MatTabsModule,\n MatTableModule,\n MatSortModule,\n MatPaginatorModule,\n MatDialogModule,\n MatMenuModule,\n MatChipsModule,\n MatProgressBarModule,\n FormsModule,\n ReactiveFormsModule,\n StrategyDetailsComponent\n ],\n templateUrl: './strategies.component.html',\n styleUrl: './strategies.component.css'\n})\nexport class StrategiesComponent implements OnInit {\n /*...*/\n this.strategyService.startStrategy(strategy.id).subscribe({\n next: () => this.loadStrategies(),\n error: (error) => {\n console.error('Error starting strategy:', error);\n this.isLoading = false;\n }\n });\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.21794871794872 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.23076923076923, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts` starting at line 234:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\n/*...*/\n/**\n * Strategy Controller\n * \n * Handles HTTP requests related to strategy management, backtesting, and execution.\n */\nexport class StrategyController {\n /*...*/\n /**\n * Optimize a strategy with grid search\n */\n public async optimizeStrategy(req: Request, res: Response): Promise {\n try {\n const { baseRequest, parameterGrid } = req.body;\n \n // Validate request\n if (!baseRequest || !parameterGrid) {\n res.status(400).json({\n success: false,\n error: 'Base request and parameter grid are required'\n });\n return;\n }\n \n // Run optimization\n const results = await this.backtestService.optimizeStrategy(baseRequest, parameterGrid);\n \n res.json({\n success: true,\n data: results\n });\n } catch (error) {\n res.status(500).json({\n success: false,\n error: (error as Error).message\n });\n }\n }\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.23076923076923 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.24358974358974, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts` starting at line 76:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts\n/*...*/\n@Component({\n selector: 'app-strategies',\n standalone: true,\n imports: [\n CommonModule, \n MatCardModule, \n MatIconModule,\n MatButtonModule,\n MatTabsModule,\n MatTableModule,\n MatSortModule,\n MatPaginatorModule,\n MatDialogModule,\n MatMenuModule,\n MatChipsModule,\n MatProgressBarModule,\n FormsModule,\n ReactiveFormsModule,\n StrategyDetailsComponent\n ],\n templateUrl: './strategies.component.html',\n styleUrl: './strategies.component.css'\n})\nexport class StrategiesComponent implements OnInit {\n /*...*/\n listenForStrategyUpdates(): void {\n this.webSocketService.messages.subscribe(message => {\n if (message.type === 'STRATEGY_CREATED' || \n message.type === 'STRATEGY_UPDATED' || \n message.type === 'STRATEGY_STATUS_CHANGED') {\n // Refresh the strategy list when changes occur\n this.loadStrategies();\n }\n });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.24358974358974 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.25641025641026, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts` starting at line 157:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts\n/*...*/\n/**\n * Strategy Registry\n * \n * Manages and creates strategy instances based on strategy type.\n * Allows dynamic registration of new strategy types.\n */\nexport class StrategyRegistry {\n /*...*/\n private storeStrategy(strategy: BaseStrategy): void {\n /*...*/\n }\n \n /**\n * Get all registered strategies\n */\n public getAllStrategies(): BaseStrategy[] {\n /*...*/\n }\n \n /**\n * Get a strategy by ID\n */\n public getStrategyById(id: string): BaseStrategy | undefined {\n /*...*/\n }\n \n /**\n * Delete a strategy by ID\n */\n public deleteStrategy(id: string): boolean {\n /*...*/\n }\n \n /**\n * Get the type of a strategy instance\n */\n public getStrategyType(strategy: BaseStrategy): StrategyType {\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.25641025641026 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.26923076923077, - "text": "Here is the full text of `g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestService.ts`:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestService.ts\nimport { BaseStrategy } from '../Strategy';\nimport { BacktestConfig, BacktestEngine, BacktestResult } from './BacktestEngine';\nimport { MarketDataFeed } from './MarketDataFeed';\nimport { StrategyRegistry, StrategyType } from '../strategies/StrategyRegistry';\n\nexport interface BacktestRequest {\n /*...*/\n}\n\n/**\n * Backtesting Service\n * \n * A service that handles backtesting requests and manages backtesting sessions.\n */\nexport class BacktestService {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.26923076923077 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.28205128205128, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts` starting at line 272:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts\n/*...*/\n@Component({\n selector: 'app-strategy-details',\n standalone: true,\n imports: [\n CommonModule,\n MatCardModule,\n MatTabsModule, \n MatIconModule,\n MatButtonModule,\n MatTableModule,\n MatChipsModule,\n MatProgressBarModule,\n MatDividerModule,\n EquityChartComponent,\n DrawdownChartComponent,\n TradesTableComponent,\n PerformanceMetricsComponent\n ],\n templateUrl: './strategy-details.component.html',\n styleUrl: './strategy-details.component.css'\n})\nexport class StrategyDetailsComponent implements OnChanges {\n /*...*/\n /**\n * Start the strategy\n */\n activateStrategy(): void {\n if (!this.strategy) return;\n \n this.strategyService.startStrategy(this.strategy.id).subscribe({\n next: (response) => {\n if (response.success) {\n this.strategy!.status = 'ACTIVE';\n }\n },\n error: (error) => {\n console.error('Error starting strategy:', error);\n }\n });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.28205128205128 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.2948717948718, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts` starting at line 43:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts\n/*...*/\n/**\n * Strategy Registry\n * \n * Manages and creates strategy instances based on strategy type.\n * Allows dynamic registration of new strategy types.\n */\nexport class StrategyRegistry {\n /*...*/\n /**\n * Register built-in strategies\n */\n private registerBuiltInStrategies(): void {\n // Register Moving Average Crossover\n this.registerStrategy('MOVING_AVERAGE_CROSSOVER', (id, name, description, symbols, parameters) => {\n return new MovingAverageCrossover(\n id,\n name,\n description,\n symbols,\n parameters as MovingAverageCrossoverParams\n );\n });\n \n // Register Mean Reversion\n this.registerStrategy('MEAN_REVERSION', (id, name, description, symbols, parameters) => {\n return new MeanReversionStrategy(\n id,\n name,\n description,\n symbols,\n parameters as MeanReversionParams\n );\n });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.2948717948718 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.3076923076923, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts` starting at line 4:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts\n/*...*/\nexport interface TradingStrategy {\n id: string;\n name: string;\n description: string;\n status: 'ACTIVE' | 'INACTIVE' | 'PAUSED' | 'ERROR';\n type: string;\n symbols: string[];\n parameters: Record;\n performance: {\n totalTrades: number;\n winRate: number;\n totalReturn: number;\n sharpeRatio: number;\n maxDrawdown: number;\n };\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface BacktestRequest {\n strategyType: string;\n strategyParams: Record;\n symbols: string[];\n startDate: Date | string;\n endDate: Date | string;\n initialCapital: number;\n dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\n commission: number;\n slippage: number;\n mode: 'event' | 'vector';\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.3076923076923 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.32051282051282, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts` starting at line 12:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\n/*...*/\n/**\n * Strategy Controller\n * \n * Handles HTTP requests related to strategy management, backtesting, and execution.\n */\nexport class StrategyController {\n private readonly strategyRegistry: StrategyRegistry;\n private readonly backtestService: BacktestService;\n \n constructor(apiBaseUrl: string = 'http://localhost:3001/api') {\n /*...*/\n }\n \n /**\n * Get all available strategy types\n */\n public getStrategyTypes(req: Request, res: Response): void {\n /*...*/\n }\n \n /**\n * Get all strategies\n */\n public getStrategies(req: Request, res: Response): void {\n /*...*/\n }\n \n /**\n * Get a specific strategy by ID\n */\n public getStrategy(req: Request, res: Response): void {\n /*...*/\n }\n \n /**\n * Create a new strategy\n */\n public createStrategy(req: Request, res: Response): void {\n /*...*/\n }\n \n /**\n * Update an existing strategy\n */\n /*...*/\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.32051282051282 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.33333333333333, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 7:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\nexport interface ExecutionConfig {\n symbols: string[];\n dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\n realTrading: boolean;\n maxPositionValue: number;\n maxOrdersPerMinute: number;\n stopLossPercentage: number;\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.33333333333333 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.34615384615384, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\ARCHITECTURE.md` starting at line 166:\n````md\n// filepath: g:\\repos\\stock-bot\\ARCHITECTURE.md\n# 🏗️ Stock Bot Trading System - Architecture Documentation\n...\n## 🔧 Service Breakdown\n...\n### **2. Core Services**\n...\n#### **Strategy Orchestrator** (`apps/intelligence-services/strategy-orchestrator`)\n- **Framework**: Hono + Bun\n- **Port**: 4001\n- **Purpose**: Strategy lifecycle management and execution\n- **Database**: MongoDB (strategies), PostgreSQL (trades), Redis (signals)\n\n**Responsibilities:**\n- Strategy creation and management\n- Backtesting engine (vectorized & event-based)\n- Real-time strategy execution\n- Signal generation and broadcasting\n- Performance analytics\n- Strategy optimization\n\n**Current Structure:**\n```\nstrategy-orchestrator/\n├── src/\n│ ├── core/\n│ │ ├── backtesting/\n│ │ │ ├── BacktestEngine.ts # Main backtesting engine\n│ │ │ ├── BacktestService.ts # Backtesting service layer\n│ │ │ ├── MarketDataFeed.ts # Historical data provider\n...\n````\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.34615384615384 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.35897435897436, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 102:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Send a message to all connected WebSocket clients\n */\n private broadcastMessage(message: any): void {\n const messageStr = JSON.stringify(message);\n for (const client of this.wsClients) {\n if (client.readyState === WebSocket.OPEN) {\n client.send(messageStr);\n }\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.35897435897436 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.37179487179488, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 468:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Execute a trading signal\n */\n private executeSignal(strategyId: string, signal: any): void {\n // In a real implementation, this would connect to the order execution service\n // For now, just log the signal and broadcast a mock trade\n console.log(`Executing signal for strategy ${strategyId}:`, signal);\n \n const strategyData = this.activeStrategies.get(strategyId);\n if (!strategyData) return;\n \n const { strategy } = strategyData;\n \n // Broadcast mock trade execution\n this.broadcastMessage({\n type: 'strategy_trade',\n timestamp: new Date().toISOString(),\n data: {\n strategyId,\n name: strategy.name,\n symbol: signal.symbol,\n price: signal.price,\n action: signal.action,\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.37179487179488 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.38461538461539, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts` starting at line 162:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async runEventBased(): Promise {\n /*...*/\n // Send the new bar to the strategy\n const orders = await this.strategy.onBar(bar);\n \n // Add any new orders to the pending orders queue\n if (orders && orders.length > 0) {\n this.pendingOrders.push(...orders);\n }\n\n // Update progress periodically\n if (Date.now() - lastProgressUpdate > 1000) { // Update every second\n this.updateProgress(i / timeline.length);\n lastProgressUpdate = Date.now();\n }\n }\n\n // Process any remaining orders\n for (const order of this.pendingOrders) {\n await this.processOrder(order);\n }\n\n // Close any remaining positions at the last known price\n await this.closeAllPositions();\n\n // Clean up strategy\n await this.strategy.stop();\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.38461538461539 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.3974358974359, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts` starting at line 24:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts\n/*...*/\nconst backtestService = new BacktestService();\n\n// Strategy interfaces\ninterface TradingStrategy {\n /*...*/\n}\n\ninterface StrategySignal {\n /*...*/\n}\n\n// In-memory strategy registry (in production, this would be persisted)\nconst strategies = new Map();\n\n// Initialize strategy controller\nconst strategyController = new StrategyController();\n\n// Health check endpoint\napp.get('/health', (c) => {\n return c.json({ \n service: 'strategy-orchestrator',\n status: 'healthy',\n timestamp: new Date(),\n version: '1.0.0',\n activeStrategies: Array.from(strategies.values()).filter(s => s.status === 'ACTIVE').length,\n registeredStrategies: strategyRegistry.getAllStrategies().length,\n connections: wss.clients.size\n });\n});\n\n// API Routes\n// Strategy management endpoints\napp.get('/api/strategy-types', async (c) => {\n try {\n const types = Object.values(strategyRegistry.getStrategyTypes());\n return c.json({ success: true, data: types });\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.3974358974359 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.41025641025641, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts` starting at line 87:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts\n/*...*/\n@Injectable({\n providedIn: 'root'\n})\nexport class StrategyService {\n /*...*/\n constructor(private http: HttpClient) { }\n\n // Strategy Management\n getStrategies(): Observable> {\n return this.http.get>(`${this.apiBaseUrl}/strategies`);\n }\n\n getStrategy(id: string): Observable> {\n return this.http.get>(`${this.apiBaseUrl}/strategies/${id}`);\n }\n\n createStrategy(strategy: Partial): Observable> {\n return this.http.post>(`${this.apiBaseUrl}/strategies`, strategy);\n }\n\n updateStrategy(id: string, updates: Partial): Observable> {\n return this.http.put>(`${this.apiBaseUrl}/strategies/${id}`, updates);\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.41025641025641 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.42307692307692, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\MeanReversionStrategy.ts` starting at line 133:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\MeanReversionStrategy.ts\n/*...*/\n/**\n * Mean Reversion Strategy\n * \n * A vectorized strategy that trades mean reversion by detecting\n * overbought/oversold conditions and entering when price deviates\n * significantly from its moving average.\n */\nexport class MeanReversionStrategy extends VectorizedStrategy {\n /*...*/\n async onBar(bar: BarData): Promise {\n // Use the vectorized implementation from the base class\n return super.onBar(bar);\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.42307692307692 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.43589743589743, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts` starting at line 211:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts\n/*...*/\n }\n\n protected createStopOrder(\n symbol: string,\n side: 'BUY' | 'SELL',\n quantity: number,\n stopPrice: number\n ): Order {\n /*...*/\n }\n\n private generateOrderId(): string {\n /*...*/\n }\n\n // Utility methods for common strategy patterns\n protected getBarsSince(symbol: string, periods: number): BarData[] {\n /*...*/\n }\n\n protected getReturns(symbol: string, periods: number): number[] {\n /*...*/\n }\n\n protected getVolatility(symbol: string, periods: number): number {\n /*...*/\n }\n\n // Parameter validation\n protected validateParameters(): boolean {\n /*...*/\n }\n\n // Get strategy state for serialization\n getState() {\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.43589743589743 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.44871794871794, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts` starting at line 151:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\n/*...*/\n/**\n * Strategy Controller\n * \n * Handles HTTP requests related to strategy management, backtesting, and execution.\n */\nexport class StrategyController {\n /*...*/\n /**\n * Update an existing strategy\n */\n public updateStrategy(req: Request, res: Response): void {\n /*...*/\n data: {\n id: strategy.id,\n name: strategy.name,\n description: strategy.description,\n symbols: strategy.symbols,\n parameters: strategy.parameters,\n type: this.strategyRegistry.getStrategyType(strategy)\n }\n });\n }\n /*...*/\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.44871794871794 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.46153846153847, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts` starting at line 32:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts\n/*...*/\n protected indicators: Map; // 1 = BUY, 0 = NEUTRAL, -1 = SELL\n stopLevels: number[];\n profitLevels: number[];\n bollingerUpper?: number[];\n bollingerLower?: number[];\n }> = new Map();\n \n protected stopLossLevels: Map = new Map();\n protected takeProfitLevels: Map = new Map();\n \n constructor(\n id: string,\n name: string,\n description: string,\n symbols: string[],\n params: Partial = {}\n ) {\n /*...*/\n }\n \n async initialize(): Promise {\n /*...*/\n }\n \n /**\n * The main method that must be implemented by vectorized strategy subclasses.\n * It should compute signals based on price data in a vectorized manner.\n */\n protected abstract computeSignals(\n symbol: string,\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.46153846153847 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.47435897435898, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts` starting at line 88:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts\n/*...*/\n async onBar(bar: BarData): Promise {\n const symbol = bar.symbol;\n const params = this.parameters as VectorizedStrategyParams;\n \n // Update market data\n this.addBar(bar);\n \n // Get historical data\n const bars = this.context.marketData.get(symbol) || [];\n \n // If we don't have enough bars yet, wait\n if (bars.length < params.lookbackPeriod) {\n return [];\n }\n \n // Extract price and volume data\n const prices = TechnicalIndicators.extractPrice(bars, 'close');\n const volumes = bars.map(b => b.volume);\n \n // Update indicators cache\n const indicators = this.indicators.get(symbol)!;\n indicators.prices = prices;\n \n // Check for stop loss and take profit first\n const orders: Order[] = [];\n \n if (this.hasPosition(symbol)) {\n const position = this.getPosition(symbol)!;\n const currentPrice = bar.close;\n /*...*/\n }\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.47435897435898 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.48717948717949, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts` starting at line 106:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts\n/*...*/\n@Injectable({\n providedIn: 'root'\n})\nexport class StrategyService {\n /*...*/\n startStrategy(id: string): Observable> {\n return this.http.post>(`${this.apiBaseUrl}/strategies/${id}/start`, {});\n }\n\n stopStrategy(id: string): Observable> {\n return this.http.post>(`${this.apiBaseUrl}/strategies/${id}/stop`, {});\n }\n\n pauseStrategy(id: string): Observable> {\n return this.http.post>(`${this.apiBaseUrl}/strategies/${id}/pause`, {});\n }\n\n // Backtest Management\n getStrategyTypes(): Observable> {\n return this.http.get>(`${this.apiBaseUrl}/strategy-types`);\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.48717948717949 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.5, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 487:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Execute a trading signal\n */\n private executeSignal(strategyId: string, signal: any): void {\n /*...*/\n quantity: signal.quantity,\n executionTime: new Date().toISOString(),\n status: 'FILLED'\n }\n });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.51282051282051, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts` starting at line 62:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts\n/*...*/\n// Mock strategy for testing\nclass MockStrategy extends BaseStrategy {\n name = 'MockStrategy';\n description = 'A mock strategy for testing';\n symbols = ['AAPL', 'MSFT'];\n parameters = { param1: 1, param2: 2 };\n \n constructor(id: string) {\n super(id);\n }\n \n async start(): Promise {}\n \n async stop(): Promise {}\n \n onBar(bar: BarData) {\n // Return a mock signal\n return {\n action: 'BUY',\n symbol: bar.symbol,\n price: bar.close,\n quantity: 10,\n metadata: { reason: 'Test signal' }\n };\n }\n \n async onOrderFilled(order: Order): Promise {}\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.51282051282051 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.52564102564102, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts` starting at line 112:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts\n/*...*/\n async start(): Promise {\n /*...*/\n }\n\n async stop(): Promise {\n /*...*/\n }\n\n // Market data management\n addBar(bar: BarData): void {\n /*...*/\n }\n\n // Portfolio management helpers\n protected getCurrentPrice(symbol: string): number | null {\n /*...*/\n }\n\n protected getPosition(symbol: string): Position | null {\n /*...*/\n }\n\n protected hasPosition(symbol: string): boolean {\n /*...*/\n }\n\n protected getAvailableCash(): number {\n /*...*/\n }\n\n protected calculatePositionValue(symbol: string): number {\n /*...*/\n }\n\n protected updatePortfolioValue(): void {\n /*...*/\n }\n\n // Order creation helpers\n protected createMarketOrder(symbol: string, side: 'BUY' | 'SELL', quantity: number): Order {\n /*...*/\n }\n\n protected createLimitOrder(\n symbol: string,\n side: 'BUY' | 'SELL',\n quantity: number,\n price: number\n ): Order {\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.52564102564102 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.53846153846153, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts` starting at line 129:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts\n/*...*/\n/**\n * Strategy Controller\n * \n * Handles HTTP requests related to strategy management, backtesting, and execution.\n */\nexport class StrategyController {\n /*...*/\n public updateStrategy(req: Request, res: Response): void {\n /*...*/\n }\n \n /**\n * Delete a strategy\n */\n public deleteStrategy(req: Request, res: Response): void {\n /*...*/\n }\n \n /**\n * Run a backtest\n */\n public async runBacktest(req: Request, res: Response): Promise {\n /*...*/\n }\n \n /**\n * Optimize a strategy with grid search\n */\n public async optimizeStrategy(req: Request, res: Response): Promise {\n /*...*/\n }\n}\n/*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.53846153846153 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.55128205128206, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts` starting at line 178:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts\n/*...*/\nexport class BacktestEngine extends EventEmitter {\n /*...*/\n private async runEventBased(): Promise {\n /*...*/\n // Send the new bar to the strategy\n const orders = await this.strategy.onBar(bar);\n \n // Add any new orders to the pending orders queue\n if (orders && orders.length > 0) {\n this.pendingOrders.push(...orders);\n }\n\n // Update progress periodically\n if (Date.now() - lastProgressUpdate > 1000) { // Update every second\n this.updateProgress(i / timeline.length);\n lastProgressUpdate = Date.now();\n }\n }\n\n // Process any remaining orders\n for (const order of this.pendingOrders) {\n await this.processOrder(order);\n }\n\n // Close any remaining positions at the last known price\n await this.closeAllPositions();\n\n // Clean up strategy\n await this.strategy.stop();\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.55128205128206 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.56410256410257, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\ARCHITECTURE.md` starting at line 188:\n```md\n// filepath: g:\\repos\\stock-bot\\ARCHITECTURE.md\n# 🏗️ Stock Bot Trading System - Architecture Documentation\n...\n## 🔧 Service Breakdown\n...\n### **2. Core Services**\n...\n#### **Strategy Orchestrator** (`apps/intelligence-services/strategy-orchestrator`)\n...\n│ │ │ └── PerformanceAnalytics.ts # Performance metrics\n│ │ ├── execution/\n│ │ │ └── StrategyExecutionService.ts # Real-time execution\n│ │ ├── strategies/\n│ │ │ ├── Strategy.ts # Base strategy interface\n│ │ │ ├── StrategyRegistry.ts # Strategy management\n│ │ │ ├── BaseStrategy.ts # Abstract base class\n│ │ │ ├── VectorizedStrategy.ts # Vectorized base class\n│ │ │ ├── MovingAverageCrossover.ts # MA strategy\n│ │ │ └── MeanReversionStrategy.ts # Mean reversion\n│ │ └── indicators/\n...\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.56410256410257 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.57692307692308, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 114:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Send current status of all active strategies to a specific client\n */\n private sendAllStrategyStatus(ws: WebSocket): void {\n const statusList = Array.from(this.activeStrategies.entries()).map(([id, data]) => ({\n id,\n name: data.strategy.name,\n status: this.isRunning ? 'ACTIVE' : 'PAUSED',\n symbols: data.config.symbols,\n positions: Array.from(data.positions.entries()).map(([symbol, pos]) => ({\n symbol,\n quantity: pos.quantity,\n entryPrice: pos.entryPrice,\n currentValue: pos.currentValue\n }))\n }));\n \n ws.send(JSON.stringify({\n type: 'strategy_status_list',\n timestamp: new Date().toISOString(),\n data: statusList\n }));\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.57692307692308 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.58974358974359, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 494:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Close all connections when service is shut down\n */\n shutdown(): void {\n this.stop();\n \n if (this.webSocketServer) {\n for (const client of this.wsClients) {\n client.close();\n }\n this.wsClients.clear();\n \n this.webSocketServer.close(() => {\n console.log('WebSocket server closed');\n });\n }\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.58974358974359 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.6025641025641, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 223:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Start a specific strategy\n */\n startStrategy(strategyId: string, config?: ExecutionConfig): boolean {\n /*...*/\n console.log(`Strategy ${strategyId} started with ${executionConfig.symbols.length} symbols`);\n \n this.broadcastMessage({\n type: 'strategy_started',\n timestamp: new Date().toISOString(),\n data: {\n strategyId,\n name: strategy.name,\n symbols: executionConfig.symbols\n }\n });\n \n return true;\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.6025641025641 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.61538461538461, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 435:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Process a new bar with the strategy\n */ private processBar(strategyId: string, symbol: string, bar: BarData): void {\n /*...*/\n port: parseInt(process.env.REDIS_PORT || '6379')\n }) : null;\n \n if (redis) {\n // Store signal with TTL of 7 days\n redis.setex(\n `signal:${strategyId}:${signalObject.id}`,\n 60 * 60 * 24 * 7, // 7 days TTL\n JSON.stringify(signalObject)\n );\n }\n } catch (err) {\n console.error('Error storing signal in Redis:', err);\n }\n \n // Broadcast the signal\n this.broadcastMessage({\n type: 'strategy_signal',\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.61538461538461 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.62820512820512, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 281:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Pause a specific strategy\n */\n pauseStrategy(strategyId: string): boolean {\n if (!this.activeStrategies.has(strategyId)) {\n console.warn(`Strategy ${strategyId} is not active`);\n return false;\n }\n \n // Clear data polling interval for this strategy\n const intervalId = this.dataPollingIntervals.get(strategyId);\n if (intervalId) {\n clearInterval(intervalId);\n this.dataPollingIntervals.delete(strategyId);\n }\n \n const { strategy } = this.activeStrategies.get(strategyId)!;\n \n console.log(`Strategy ${strategyId} paused`);\n \n this.broadcastMessage({\n type: 'strategy_paused',\n timestamp: new Date().toISOString(),\n data: {\n strategyId,\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.62820512820512 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.64102564102564, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 71:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Initialize WebSocket server for real-time updates\n */\n private initializeWebSocketServer(port: number): void {\n /*...*/\n this.sendAllStrategyStatus(ws);\n });\n \n console.log(`WebSocket server started on port ${port}`);\n } catch (error) {\n console.error('Failed to initialize WebSocket server:', error);\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.64102564102564 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.65384615384616, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 80:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Handle incoming WebSocket messages\n */\n private handleWebSocketMessage(ws: WebSocket, message: any): void {\n switch (message.type) {\n case 'get_active_strategies':\n this.sendAllStrategyStatus(ws);\n break;\n case 'start_strategy':\n this.startStrategy(message.id, message.config);\n break;\n case 'stop_strategy':\n this.stopStrategy(message.id);\n break;\n case 'pause_strategy':\n this.pauseStrategy(message.id);\n break;\n default:\n console.warn(`Unknown WebSocket message type: ${message.type}`);\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.65384615384616 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.66666666666667, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 391:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Poll market data for a specific strategy\n */\n private async pollMarketData(strategyId: string): Promise {\n /*...*/\n }\n }\n }\n } catch (error) {\n console.error(`Error polling market data for strategy ${strategyId}:`, error);\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.66666666666667 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.67948717948718, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 159:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Stop the execution service (global)\n */\n stop(): void {\n if (!this.isRunning) return;\n \n this.isRunning = false;\n console.log('Strategy execution service stopped');\n \n // Clear all data polling intervals\n for (const interval of this.dataPollingIntervals.values()) {\n clearInterval(interval);\n }\n this.dataPollingIntervals.clear();\n \n this.broadcastMessage({\n type: 'execution_service_status',\n timestamp: new Date().toISOString(),\n data: { status: 'STOPPED' }\n });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.67948717948718 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.6923076923077, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 334:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n }\n \n /**\n * Convert data resolution to polling interval\n */\n private getPollingIntervalFromResolution(resolution: string): number {\n /*...*/\n }\n \n /**\n * Poll market data for a specific strategy\n */\n private async pollMarketData(strategyId: string): Promise {\n /*...*/\n }\n \n /**\n * Process a new bar with the strategy\n */ private processBar(strategyId: string, symbol: string, bar: BarData): void {\n /*...*/\n }\n \n /**\n * Execute a trading signal\n */\n private executeSignal(strategyId: string, signal: any): void {\n /*...*/\n }\n \n /**\n * Close all connections when service is shut down\n */\n shutdown(): void {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.6923076923077 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.7051282051282, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 302:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Pause a specific strategy\n */\n pauseStrategy(strategyId: string): boolean {\n /*...*/\n name: strategy.name\n }\n });\n \n return true;\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.7051282051282 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.71794871794872, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 138:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Start the execution service (global)\n */\n start(): void {\n if (this.isRunning) return;\n \n this.isRunning = true;\n console.log('Strategy execution service started');\n \n // Start data polling for all active strategies\n for (const [strategyId, data] of this.activeStrategies.entries()) {\n this.startDataPollingForStrategy(strategyId, data);\n }\n \n this.broadcastMessage({\n type: 'execution_service_status',\n timestamp: new Date().toISOString(),\n data: { status: 'RUNNING' }\n });\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.71794871794872 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.73076923076923, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 333:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Start data polling for a specific strategy\n */\n private startDataPollingForStrategy(\n strategyId: string, \n data: { \n strategy: BaseStrategy; \n config: ExecutionConfig;\n positions: Map;\n lastBar: Map;\n }\n ): void {\n /*...*/\n console.log(`Started data polling for strategy ${strategyId} with interval ${pollingIntervalMs}ms`);\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.73076923076923 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.74358974358974, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 263:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Stop a specific strategy\n */\n stopStrategy(strategyId: string): boolean {\n /*...*/\n console.log(`Strategy ${strategyId} stopped`);\n \n this.broadcastMessage({\n type: 'strategy_stopped',\n timestamp: new Date().toISOString(),\n data: {\n strategyId,\n name: strategy.name\n }\n });\n \n return true;\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.74358974358974 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.75641025641026, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts` starting at line 85:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts\n/*...*/\n@Injectable({\n providedIn: 'root'\n})\nexport class StrategyService {\n private apiBaseUrl = '/api'; // Will be proxied to the correct backend endpoint\n\n constructor(private http: HttpClient) { }\n\n // Strategy Management\n getStrategies(): Observable> {\n /*...*/\n }\n\n getStrategy(id: string): Observable> {\n /*...*/\n }\n\n createStrategy(strategy: Partial): Observable> {\n /*...*/\n }\n\n updateStrategy(id: string, updates: Partial): Observable> {\n /*...*/\n }\n\n startStrategy(id: string): Observable> {\n /*...*/\n }\n\n stopStrategy(id: string): Observable> {\n /*...*/\n }\n\n pauseStrategy(id: string): Observable> {\n /*...*/\n }\n\n // Backtest Management\n getStrategyTypes(): Observable> {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.75641025641026 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.76923076923077, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 402:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Process a new bar with the strategy\n */ private processBar(strategyId: string, symbol: string, bar: BarData): void {\n const strategyData = this.activeStrategies.get(strategyId);\n \n if (!strategyData) {\n console.warn(`Strategy ${strategyId} not found in active strategies`);\n return;\n }\n \n const { strategy } = strategyData;\n \n // Call strategy's onBar method to get trading signals\n const signal = strategy.onBar(bar);\n \n if (signal) {\n // Create a signal object with timestamp and ID\n const signalObject = {\n id: `sig_${Date.now()}_${Math.floor(Math.random() * 10000)}`,\n strategyId,\n name: strategy.name,\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.76923076923077 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.78205128205128, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 185:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Start a specific strategy\n */\n startStrategy(strategyId: string, config?: ExecutionConfig): boolean {\n const strategy = this.strategyRegistry.getStrategyById(strategyId);\n \n if (!strategy) {\n console.error(`Strategy with ID ${strategyId} not found`);\n return false;\n }\n \n // If strategy is already active, return false\n if (this.activeStrategies.has(strategyId)) {\n console.warn(`Strategy ${strategyId} is already active`);\n return false;\n }\n \n // Use provided config or create default\n const executionConfig: ExecutionConfig = config || {\n symbols: strategy.symbols,\n dataResolution: '1m',\n realTrading: false,\n maxPositionValue: 10000,\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.78205128205128 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.7948717948718, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 49:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Initialize WebSocket server for real-time updates\n */\n private initializeWebSocketServer(port: number): void {\n try {\n this.webSocketServer = new WebSocket.Server({ port });\n \n this.webSocketServer.on('connection', (ws) => {\n console.log('New client connected to strategy execution service');\n this.wsClients.add(ws);\n \n ws.on('message', (message) => {\n try {\n const data = JSON.parse(message.toString());\n this.handleWebSocketMessage(ws, data);\n } catch (error) {\n console.error('Error handling WebSocket message:', error);\n }\n });\n \n ws.on('close', () => {\n console.log('Client disconnected from strategy execution service');\n this.wsClients.delete(ws);\n });\n \n // Send initial state\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.7948717948718 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.8076923076923, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 321:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Start data polling for a specific strategy\n */\n private startDataPollingForStrategy(\n strategyId: string, \n data: { \n strategy: BaseStrategy; \n config: ExecutionConfig;\n positions: Map;\n lastBar: Map;\n }\n ): void {\n const { strategy, config } = data;\n \n // Determine polling interval based on data resolution\n const pollingIntervalMs = this.getPollingIntervalFromResolution(config.dataResolution);\n \n // Set up interval for data polling\n const intervalId = setInterval(async () => {\n await this.pollMarketData(strategyId);\n }, pollingIntervalMs);\n \n this.dataPollingIntervals.set(strategyId, intervalId);\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.8076923076923 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.82051282051282, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 46:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n * Initialize WebSocket server for real-time updates\n */\n private initializeWebSocketServer(port: number): void {\n /*...*/\n }\n \n /**\n * Handle incoming WebSocket messages\n */\n private handleWebSocketMessage(ws: WebSocket, message: any): void {\n /*...*/\n }\n \n /**\n * Send a message to all connected WebSocket clients\n */\n private broadcastMessage(message: any): void {\n /*...*/\n }\n \n /**\n * Send current status of all active strategies to a specific client\n */\n private sendAllStrategyStatus(ws: WebSocket): void {\n /*...*/\n }\n \n /**\n * Start the execution service (global)\n */\n start(): void {\n /*...*/\n }\n \n /**\n * Stop the execution service (global)\n */\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.82051282051282 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.83333333333333, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 356:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Poll market data for a specific strategy\n */\n private async pollMarketData(strategyId: string): Promise {\n const strategyData = this.activeStrategies.get(strategyId);\n \n if (!strategyData) {\n console.warn(`Strategy ${strategyId} not found in active strategies`);\n return;\n }\n \n const { strategy, config, lastBar } = strategyData;\n \n try {\n // Get latest market data for all symbols\n for (const symbol of config.symbols) {\n // Get latest bar\n const now = new Date();\n const startTime = new Date(now.getTime() - 24 * 60 * 60 * 1000); // 24 hours ago\n \n // Fetch latest bar\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.83333333333333 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.84615384615384, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 373:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Poll market data for a specific strategy\n */\n private async pollMarketData(strategyId: string): Promise {\n /*...*/\n const bars = await this.marketDataFeed.getHistoricalData(\n symbol,\n config.dataResolution,\n startTime,\n now\n );\n \n if (bars.length > 0) {\n const latestBar = bars[bars.length - 1];\n \n // Only process if this is a new bar\n const currentLastBar = lastBar.get(symbol);\n if (!currentLastBar || latestBar.timestamp.getTime() > currentLastBar.timestamp.getTime()) {\n // Update last bar\n lastBar.set(symbol, latestBar);\n \n // Process the bar with the strategy\n this.processBar(strategyId, symbol, latestBar);\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.84615384615384 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.85897435897436, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 510:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n }\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.85897435897436 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.87179487179488, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 420:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Process a new bar with the strategy\n */ private processBar(strategyId: string, symbol: string, bar: BarData): void {\n /*...*/\n symbol: bar.symbol,\n price: bar.close,\n action: signal.action,\n quantity: signal.quantity,\n metadata: signal.metadata,\n timestamp: new Date().toISOString(),\n confidence: signal.confidence || 0.8 // Default confidence if not provided\n };\n \n // Store the signal in Redis (this would be in a production environment)\n try {\n // This would normally be injected as a dependency, but for simplicity:\n const redis = require('ioredis') ? \n new (require('ioredis'))({\n host: process.env.REDIS_HOST || 'localhost',\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.87179487179488 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.88461538461539, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 453:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Process a new bar with the strategy\n */ private processBar(strategyId: string, symbol: string, bar: BarData): void {\n /*...*/\n timestamp: new Date().toISOString(),\n data: signalObject\n });\n \n // Execute the signal if real trading is enabled\n if (strategyData.config.realTrading) {\n this.executeSignal(strategyId, signal);\n }\n }\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.88461538461539 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.8974358974359, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 242:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Stop a specific strategy\n */\n stopStrategy(strategyId: string): boolean {\n if (!this.activeStrategies.has(strategyId)) {\n console.warn(`Strategy ${strategyId} is not active`);\n return false;\n }\n \n // Clear data polling interval for this strategy\n const intervalId = this.dataPollingIntervals.get(strategyId);\n if (intervalId) {\n clearInterval(intervalId);\n this.dataPollingIntervals.delete(strategyId);\n }\n \n // Get strategy data before removing\n const strategyData = this.activeStrategies.get(strategyId)!;\n const { strategy } = strategyData;\n \n // Close any open positions (in real implementation)\n // ...\n \n this.activeStrategies.delete(strategyId);\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.8974358974359 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.91025641025641, - "text": "Here is the full text of `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts`:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\nimport { EventEmitter } from 'events';\nimport { BaseStrategy } from '../Strategy';\nimport { BarData, Order, Position } from '../Strategy';\nimport { MarketDataFeed } from '../backtesting/MarketDataFeed';\nimport { StrategyRegistry } from '../strategies/StrategyRegistry';\nimport { WebSocket } from 'ws';\n\nexport interface ExecutionConfig {\n /*...*/\n}\n\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.91025641025641 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.92307692307692, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 162:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n stop(): void {\n /*...*/\n }\n \n /**\n * Start a specific strategy\n */\n startStrategy(strategyId: string, config?: ExecutionConfig): boolean {\n /*...*/\n }\n \n /**\n * Stop a specific strategy\n */\n stopStrategy(strategyId: string): boolean {\n /*...*/\n }\n \n /**\n * Pause a specific strategy\n */\n pauseStrategy(strategyId: string): boolean {\n /*...*/\n }\n \n /**\n * Start data polling for a specific strategy\n */\n private startDataPollingForStrategy(\n strategyId: string, \n data: { \n strategy: BaseStrategy; \n config: ExecutionConfig;\n positions: Map;\n lastBar: Map;\n }\n ): void {\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.92307692307692 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.93589743589743, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 204:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n /**\n * Start a specific strategy\n */\n startStrategy(strategyId: string, config?: ExecutionConfig): boolean {\n /*...*/\n maxOrdersPerMinute: 5,\n stopLossPercentage: 0.02\n };\n \n // Initialize strategy data\n const strategyData = {\n strategy,\n config: executionConfig,\n positions: new Map(),\n lastBar: new Map()\n };\n \n this.activeStrategies.set(strategyId, strategyData);\n \n // If execution service is running, start data polling for this strategy\n if (this.isRunning) {\n this.startDataPollingForStrategy(strategyId, strategyData);\n }\n /*...*/\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.93589743589743 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.94871794871794, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 38:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n /*...*/\n constructor(apiBaseUrl: string = 'http://localhost:3001/api', wsPort: number = 8082) {\n super();\n this.strategyRegistry = StrategyRegistry.getInstance();\n this.marketDataFeed = new MarketDataFeed(apiBaseUrl);\n this.initializeWebSocketServer(wsPort);\n }\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.94871794871794 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.96153846153847, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts` starting at line 23:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts\n/*...*/\n/**\n * Strategy Execution Service\n * \n * Handles the real-time execution of trading strategies.\n * Manages live data feeds, order execution, and position tracking.\n */\nexport class StrategyExecutionService extends EventEmitter {\n private strategyRegistry: StrategyRegistry;\n private marketDataFeed: MarketDataFeed;\n private activeStrategies: Map;\n lastBar: Map;\n }> = new Map();\n \n private isRunning: boolean = false;\n private dataPollingIntervals: Map = new Map();\n private webSocketServer: WebSocket.Server | null = null;\n private wsClients: Set = new Set();\n private marketDataCache: Map = new Map();\n \n constructor(apiBaseUrl: string = 'http://localhost:3001/api', wsPort: number = 8082) {\n /*...*/\n }\n \n /**\n /*...*/\n}\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.96153846153847 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.97435897435898, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts` starting at line 0:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts\nimport { BaseStrategy, BarData, Order, StrategyParameters } from '../Strategy';\nimport { TechnicalIndicators } from '../analysis/TechnicalIndicators';\n\nexport interface VectorizedStrategyParams extends StrategyParameters {\n /*...*/\n}\n\n/**\n * Vectorized Strategy Base Class\n * \n * A performant strategy implementation designed for fast backtesting.\n * Instead of processing bars one at a time, it pre-calculates signals\n * for large chunks of data and executes them in batches.\n */\nexport abstract class VectorizedStrategy extends BaseStrategy {\n // Default parameters\n protected static readonly DEFAULT_PARAMS: VectorizedStrategyParams = {\n lookbackPeriod: 100,\n positionSize: 0.2, // 20% of portfolio\n stopLoss: 0.02, // 2% stop loss\n takeProfit: 0.05, // 5% take profit\n useBollingerBands: true,\n bollingerPeriod: 20,\n bollingerDeviation: 2\n };\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.97435897435898 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100.98717948717949, - "text": "Here is a potentially relevant text excerpt in `g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts` starting at line 0:\n```ts\n// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts\nimport { EventEmitter } from 'events';\n\nexport interface BarData {\n /*...*/\n}\n\nexport interface Position {\n /*...*/\n}\n\nexport interface Order {\n /*...*/\n}\n\nexport interface StrategyContext {\n /*...*/\n}\n\nexport interface StrategyParameters {\n /*...*/\n}\n\nexport interface StrategyMetrics {\n /*...*/\n}\n\nexport abstract class BaseStrategy extends EventEmitter {\n public readonly id: string;\n public readonly name: string;\n public readonly description: string;\n public readonly symbols: string[];\n public parameters: StrategyParameters;\n \n protected context: StrategyContext;\n protected isInitialized: boolean = false;\n \n constructor(\n id: string,\n name: string,\n description: string,\n symbols: string[],\n parameters: StrategyParameters = {}\n ) {\n /*...*/\n }\n\n // Abstract methods that must be implemented by strategy subclasses\n abstract initialize(): Promise;\n abstract onBar(bar: BarData): Promise;\n abstract onOrderFilled(order: Order): Promise;\n abstract cleanup(): Promise;\n\n // Lifecycle methods\n /*...*/\n```\n\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100.98717948717949 - }, - "references": [] - } - ], - "props": { - "priority": 100 - }, - "references": [ - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 0, - "character": 0 - }, - { - "line": 112, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 112, - "character": 0 - }, - { - "line": 200, - "character": 12 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 211, - "character": 2 - }, - { - "line": 287, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 0, - "character": 0 - }, - { - "line": 31, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 32, - "character": 0 - }, - { - "line": 83, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\VectorizedStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/VectorizedStrategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 88, - "character": 0 - }, - { - "line": 116, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\execution\\StrategyExecutionService.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/execution/StrategyExecutionService.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/execution/StrategyExecutionService.ts", - "scheme": "file" - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "scheme": "file" - }, - "range": [ - { - "line": 4, - "character": 0 - }, - { - "line": 34, - "character": 1 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "scheme": "file" - }, - "range": [ - { - "line": 85, - "character": 0 - }, - { - "line": 119, - "character": 57 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\services\\strategy.service.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/services/strategy.service.ts", - "scheme": "file" - }, - "range": [ - { - "line": 106, - "character": 2 - }, - { - "line": 121, - "character": 3 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\ARCHITECTURE.md", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/ARCHITECTURE.md", - "path": "/g:/repos/stock-bot/ARCHITECTURE.md", - "scheme": "file" - }, - "range": [ - { - "line": 166, - "character": 0 - }, - { - "line": 188, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\ARCHITECTURE.md", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/ARCHITECTURE.md", - "path": "/g:/repos/stock-bot/ARCHITECTURE.md", - "scheme": "file" - }, - "range": [ - { - "line": 188, - "character": 0 - }, - { - "line": 199, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\ARCHITECTURE.md", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/ARCHITECTURE.md", - "path": "/g:/repos/stock-bot/ARCHITECTURE.md", - "scheme": "file" - }, - "range": [ - { - "line": 199, - "character": 0 - }, - { - "line": 217, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - }, - "range": [ - { - "line": 178, - "character": 0 - }, - { - "line": 203, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "scheme": "file" - }, - "range": [ - { - "line": 12, - "character": 0 - }, - { - "line": 129, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\controllers\\StrategyController.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/controllers/StrategyController.ts", - "scheme": "file" - }, - "range": [ - { - "line": 129, - "character": 0 - }, - { - "line": 264, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\tests\\execution\\StrategyExecutionService.test.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/tests/execution/StrategyExecutionService.test.ts", - "scheme": "file" - }, - "range": [ - { - "line": 62, - "character": 0 - }, - { - "line": 89, - "character": 1 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\MeanReversionStrategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/MeanReversionStrategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/MeanReversionStrategy.ts", - "scheme": "file" - }, - "range": [ - { - "line": 133, - "character": 2 - }, - { - "line": 136, - "character": 3 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\index.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/index.ts", - "scheme": "file" - }, - "range": [ - { - "line": 24, - "character": 0 - }, - { - "line": 82, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - }, - "range": [ - { - "line": 0, - "character": 0 - }, - { - "line": 604, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\strategies\\StrategyRegistry.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/StrategyRegistry.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/strategies/StrategyRegistry.ts", - "scheme": "file" - }, - "range": [ - { - "line": 0, - "character": 0 - }, - { - "line": 197, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "scheme": "file" - }, - "range": [ - { - "line": 185, - "character": 2 - }, - { - "line": 194, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "scheme": "file" - }, - "range": [ - { - "line": 272, - "character": 2 - }, - { - "line": 288, - "character": 3 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategy-details\\strategy-details.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategy-details/strategy-details.component.ts", - "scheme": "file" - }, - "range": [ - { - "line": 308, - "character": 2 - }, - { - "line": 324, - "character": 3 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestService.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestService.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestService.ts", - "scheme": "file" - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "scheme": "file" - }, - "range": [ - { - "line": 76, - "character": 2 - }, - { - "line": 85, - "character": 3 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "scheme": "file" - }, - "range": [ - { - "line": 122, - "character": 2 - }, - { - "line": 134, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "scheme": "file" - }, - "range": [ - { - "line": 134, - "character": 0 - }, - { - "line": 142, - "character": 3 - } - ] - }, - "options": { - "isFromTool": true - } - }, - { - "anchor": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\interface-services\\trading-dashboard\\src\\app\\pages\\strategies\\strategies.component.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "path": "/g:/repos/stock-bot/apps/interface-services/trading-dashboard/src/app/pages/strategies/strategies.component.ts", - "scheme": "file" - }, - "range": [ - { - "line": 142, - "character": 2 - }, - { - "line": 147, - "character": 0 - } - ] - }, - "options": { - "isFromTool": true - } - } - ] - } - ], - "props": { - "priority": 100 - }, - "references": [] - } - ], - "props": { - "priority": 100 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": { - "priority": 100 - }, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01T27ynyGn19Nxp5bmEF28e9__vscode-1748915937106": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Lines ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "0", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " to ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "100", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " (", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "288", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " lines total):", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 104, - "text": "```typescript\n", - "references": [ - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/Strategy.ts", - "scheme": "file" - } - } - ], - "lineBreakBefore": true - } - ], - "props": { - "priority": 104 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 103, - "text": "// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\Strategy.ts\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 103 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 102, - "text": "import { EventEmitter } from 'events';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 102 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 101, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 101 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 100, - "text": "export interface BarData {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 100 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 99, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 99 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 98, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 98 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 97, - "text": " open: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 97 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 96, - "text": " high: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 96 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 95, - "text": " low: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 95 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 94, - "text": " close: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 94 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 93, - "text": " volume: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 93 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 92, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 92 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 91, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 91 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 90, - "text": "export interface Position {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 90 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 89, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 89 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 88, - "text": " quantity: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 88 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 87, - "text": " avgPrice: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 87 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 86, - "text": " side: 'LONG' | 'SHORT';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 86 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 85, - "text": " entryTime: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 85 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 84, - "text": " unrealizedPnL?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 84 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 83, - "text": " realizedPnL?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 83 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 82, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 82 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 81, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 81 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 80, - "text": "export interface Order {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 80 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 79, - "text": " id: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 79 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 78, - "text": " symbol: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 78 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 77, - "text": " side: 'BUY' | 'SELL';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 77 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 76, - "text": " quantity: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 76 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 75, - "text": " price?: number; // Market order if undefined\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 75 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 74, - "text": " type: 'MARKET' | 'LIMIT' | 'STOP' | 'STOP_LIMIT';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 74 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 73, - "text": " status: 'PENDING' | 'FILLED' | 'CANCELLED' | 'REJECTED';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 73 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 72, - "text": " timestamp: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 72 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 71, - "text": " fillPrice?: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 71 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 70, - "text": " fillTime?: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 70 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 69, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 69 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 68, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 68 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 67, - "text": "export interface StrategyContext {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 67 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 66, - "text": " currentTime: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 66 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 65, - "text": " portfolio: {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 65 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 64, - "text": " cash: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 64 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 63, - "text": " positions: Map;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 63 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 62, - "text": " totalValue: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 62 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 61, - "text": " };\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 61 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 60, - "text": " marketData: Map; // Historical data for each symbol\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 60 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 59, - "text": " indicators: Map; // Cached indicator values\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 59 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 58, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 58 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 57, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 57 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 56, - "text": "export interface StrategyParameters {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 56 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 55, - "text": " [key: string]: number | string | boolean | any[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 55 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 54, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 54 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 53, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 53 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 52, - "text": "export interface StrategyMetrics {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 52 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 51, - "text": " totalReturn: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 51 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 50, - "text": " totalTrades: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 50 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 49, - "text": " winningTrades: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 49 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 48, - "text": " losingTrades: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 48 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 47, - "text": " winRate: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 47 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 46, - "text": " avgWin: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 46 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 45, - "text": " avgLoss: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 45 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 44, - "text": " profitFactor: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 44 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 43, - "text": " sharpeRatio: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 43 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 42, - "text": " maxDrawdown: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 42 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 41, - "text": " maxDrawdownDuration: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 41 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 40, - "text": " calmarRatio: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 40 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 39, - "text": " sortinoRatio: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 39 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 38, - "text": " beta: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 38 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 37, - "text": " alpha: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 37 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 36, - "text": " volatility: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 36 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 35, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 35 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 34, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 34 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 33, - "text": "export abstract class BaseStrategy extends EventEmitter {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 33 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 32, - "text": " public readonly id: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 32 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 31, - "text": " public readonly name: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 31 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 30, - "text": " public readonly description: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 30 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 29, - "text": " public readonly symbols: string[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 29 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 28, - "text": " public parameters: StrategyParameters;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 28 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 27, - "text": " \r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 27 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 26, - "text": " protected context: StrategyContext;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 26 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 25, - "text": " protected isInitialized: boolean = false;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 25 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 24, - "text": " \r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 24 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 23, - "text": " constructor(\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 23 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 22, - "text": " id: string,\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 22 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 21, - "text": " name: string,\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 21 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 20, - "text": " description: string,\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 20 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 19, - "text": " symbols: string[],\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 19 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 18, - "text": " parameters: StrategyParameters = {}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 18 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 17, - "text": " ) {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 17 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 16, - "text": " super();\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 16 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 15, - "text": " this.id = id;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 15 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 14, - "text": " this.name = name;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 14 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 13, - "text": " this.description = description;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 13 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 12, - "text": " this.symbols = symbols;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 12 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 11, - "text": " this.parameters = parameters;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 11 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 10, - "text": " \r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 10 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9, - "text": " this.context = {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 9 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 8, - "text": " currentTime: new Date(),\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 8 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 7, - "text": " portfolio: {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 7 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 6, - "text": " cash: 100000, // Default starting capital\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 6 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 5, - "text": " positions: new Map(),\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 4, - "text": " totalValue: 100000\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 4 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 3, - "text": " },\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 3 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 2, - "text": " marketData: new Map(),\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 2 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 104, - "text": "```", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 104 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01Y3qjEd1BZudG2XDSmpiUPN__vscode-1748915937107": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "mm", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "String replacement failed: Failed to edit file: Could not find matching text to replace. Try making your search string more specific or checking for whitespace/formatting differences.\n\noldStr: import { OHLCV, Order, Position } from '@stock-bot/shared-types';\n\nexport interface BacktestConfig {\n initialCapital: number;\n startDate: Date;\n endDate: Date;\n commission: number;\n slippage: number;\n}\n\nexport interface BacktestResult {\n startDate: Date;\n endDate: Date;\n initialCapital: number;\n finalCapital: number;\n totalReturn: number;\n totalTrades: number;\n winningTrades: number;\n losingTrades: number;\n winRate: number;\n avgWin: number;\n avgLoss: number;\n profitFactor: number;\n sharpeRatio: number;\n maxDrawdown: number;\n trades: Array<{\n id: string;\n symbol: string;\n side: 'BUY' | 'SELL';\n quantity: number;\n entryTime: Date;\n exitTime: Date;\n entryPrice: number;\n exitPrice: number;\n pnl: number;\n pnlPercent: number;\n }>;\n dailyReturns: Array<{\n date: Date;\n portfolioValue: number;\n dayReturn: number;\n }>;\n}\n\nexport interface BacktestProgress {\n currentDate: Date;\n progress: number; // 0-100\n portfolioValue: number;\n totalTrades: number;\n}\n\nexport interface DataFeed {\n getHistoricalData(symbol: string, startDate: Date, endDate: Date): Promise;\n}\n\ninterface BarData {\n symbol: string;\n timestamp: Date;\n open: number;\n high: number;\n low: number;\n close: number;\n volume: number;\n}\n\ntext: import { EventEmitter } from 'events';\r\nimport { OHLCV, Order, Position } from '@stock-bot/shared-types';\r\n\r\n// Define additional types needed for backtesting\r\nexport interface BarData extends OHLCV {}\r\n\r\nexport interface BacktestPosition extends Position {\r\n entryTime: Date;\r\n side: 'LONG' | 'SHORT';\r\n avgPrice: number; // Alias for averagePrice for backward compatibility\r\n}\r\n\r\nexport interface StrategyInterface {\r\n id: string;\r\n start(): Promise;\r\n stop(): Promise;\r\n onBar(bar: BarData): Promise;\r\n onOrderFilled(order: Order): Promise;\r\n}\r\n\r\nexport interface BacktestConfig {\r\n startDate: Date;\r\n endDate: Date;\r\n symbols: string[];\r\n initialCapital: number;\r\n commission: number; // Per trade commission (percentage)\r\n slippage: number; // Slippage model (percentage)\r\n dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\r\n mode: 'event' | 'vector';\r\n}\r\n\r\nexport interface BacktestResult {\r\n strategyId: string;\r\n startDate: Date;\r\n endDate: Date;\r\n duration: number; // In milliseconds\r\n initialCapital: number;\r\n finalCapital: number;\r\n totalReturn: number;\r\n annualizedReturn: number;\r\n sharpeRatio: number;\r\n maxDrawdown: number;\r\n maxDrawdownDuration: number; // In days\r\n winRate: number;\r\n totalTrades: number;\r\n winningTrades: number;\r\n losingTrades: number;\r\n averageWinningTrade: number;\r\n averageLosingTrade: number;\r\n profitFactor: number;\r\n dailyReturns: Array<{ date: Date; return: number }>;\r\n trades: Array<{\r\n symbol: string;\r\n entryTime: Date;\r\n entryPrice: number;\r\n exitTime: Date;\r\n exitPrice: number;\r\n quantity: number;\r\n pnl: number;\r\n pnlPercent: number;\r\n }>;\r\n}\r\n\r\nexport interface BacktestProgress {\r\n progress: number; // 0-100\r\n currentDate: Date;\r\n processingSpeed: number; // Bars per second\r\n estimatedTimeRemaining: number; // milliseconds\r\n currentCapital: number;\r\n currentReturn: number;\r\n currentDrawdown: number;\r\n}\r\n\r\nexport interface DataFeed {\r\n getHistoricalData(symbol: string, resolution: string, start: Date, end: Date): Promise;\r\n hasDataFor(symbol: string, resolution: string, start: Date, end: Date): Promise;\r\n}\r\n\r\nexport class BacktestEngine extends EventEmitter {\r\n private config: BacktestConfig;\r\n private strategy: BaseStrategy;\r\n private dataFeed: DataFeed;\r\n private isRunning: boolean = false;\r\n private barBuffer: Map = new Map();\r\n private pendingOrders: Order[] = [];\r\n private filledOrders: Order[] = [];\r\n private currentTime: Date;\r\n private startTime: number = 0; // For performance tracking\r\n private processedBars: number = 0;\r\n private marketData: Map = new Map();\r\n\r\n // Results tracking\r\n private initialCapital: number;\r\n private currentCapital: number;\r\n private positions = new Map();\r\n private trades: BacktestResult['trades'] = [];\r\n private dailyReturns: BacktestResult['dailyReturns'] = [];\r\n private previousPortfolioValue: number;\r\n private highWaterMark: number;\r\n private maxDrawdown: number = 0;\r\n private drawdownStartTime: Date | null = null;\r\n private maxDrawdownDuration: number = 0;\r\n private winningTrades: number = 0;\r\n private losingTrades: number = 0;\r\n private breakEvenTrades: number = 0;\r\n private totalProfits: number = 0;\r\n private totalLosses: number = 0;\r\n\r\n constructor(strategy: BaseStrategy, config: BacktestConfig, dataFeed: DataFeed) {\r\n super();\r\n this.strategy = strategy;\r\n this.config = config;\r\n this.dataFeed = dataFeed;\r\n this.currentTime = new Date(config.startDate);\r\n this.initialCapital = config.initialCapital;\r\n this.currentCapital = config.initialCapital;\r\n this.previousPortfolioValue = config.initialCapital;\r\n this.highWaterMark = config.initialCapital;\r\n }\r\n\r\n async run(): Promise {\r\n if (this.isRunning) {\r\n throw new Error('Backtest is already running');\r\n }\r\n\r\n this.isRunning = true;\r\n this.startTime = Date.now();\r\n this.emit('started', { strategyId: this.strategy.id, config: this.config });\r\n\r\n try {\r\n // Load data based on configured mode\r\n if (this.config.mode === 'event') {\r\n await this.runEventBased();\r\n } else {\r\n await this.runVectorized();\r\n }\r\n\r\n const result = this.generateResults();\r\n this.emit('completed', { strategyId: this.strategy.id, result });\r\n this.isRunning = false;\r\n return result;\r\n } catch (error) {\r\n this.isRunning = false;\r\n this.emit('error', { strategyId: this.strategy.id, error });\r\n throw error;\r\n }\r\n }\r\n\r\n private async runEventBased(): Promise {\r\n // Load market data for all symbols\r\n await this.loadMarketData();\r\n\r\n // Initialize the strategy\r\n await this.strategy.start();\r\n\r\n // Create a merged timeline of all bars across all symbols, sorted by timestamp\r\n const timeline = this.createMergedTimeline();\r\n\r\n // Process each event in chronological order\r\n let lastProgressUpdate = Date.now();\r\n let prevDate = new Date(0);\r\n \r\n for (let i = 0; i < timeline.length; i++) {\r\n const bar = timeline[i];\r\n this.currentTime = bar.timestamp;\r\n\r\n // Process any pending orders\r\n await this.processOrders(bar);\r\n\r\n // Update positions with current prices\r\n this.updatePositions(bar);\r\n\r\n // If we've crossed to a new day, calculate daily return\r\n if (this.currentTime.toDateString() !== prevDate.toDateString()) {\r\n this.calculateDailyReturn();\r\n prevDate = this.currentTime;\r\n }\r\n\r\n // Send the new bar to the strategy\r\n const orders = await this.strategy.onBar(bar);\r\n \r\n // Add any new orders to the pending orders queue\r\n if (orders && orders.length > 0) {\r\n this.pendingOrders.push(...orders);\r\n }\r\n\r\n // Update progress periodically\r\n if (Date.now() - lastProgressUpdate > 1000) { // Update every second\r\n this.updateProgress(i / timeline.length);\r\n lastProgressUpdate = Date.now();\r\n }\r\n }\r\n\r\n // Process any remaining orders\r\n for (const order of this.pendingOrders) {\r\n await this.processOrder(order);\r\n }\r\n\r\n // Close any remaining positions at the last known price\r\n await this.closeAllPositions();\r\n\r\n // Clean up strategy\r\n await this.strategy.stop();\r\n }\r\n\r\n private async runVectorized(): Promise {\r\n // Load market data for all symbols\r\n await this.loadMarketData();\r\n \r\n // To implement a vectorized approach, we need to:\r\n // 1. Pre-compute technical indicators\r\n // 2. Generate buy/sell signals for the entire dataset\r\n // 3. Calculate portfolio values based on signals\r\n \r\n // This is a simplified implementation since specific vectorized strategies\r\n // will need to be implemented separately based on the strategy type\r\n\r\n const timeline = this.createMergedTimeline();\r\n const startTime = Date.now();\r\n \r\n // Initialize variables for tracking performance\r\n let currentPositions = new Map();\r\n let currentCash = this.initialCapital;\r\n let prevPortfolioValue = this.initialCapital;\r\n let highWaterMark = this.initialCapital;\r\n let maxDrawdown = 0;\r\n let maxDrawdownStartDate = new Date();\r\n let maxDrawdownEndDate = new Date();\r\n let currentDrawdownStart = new Date();\r\n \r\n // Pre-process data (this would be implemented by the specific strategy)\r\n const allBars = new Map();\r\n for (const symbol of this.config.symbols) {\r\n allBars.set(symbol, this.marketData.get(symbol) || []);\r\n }\r\n \r\n // Apply strategy logic (vectorized implementation would be here)\r\n // For now, we'll just simulate the processing\r\n \r\n this.emit('completed', { message: 'Vectorized backtest completed in fast mode' });\r\n }\r\n\r\n private async loadMarketData(): Promise {\r\n for (const symbol of this.config.symbols) {\r\n this.emit('loading', { symbol, resolution: this.config.dataResolution });\r\n \r\n // Check if data is available\r\n const hasData = await this.dataFeed.hasDataFor(\r\n symbol,\r\n this.config.dataResolution,\r\n this.config.startDate,\r\n this.config.endDate\r\n );\r\n \r\n if (!hasData) {\r\n throw new Error(`No data available for ${symbol} at resolution ${this.config.dataResolution}`);\r\n }\r\n \r\n // Load data\r\n const data = await this.dataFeed.getHistoricalData(\r\n symbol,\r\n this.config.dataResolution,\r\n this.config.startDate,\r\n this.config.endDate\r\n );\r\n \r\n this.marketData.set(symbol, data);\r\n this.emit('loaded', { symbol, count: data.length });\r\n }\r\n }\r\n\r\n private createMergedTimeline(): BarData[] {\r\n const allBars: BarData[] = [];\r\n \r\n for (const [symbol, bars] of this.marketData.entries()) {\r\n allBars.push(...bars);\r\n }\r\n \r\n // Sort by timestamp\r\n return allBars.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());\r\n }\r\n\r\n private async processOrders(currentBar: BarData): Promise {\r\n // Find orders for the current symbol\r\n const ordersToProcess = this.pendingOrders.filter(order => order.symbol === currentBar.symbol);\r\n \r\n if (ordersToProcess.length === 0) return;\r\n \r\n // Remove these orders from pendingOrders\r\n this.pendingOrders = this.pendingOrders.filter(order => order.symbol !== currentBar.symbol);\r\n \r\n // Process each order\r\n for (const order of ordersToProcess) {\r\n await this.processOrder(order);\r\n }\r\n }\r\n\r\n private async processOrder(order: Order): Promise {\r\n // Get the latest price for the symbol\r\n const latestBars = this.marketData.get(order.symbol);\r\n if (!latestBars || latestBars.length === 0) {\r\n order.status = 'REJECTED';\r\n this.emit('orderRejected', { order, reason: 'No market data available' });\r\n return;\r\n }\r\n \r\n // Find the bar closest to the order time\r\n const bar = latestBars.find(b => \r\n b.timestamp.getTime() >= order.timestamp.getTime()\r\n ) || latestBars[latestBars.length - 1];\r\n \r\n // Calculate fill price with slippage\r\n let fillPrice: number;\r\n if (order.type === 'MARKET') {\r\n // Apply slippage model\r\n const slippageFactor = 1 + (order.side === 'BUY' ? this.config.slippage : -this.config.slippage);\r\n fillPrice = bar.close * slippageFactor;\r\n } else if (order.type === 'LIMIT' && order.price !== undefined) {\r\n // For limit orders, check if the price was reached\r\n if ((order.side === 'BUY' && bar.low <= order.price) ||\r\n (order.side === 'SELL' && bar.high >= order.price)) {\r\n fillPrice = order.price;\r\n } else {\r\n // Limit price not reached\r\n return;\r\n }\r\n } else {\r\n // Other order types not implemented\r\n order.status = 'REJECTED';\r\n this.emit('orderRejected', { order, reason: 'Order type not supported' });\r\n return;\r\n }\r\n \r\n // Calculate commission\r\n const orderValue = order.quantity * fillPrice;\r\n const commission = orderValue * this.config.commission;\r\n \r\n // Check if we have enough cash for BUY orders\r\n if (order.side === 'BUY') {\r\n const totalCost = orderValue + commission;\r\n if (totalCost > this.currentCapital) {\r\n // Not enough cash\r\n order.status = 'REJECTED';\r\n this.emit('orderRejected', { order, reason: 'Insufficient funds' });\r\n return;\r\n }\r\n \r\n // Update cash\r\n this.currentCapital -= totalCost;\r\n \r\n // Update or create position\r\n const existingPosition = this.positions.get(order.symbol);\r\n if (existingPosition) {\r\n // Update existing position (average down)\r\n const totalShares = existingPosition.quantity + order.quantity;\r\n const totalCost = (existingPosition.quantity * existingPosition.avgPrice) + (order.quantity * fillPrice);\r\n existingPosition.avgPrice = totalCost / totalShares;\r\n existingPosition.quantity = totalShares;\r\n } else {\r\n // Create new position\r\n this.positions.set(order.symbol, {\r\n symbol: order.symbol,\r\n quantity: order.quantity,\r\n avgPrice: fillPrice,\r\n side: 'LONG',\r\n entryTime: this.currentTime\r\n });\r\n }\r\n } else if (order.side === 'SELL') {\r\n const position = this.positions.get(order.symbol);\r\n \r\n if (!position || position.quantity < order.quantity) {\r\n // Not enough shares to sell\r\n order.status = 'REJECTED';\r\n this.emit('orderRejected', { order, reason: 'Insufficient position' });\r\n return;\r\n }\r\n \r\n // Calculate P&L\r\n const pnl = (fillPrice - position.avgPrice) * order.quantity;\r\n \r\n // Update cash\r\n this.currentCapital += orderValue - commission;\r\n \r\n // Update position\r\n position.quantity -= order.quantity;\r\n \r\n if (position.quantity === 0) {\r\n // Position closed, record the trade\r\n this.positions.delete(order.symbol);\r\n \r\n this.trades.push({\r\n symbol: order.symbol,\r\n entryTime: position.entryTime,\r\n entryPrice: position.avgPrice,\r\n exitTime: this.currentTime,\r\n exitPrice: fillPrice,\r\n quantity: order.quantity,\r\n pnl: pnl,\r\n pnlPercent: (pnl / (position.avgPrice * order.quantity)) * 100\r\n });\r\n \r\n // Update statistics\r\n if (pnl > 0) {\r\n this.winningTrades++;\r\n this.totalProfits += pnl;\r\n } else if (pnl < 0) {\r\n this.losingTrades++;\r\n this.totalLosses -= pnl; // Make positive for easier calculations\r\n } else {\r\n this.breakEvenTrades++;\r\n }\r\n }\r\n }\r\n \r\n // Mark order as filled\r\n order.status = 'FILLED';\r\n order.fillPrice = fillPrice;\r\n order.fillTime = this.currentTime;\r\n this.filledOrders.push(order);\r\n \r\n // Notify strategy\r\n await this.strategy.onOrderFilled(order);\r\n \r\n this.emit('orderFilled', { order });\r\n }\r\n\r\n private updatePositions(currentBar: BarData): void {\r\n // Update the unrealized P&L for positions in this symbol\r\n const position = this.positions.get(currentBar.symbol);\r\n if (position) {\r\n const currentPrice = currentBar.close;\r\n const unrealizedPnL = (currentPrice - position.avgPrice) * position.quantity;\r\n position.unrealizedPnL = unrealizedPnL;\r\n }\r\n \r\n // Calculate total portfolio value\r\n const portfolioValue = this.calculatePortfolioValue();\r\n \r\n // Check for new high water mark\r\n if (portfolioValue > this.highWaterMark) {\r\n this.highWaterMark = portfolioValue;\r\n this.drawdownStartTime = null;\r\n }\r\n \r\n // Check for drawdown\r\n if (this.drawdownStartTime === null && portfolioValue < this.highWaterMark) {\r\n this.drawdownStartTime = this.currentTime;\r\n }\r\n \r\n // Update max drawdown\r\n if (this.highWaterMark > 0) {\r\n const currentDrawdown = (this.highWaterMark - portfolioValue) / this.highWaterMark;\r\n if (currentDrawdown > this.maxDrawdown) {\r\n this.maxDrawdown = currentDrawdown;\r\n \r\n // Calculate drawdown duration\r\n if (this.drawdownStartTime !== null) {\r\n const drawdownDuration = (this.currentTime.getTime() - this.drawdownStartTime.getTime()) / (1000 * 60 * 60 * 24); // In days\r\n if (drawdownDuration > this.maxDrawdownDuration) {\r\n this.maxDrawdownDuration = drawdownDuration;\r\n }\r\n }\r\n }\r\n }\r\n \r\n this.previousPortfolioValue = portfolioValue;\r\n }\r\n\r\n private calculatePortfolioValue(): number {\r\n let totalValue = this.currentCapital;\r\n \r\n // Add the current value of all positions\r\n for (const [symbol, position] of this.positions.entries()) {\r\n // Find the latest price for this symbol\r\n const bars = this.marketData.get(symbol);\r\n if (bars && bars.length > 0) {\r\n const latestBar = bars[bars.length - 1];\r\n totalValue += position.quantity * latestBar.close;\r\n } else {\r\n // If no price data, use the average price (not ideal but better than nothing)\r\n totalValue += position.quantity * position.avgPrice;\r\n }\r\n }\r\n \r\n return totalValue;\r\n }\r\n\r\n private calculateDailyReturn(): void {\r\n const portfolioValue = this.calculatePortfolioValue();\r\n const dailyReturn = (portfolioValue - this.previousPortfolioValue) / this.previousPortfolioValue;\r\n \r\n this.dailyReturns.push({\r\n date: new Date(this.currentTime),\r\n return: dailyReturn\r\n });\r\n \r\n this.previousPortfolioValue = portfolioValue;\r\n }\r\n\r\n private async closeAllPositions(): Promise {\r\n for (const [symbol, position] of this.positions.entries()) {\r\n // Find the latest price\r\n const bars = this.marketData.get(symbol);\r\n if (!bars || bars.length === 0) continue;\r\n \r\n const lastBar = bars[bars.length - 1];\r\n const closePrice = lastBar.close;\r\n \r\n // Calculate P&L\r\n const pnl = (closePrice - position.avgPrice) * position.quantity;\r\n \r\n // Update cash\r\n this.currentCapital += position.quantity * closePrice;\r\n \r\n // Record the trade\r\n this.trades.push({\r\n symbol,\r\n entryTime: position.entryTime,\r\n entryPrice: position.avgPrice,\r\n exitTime: this.currentTime,\r\n exitPrice: closePrice,\r\n quantity: position.quantity,\r\n pnl,\r\n pnlPercent: (pnl / (position.avgPrice * position.quantity)) * 100\r\n });\r\n \r\n // Update statistics\r\n if (pnl > 0) {\r\n this.winningTrades++;\r\n this.totalProfits += pnl;\r\n } else if (pnl < 0) {\r\n this.losingTrades++;\r\n this.totalLosses -= pnl; // Make positive for easier calculations\r\n } else {\r\n this.breakEvenTrades++;\r\n }\r\n }\r\n \r\n // Clear positions\r\n this.positions.clear();\r\n }\r\n\r\n private updateProgress(progress: number): void {\r\n const currentPortfolioValue = this.calculatePortfolioValue();\r\n const currentDrawdown = this.highWaterMark > 0 \r\n ? (this.highWaterMark - currentPortfolioValue) / this.highWaterMark\r\n : 0;\r\n \r\n const elapsedMs = Date.now() - this.startTime;\r\n const totalEstimatedMs = elapsedMs / progress;\r\n const remainingMs = totalEstimatedMs - elapsedMs;\r\n \r\n this.emit('progress', {\r\n progress: progress * 100,\r\n currentDate: this.currentTime,\r\n processingSpeed: this.processedBars / (elapsedMs / 1000),\r\n estimatedTimeRemaining: remainingMs,\r\n currentCapital: this.currentCapital,\r\n currentReturn: (currentPortfolioValue - this.initialCapital) / this.initialCapital,\r\n currentDrawdown\r\n } as BacktestProgress);\r\n }\r\n\r\n private generateResults(): BacktestResult {\r\n const currentPortfolioValue = this.calculatePortfolioValue();\r\n const totalReturn = (currentPortfolioValue - this.initialCapital) / this.initialCapital;\r\n \r\n // Calculate annualized return\r\n const days = (this.config.endDate.getTime() - this.config.startDate.getTime()) / (1000 * 60 * 60 * 24);\r\n const annualizedReturn = Math.pow(1 + totalReturn, 365 / days) - 1;\r\n \r\n // Calculate Sharpe Ratio\r\n let sharpeRatio = 0;\r\n if (this.dailyReturns.length > 1) {\r\n const dailyReturnValues = this.dailyReturns.map(dr => dr.return);\r\n const avgDailyReturn = dailyReturnValues.reduce((sum, ret) => sum + ret, 0) / dailyReturnValues.length;\r\n const stdDev = Math.sqrt(\r\n dailyReturnValues.reduce((sum, ret) => sum + Math.pow(ret - avgDailyReturn, 2), 0) / dailyReturnValues.length\r\n );\r\n \r\n // Annualize\r\n sharpeRatio = stdDev > 0 \r\n ? (avgDailyReturn * 252) / (stdDev * Math.sqrt(252)) \r\n : 0;\r\n }\r\n \r\n // Calculate win rate and profit factor\r\n const totalTrades = this.winningTrades + this.losingTrades + this.breakEvenTrades;\r\n const winRate = totalTrades > 0 ? this.winningTrades / totalTrades : 0;\r\n const profitFactor = this.totalLosses > 0 ? this.totalProfits / this.totalLosses : (this.totalProfits > 0 ? Infinity : 0);\r\n \r\n // Calculate average winning and losing trade\r\n const avgWinningTrade = this.winningTrades > 0 ? this.totalProfits / this.winningTrades : 0;\r\n const avgLosingTrade = this.losingTrades > 0 ? this.totalLosses / this.losingTrades : 0;\r\n \r\n return {\r\n strategyId: this.strategy.id,\r\n startDate: this.config.startDate,\r\n endDate: this.config.endDate,\r\n duration: Date.now() - this.startTime,\r\n initialCapital: this.initialCapital,\r\n finalCapital: currentPortfolioValue,\r\n totalReturn,\r\n annualizedReturn,\r\n sharpeRatio,\r\n maxDrawdown: this.maxDrawdown,\r\n maxDrawdownDuration: this.maxDrawdownDuration,\r\n winRate,\r\n totalTrades,\r\n winningTrades: this.winningTrades,\r\n losingTrades: this.losingTrades,\r\n averageWinningTrade: avgWinningTrade,\r\n averageLosingTrade: avgLosingTrade,\r\n profitFactor,\r\n dailyReturns: this.dailyReturns,\r\n trades: this.trades\r\n };\r\n }\r\n}\r\n\n\n Make sure your oldString matches exactly what's in the file or can be found with flexible whitespace. Check for differences in indentation, line endings, or special characters.", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01L4mieXjkwoqWM3cYa5JUvC__vscode-1748915937108": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "AY", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Lines ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "0", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " to ", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "50", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " (", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "621", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": " lines total):", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 54, - "text": "```typescript\n", - "references": [ - { - "anchor": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - ], - "lineBreakBefore": true - } - ], - "props": { - "priority": 54 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 53, - "text": "// filepath: g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 53 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 52, - "text": "import { EventEmitter } from 'events';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 52 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 51, - "text": "import { OHLCV, Order, Position } from '@stock-bot/shared-types';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 51 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 50, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 50 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 49, - "text": "// Define additional types needed for backtesting\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 49 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 48, - "text": "export interface BarData extends OHLCV {}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 48 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 47, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 47 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 46, - "text": "export interface BacktestPosition extends Position {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 46 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 45, - "text": " entryTime: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 45 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 44, - "text": " side: 'LONG' | 'SHORT';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 44 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 43, - "text": " avgPrice: number; // Alias for averagePrice for backward compatibility\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 43 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 42, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 42 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 41, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 41 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 40, - "text": "export interface StrategyInterface {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 40 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 39, - "text": " id: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 39 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 38, - "text": " start(): Promise;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 38 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 37, - "text": " stop(): Promise;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 37 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 36, - "text": " onBar(bar: BarData): Promise;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 36 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 35, - "text": " onOrderFilled(order: Order): Promise;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 35 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 34, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 34 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 33, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 33 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 32, - "text": "export interface BacktestConfig {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 32 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 31, - "text": " startDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 31 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 30, - "text": " endDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 30 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 29, - "text": " symbols: string[];\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 29 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 28, - "text": " initialCapital: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 28 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 27, - "text": " commission: number; // Per trade commission (percentage)\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 27 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 26, - "text": " slippage: number; // Slippage model (percentage)\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 26 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 25, - "text": " dataResolution: '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 25 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 24, - "text": " mode: 'event' | 'vector';\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 24 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 23, - "text": "}\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 23 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 22, - "text": "\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 22 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 21, - "text": "export interface BacktestResult {\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 21 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 20, - "text": " strategyId: string;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 20 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 19, - "text": " startDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 19 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 18, - "text": " endDate: Date;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 18 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 17, - "text": " duration: number; // In milliseconds\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 17 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 16, - "text": " initialCapital: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 16 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 15, - "text": " finalCapital: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 15 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 14, - "text": " totalReturn: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 14 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 13, - "text": " annualizedReturn: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 13 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 12, - "text": " sharpeRatio: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 12 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 11, - "text": " maxDrawdown: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 11 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 10, - "text": " maxDrawdownDuration: number; // In days\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 10 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9, - "text": " winRate: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 9 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 8, - "text": " totalTrades: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 8 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 7, - "text": " winningTrades: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 7 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 6, - "text": " losingTrades: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 6 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 5, - "text": " averageWinningTrade: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 5 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 4, - "text": " averageLosingTrade: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 4 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 3, - "text": " profitFactor: number;\r\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 3 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 2, - "text": " dailyReturns: Array<{ date: Date; return: number }>;\n", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 2 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 54, - "text": "```", - "references": [], - "lineBreakBefore": true - } - ], - "props": { - "priority": 54 - }, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01BRFpPDWcjWsQ8moAvKiNG7__vscode-1748915937109": { - "$mid": 20, - "content": [ - { - "$mid": 21, - "value": "ERROR while calling tool: File already exists. You must use an edit tool to modify it.\nPlease check your input and try again." - } - ] - }, - "toolu_vrtx_012Fy3a1BvkNbrntkGkrTBaJ__vscode-1748915937110": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "mm", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Applying the proposed edit resulted in the following diagnostics:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "vk", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1445 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "Ay", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private positions = new Map();\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1446 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Declaration or statement expected.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1446 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n this.currentTime = new Date(config.startDate);\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1447 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Cannot find name 'BaseStrategy'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1447 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n } catch (error) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1448 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Cannot find name 'BaseStrategy'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1448 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n this.currentTime = bar.timestamp;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1449 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'mode' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1449 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n }\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1450 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'symbols' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1450 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private async processOrders(currentBar: BarData): Promise {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1451 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1451 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Remove these orders from pendingOrders\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1452 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1452 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n }\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1453 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1453 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const bar = latestBars.find(b =>\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1454 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, OHLCV[]]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1454 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Position closed, record the trade\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1455 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1455 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n this.positions.delete(order.symbol);\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1456 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1456 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n exitPrice: fillPrice,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1457 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'avgPrice' does not exist in type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1457 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n }\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1458 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1458 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1459 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Use this declaration and other usages as examples.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1459 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private updatePositions(currentBar: BarData): void {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1460 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1460 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const unrealizedPnL = (currentPrice - position.avgPrice) * position.quantity;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1461 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'avgPrice' does not exist on type 'Position'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1461 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Update max drawdown\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1462 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillPrice' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1462 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n if (this.highWaterMark > 0) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1463 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillTime' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1463 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const lastBar = bars[bars.length - 1];\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1464 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, Position]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1464 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Update statistics\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1465 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'return' does not exist in type '{ date: Date; portfolioValue: number; dayReturn: number; }'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1465 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n } else {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1466 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, Position]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1466 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1467 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Use this declaration and other usages as examples.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1467 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n winRate,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1468 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'return' does not exist on type '{ date: Date; portfolioValue: number; dayReturn: number; }'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1468 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1445 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01AsCqJnx3Wq3WLDn3a4UmDn__vscode-1748915937111": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "mm", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Applying the proposed edit resulted in the following diagnostics:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "vk", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1526 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "Ay", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n await this.strategy.start();\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1527 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'start' does not exist on type 'StrategyInterface'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1527 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n side: 'LONG',\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1528 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'side' does not exist in type 'BacktestPosition'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1528 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1529 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Use this declaration and other usages as examples.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1529 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n await this.strategy.onOrderFilled(order);\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1530 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'onOrderFilled' does not exist on type 'StrategyInterface'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1530 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n for (const [symbol, position] of this.positions.entries()) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1531 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, BacktestPosition]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1531 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n for (const [symbol, position] of this.positions.entries()) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1532 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, BacktestPosition]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1532 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1526 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_015o8ED2HDNYin9gv594YFuX__vscode-1748915937112": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "mm", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Applying the proposed edit resulted in the following diagnostics:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "vk", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1598 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "Ay", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Load data based on configured mode\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1599 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'mode' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1599 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Initialize the strategy\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1600 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'start' does not exist on type 'StrategyInterface'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1600 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const allBars = new Map();\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1601 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'symbols' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1601 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private async loadMarketData(): Promise {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1602 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'symbols' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1602 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n for (const symbol of this.config.symbols) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1603 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1603 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n symbol,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1604 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1604 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n if (!hasData) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1605 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1605 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n symbol,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1606 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1606 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n avgPrice: fillPrice,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1607 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'side' does not exist in type 'BacktestPosition'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1607 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1608 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Use this declaration and other usages as examples.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1608 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n order.status = 'FILLED';\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1609 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillPrice' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1609 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n order.fillPrice = fillPrice;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1610 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillTime' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1610 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Notify strategy\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1611 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'onOrderFilled' does not exist on type 'StrategyInterface'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1611 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Add the current value of all positions\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1612 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, BacktestPosition]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1612 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n date: new Date(this.currentTime),\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1613 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'return' does not exist in type '{ date: Date; portfolioValue: number; dayReturn: number; }'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1613 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private async closeAllPositions(): Promise {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1614 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, BacktestPosition]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1614 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1615 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Use this declaration and other usages as examples.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1615 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n if (this.dailyReturns.length > 1) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1616 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'return' does not exist on type '{ date: Date; portfolioValue: number; dayReturn: number; }'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1616 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n return {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1617 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'strategyId' does not exist in type 'BacktestResult'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1617 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1598 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - }, - "toolu_vrtx_01Km7ureNdH5MwEx7rpmYCre__vscode-1748915937113": { - "$mid": 20, - "content": [ - { - "$mid": 21, - "value": "ERROR while calling tool: File already exists. You must use an edit tool to modify it.\nPlease check your input and try again." - } - ] - }, - "toolu_vrtx_01XyVZbRQw16Z5rrtM5YeVvB__vscode-1748915937114": { - "$mid": 20, - "content": [ - { - "$mid": 22, - "value": { - "node": { - "type": 1, - "ctor": 2, - "ctorName": "mm", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "Applying the proposed edit resulted in the following diagnostics:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "vk", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1791 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "Ay", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n }\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1792 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'start' does not exist on type 'StrategyInterface'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1792 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n let maxDrawdown = 0;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1793 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'symbols' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1793 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Apply strategy logic (vectorized implementation would be here)\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1794 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'symbols' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1794 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // For now, we'll just simulate the processing\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1795 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1795 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n private async loadMarketData(): Promise {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1796 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1796 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n symbol,\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1797 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1797 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n if (!hasData) {\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1798 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'dataResolution' does not exist on type 'BacktestConfig'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1798 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n this.emit('loaded', { symbol, count: data.length });\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1799 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, OHLCV[]]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1799 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n existingPosition.quantity = totalShares;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1800 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'side' does not exist in type 'BacktestPosition'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1800 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1801 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Use this declaration and other usages as examples.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1801 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n this.breakEvenTrades++;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1802 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillPrice' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1802 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n }\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1803 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'fillTime' does not exist on type 'Order'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1803 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Mark order as filled\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1804 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'onOrderFilled' does not exist on type 'StrategyInterface'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1804 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n this.previousPortfolioValue = portfolioValue;\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1805 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, BacktestPosition]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1805 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n return: dailyReturn\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1806 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Type 'MapIterator<[string, BacktestPosition]>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1806 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1807 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Use this declaration and other usages as examples.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1807 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n // Calculate annualized return\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1808 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Property 'return' does not exist on type '{ date: Date; portfolioValue: number; dayReturn: number; }'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1808 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "s6e", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "This code", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ot", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "xre", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "```\n const profitFactor = this.totalLosses > 0 ? this.totalProfits / this.totalLosses : (this.totalProfits > 0 ? Infinity : 0);\n```", - "references": [], - "lineBreakBefore": true - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "has the problem reported:", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - }, - { - "type": 1, - "ctor": 2, - "ctorName": "r", - "children": [ - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1809 - }, - { - "type": 1, - "ctor": 2, - "ctorName": "ixe", - "children": [ - { - "type": 2, - "priority": 1, - "text": "Object literal may only specify known properties, and 'strategyId' does not exist in type 'BacktestResult'.", - "lineBreakBefore": false - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1809 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "a6e", - "children": [], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - }, - { - "type": 2, - "priority": 1, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": { - "flexGrow": 1, - "priority": 1 - }, - "references": [] - }, - { - "type": 1, - "ctor": 2, - "ctorName": "", - "children": [ - { - "type": 2, - "priority": 9007199254740991, - "text": "", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [], - "keepWithId": 1791 - }, - { - "type": 2, - "priority": 9007199254740991, - "text": "\n", - "lineBreakBefore": false - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - ], - "props": {}, - "references": [] - } - } - } - ] - } - }, - "modelMessageId": "0a1f3fc7-f9ce-471f-b1a9-724860dc08b3", - "responseId": "b1ee4865-57f5-47d1-8d47-cb3b2be5615c", - "sessionId": "b8852c97-aefb-4e3a-a2e5-4755c925c5cc", - "agentId": "github.copilot.editsAgent" - } - }, - "followups": [], - "isCanceled": false, - "agent": { - "extensionId": { - "value": "GitHub.copilot-chat", - "_lower": "github.copilot-chat" - }, - "publisherDisplayName": "GitHub", - "extensionPublisherId": "GitHub", - "extensionDisplayName": "GitHub Copilot Chat", - "id": "github.copilot.editsAgent", - "description": "Edit files in your workspace in agent mode", - "when": "config.chat.agent.enabled && !chatAgentModeDisallowed", - "metadata": { - "themeIcon": { - "id": "tools" - }, - "hasFollowups": false, - "supportIssueReporting": false - }, - "name": "agent", - "fullName": "GitHub Copilot", - "isDefault": true, - "locations": [ - "panel" - ], - "modes": [ - "agent" - ], - "slashCommands": [], - "disambiguation": [] - }, - "contentReferences": [ - { - "kind": "reference", - "reference": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\package.json", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/package.json", - "scheme": "file" - } - }, - { - "kind": "reference", - "reference": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\strategy-orchestrator\\src\\core\\backtesting\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/strategy-orchestrator/src/core/backtesting/BacktestEngine.ts", - "scheme": "file" - } - } - ], - "codeCitations": [], - "timestamp": 1748916774748, - "confirmation": "Continue" - }, - { - "requestId": "request_f3ce8f6f-b814-4c50-9287-9a7f7cc0c76c", - "message": { - "parts": [ - { - "range": { - "start": 0, - "endExclusive": 68 - }, - "editorRange": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 1, - "endColumn": 69 - }, - "text": "using my project structure what are recommendations for improving it", - "kind": "text" - } - ], - "text": "using my project structure what are recommendations for improving it" - }, - "variableData": { - "variables": [ - { - "kind": "file", - "id": "vscode.implicit.viewport", - "name": "file:PerformanceAnalytics.ts", - "value": { - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\PerformanceAnalytics.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/PerformanceAnalytics.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/PerformanceAnalytics.ts", - "scheme": "file" - }, - "range": { - "startLineNumber": 1, - "startColumn": 1, - "endLineNumber": 44, - "endColumn": 94 - } - }, - "modelDescription": "User's current visible code" - } - ] - }, - "response": [ - { - "value": "Looking at your project structure and the current code, I can see you're building a sophisticated stock trading bot with microservices architecture. Here are my recommendations for improving the structure:\n\n## 1. **Complete Service Separation** \n\nCurrently, your intelligence services are not properly separated. The `strategy-orchestrator` is doing everything while `backtest-engine` and `signal-engine` are mostly empty.\n\n````typescript\n// Recommended structure:\n\n// apps/intelligence-services/strategy-orchestrator/\n// - Core strategy management and coordination\n// - Strategy CRUD operations\n// - Orchestrates calls to other services\n\n// apps/intelligence-services/backtest-engine/\n// - Dedicated backtesting service\n// - Performance analytics\n// - Historical data processing\n\n// apps/intelligence-services/signal-engine/\n// - Real-time signal generation\n// - Technical indicator calculations\n// - Market data streaming\n````\n\n## 2. **Shared Library Structure**\n\nYour current shared libraries need better organization:\n\n````typescript\n// libs/shared/\n├── types/\n│ ├── trading/ // Trading-specific types\n│ ├── market-data/ // Market data types\n│ ├── strategy/ // Strategy types\n│ └── common/ // Generic types\n├── utils/\n│ ├── validation/ // Input validation utilities\n│ ├── formatting/ // Data formatting\n│ ├── math/ // Mathematical utilities\n│ └── date/ // Date/time utilities\n├── constants/\n│ ├── trading/ // Trading constants\n│ ├── market/ // Market constants\n│ └── system/ // System constants\n└── interfaces/\n ├── services/ // Service interfaces\n ├── repositories/ // Data access interfaces\n └── external/ // External API interfaces\n````\n\n## 3. **Configuration Management**\n\nCreate a centralized configuration system:\n\n````typescript\n// libs/config/\n├── base.config.ts // Base configuration\n├── development.config.ts\n├── production.config.ts\n├── test.config.ts\n└── index.ts\n\n// Example structure:\nexport interface AppConfig {\n services: {\n strategyOrchestrator: ServiceConfig;\n backtestEngine: ServiceConfig;\n signalEngine: ServiceConfig;\n marketDataService: ServiceConfig;\n };\n database: DatabaseConfig;\n redis: RedisConfig;\n external: {\n alphaVantage: ExternalServiceConfig;\n polygonIo: ExternalServiceConfig;\n };\n}\n````\n\n## 4. **Error Handling & Logging**\n\nImplement centralized error handling and logging:\n\n````typescript\n// libs/logging/\n├── logger.ts\n├── error-handler.ts\n└── metrics.ts\n\n// libs/errors/\n├── base-error.ts\n├── trading-errors.ts\n├── market-data-errors.ts\n└── validation-errors.ts\n````\n\n## 5. **Database Layer Improvements**\n\nCreate a proper data access layer:\n\n````typescript\n// libs/database/\n├── entities/\n│ ├── strategy.entity.ts\n│ ├── backtest-result.entity.ts\n│ ├── trade.entity.ts\n│ └── market-data.entity.ts\n├── repositories/\n│ ├── base.repository.ts\n│ ├── strategy.repository.ts\n│ ├── backtest.repository.ts\n│ └── trade.repository.ts\n├── migrations/\n└── seeders/\n````\n\n## 6. **API Gateway Pattern**\n\nAdd an API gateway for better service orchestration:\n\n````typescript\n// apps/api-gateway/\n├── src/\n│ ├── routes/\n│ │ ├── strategy.routes.ts\n│ │ ├── backtest.routes.ts\n│ │ └── signal.routes.ts\n│ ├── middleware/\n│ │ ├── auth.middleware.ts\n│ │ ├── rate-limit.middleware.ts\n│ │ └── validation.middleware.ts\n│ └── services/\n│ └── service-discovery.ts\n````\n\n## 7. **Testing Structure**\n\nImprove your testing organization:\n\n````typescript\n// Each service should have:\n├── src/\n└── tests/\n ├── unit/ // Unit tests\n ├── integration/ // Integration tests\n ├── e2e/ // End-to-end tests\n ├── fixtures/ // Test data\n └── helpers/ // Test utilities\n````\n\n## 8. **Docker & DevOps Improvements**\n\nCreate service-specific Dockerfiles and improve orchestration:\n\n````dockerfile\n# apps/intelligence-services/strategy-orchestrator/Dockerfile\n# apps/intelligence-services/backtest-engine/Dockerfile\n# apps/intelligence-services/signal-engine/Dockerfile\n\n# docker-compose.yml - for local development\n# docker-compose.prod.yml - for production\n````\n\n## 9. **Event-Driven Architecture**\n\nImplement proper event handling between services:\n\n````typescript\n// libs/events/\n├── event-bus.ts\n├── events/\n│ ├── strategy.events.ts\n│ ├── signal.events.ts\n│ └── trade.events.ts\n└── handlers/\n ├── base.handler.ts\n └── strategy.handler.ts\n````\n\n## 10. **Security Improvements**\n\nAdd proper security layers:\n\n````typescript\n// libs/security/\n├── auth/\n│ ├── jwt.service.ts\n│ ├── auth.guard.ts\n│ └── roles.decorator.ts\n├── encryption/\n│ ├── crypto.service.ts\n│ └── api-key.service.ts\n└── validation/\n ├── input.validator.ts\n └── sanitizer.ts\n````\n\n## 11. **Monitoring & Observability**\n\nAdd comprehensive monitoring:\n\n````typescript\n// libs/monitoring/\n├── health-check.ts\n├── metrics.service.ts\n├── tracing.service.ts\n└── alerts.service.ts\n````\n\n## 12. **Caching Strategy**\n\nImplement proper caching:\n\n````typescript\n// libs/cache/\n├── redis.service.ts\n├── cache.decorator.ts\n├── cache.strategies.ts\n└── memory.cache.ts\n````\n\n## 13. **Data Pipeline**\n\nCreate a proper data pipeline for market data:\n\n````typescript\n// apps/data-pipeline/\n├── ingestion/ // Data ingestion services\n├── processing/ // Data processing\n├── storage/ // Data storage strategies\n└── validation/ // Data quality checks\n````\n\n## 14. **Performance Optimizations**\n\nFor your ", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - }, - { - "kind": "inlineReference", - "inlineReference": { - "name": "PerformanceAnalytics", - "kind": 12, - "containerName": "", - "location": { - "range": { - "startLineNumber": 8, - "startColumn": 14, - "endLineNumber": 8, - "endColumn": 14 - }, - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\PerformanceAnalytics.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/PerformanceAnalytics.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/PerformanceAnalytics.ts", - "scheme": "file" - } - } - }, - "resolveId": "b12216be-8608-4616-a032-d9cf826da025" - }, - { - "value": " class, consider:\n\n````typescript\n// Add memoization for expensive calculations\n// Use streaming calculations for large datasets\n// Implement parallel processing for multiple backtests\n\nexport class PerformanceAnalytics {\n private static cache = new Map();\n \n static enhanceResults(result: BacktestResult): BacktestResult {\n const cacheKey = this.generateCacheKey(result);\n \n if (this.cache.has(cacheKey)) {\n return this.cache.get(cacheKey);\n }\n \n const enhanced = {\n ...result,\n ...this.calculateAdvancedMetrics(result)\n };\n \n this.cache.set(cacheKey, enhanced);\n return enhanced;\n }\n \n // Add streaming calculations for better memory usage\n static calculateMetricsStream(returns: AsyncIterable): Promise {\n // Stream processing implementation\n }\n}\n````\n\n## Implementation Priority\n\n1. **High Priority**: Complete service separation, error handling, configuration management\n2. **Medium Priority**: Database layer, testing structure, API gateway\n3. **Low Priority**: Monitoring, caching, performance optimizations\n\nWould you like me to help implement any of these specific improvements? I can start with the service separation or any other area you'd like to focus on first.", - "supportThemeIcons": false, - "supportHtml": false, - "baseUri": { - "$mid": 1, - "path": "/g:/repos/stock-bot/", - "scheme": "file" - } - } - ], - "responseId": "response_47c9e2fa-1875-4d38-88c9-ccabd9b04aa9", - "result": { - "timings": { - "firstProgress": 1067, - "totalElapsed": 21259 - }, - "metadata": { - "codeBlocks": [ - { - "code": "// Recommended structure:\n\n// apps/intelligence-services/strategy-orchestrator/\n// - Core strategy management and coordination\n// - Strategy CRUD operations\n// - Orchestrates calls to other services\n\n// apps/intelligence-services/backtest-engine/\n// - Dedicated backtesting service\n// - Performance analytics\n// - Historical data processing\n\n// apps/intelligence-services/signal-engine/\n// - Real-time signal generation\n// - Technical indicator calculations\n// - Market data streaming\n", - "language": "typescript", - "markdownBeforeBlock": "Looking at your project structure and the current code, I can see you're building a sophisticated stock trading bot with microservices architecture. Here are my recommendations for improving the structure:\n\n## 1. **Complete Service Separation** \n\nCurrently, your intelligence services are not properly separated. The `strategy-orchestrator` is doing everything while `backtest-engine` and `signal-engine` are mostly empty.\n\n" - }, - { - "code": "// libs/shared/\n├── types/\n│ ├── trading/ // Trading-specific types\n│ ├── market-data/ // Market data types\n│ ├── strategy/ // Strategy types\n│ └── common/ // Generic types\n├── utils/\n│ ├── validation/ // Input validation utilities\n│ ├── formatting/ // Data formatting\n│ ├── math/ // Mathematical utilities\n│ └── date/ // Date/time utilities\n├── constants/\n│ ├── trading/ // Trading constants\n│ ├── market/ // Market constants\n│ └── system/ // System constants\n└── interfaces/\n ├── services/ // Service interfaces\n ├── repositories/ // Data access interfaces\n └── external/ // External API interfaces\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 2. **Shared Library Structure**\n\nYour current shared libraries need better organization:\n\n" - }, - { - "code": "// libs/config/\n├── base.config.ts // Base configuration\n├── development.config.ts\n├── production.config.ts\n├── test.config.ts\n└── index.ts\n\n// Example structure:\nexport interface AppConfig {\n services: {\n strategyOrchestrator: ServiceConfig;\n backtestEngine: ServiceConfig;\n signalEngine: ServiceConfig;\n marketDataService: ServiceConfig;\n };\n database: DatabaseConfig;\n redis: RedisConfig;\n external: {\n alphaVantage: ExternalServiceConfig;\n polygonIo: ExternalServiceConfig;\n };\n}\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 3. **Configuration Management**\n\nCreate a centralized configuration system:\n\n" - }, - { - "code": "// libs/logging/\n├── logger.ts\n├── error-handler.ts\n└── metrics.ts\n\n// libs/errors/\n├── base-error.ts\n├── trading-errors.ts\n├── market-data-errors.ts\n└── validation-errors.ts\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 4. **Error Handling & Logging**\n\nImplement centralized error handling and logging:\n\n" - }, - { - "code": "// libs/database/\n├── entities/\n│ ├── strategy.entity.ts\n│ ├── backtest-result.entity.ts\n│ ├── trade.entity.ts\n│ └── market-data.entity.ts\n├── repositories/\n│ ├── base.repository.ts\n│ ├── strategy.repository.ts\n│ ├── backtest.repository.ts\n│ └── trade.repository.ts\n├── migrations/\n└── seeders/\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 5. **Database Layer Improvements**\n\nCreate a proper data access layer:\n\n" - }, - { - "code": "// apps/api-gateway/\n├── src/\n│ ├── routes/\n│ │ ├── strategy.routes.ts\n│ │ ├── backtest.routes.ts\n│ │ └── signal.routes.ts\n│ ├── middleware/\n│ │ ├── auth.middleware.ts\n│ │ ├── rate-limit.middleware.ts\n│ │ └── validation.middleware.ts\n│ └── services/\n│ └── service-discovery.ts\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 6. **API Gateway Pattern**\n\nAdd an API gateway for better service orchestration:\n\n" - }, - { - "code": "// Each service should have:\n├── src/\n└── tests/\n ├── unit/ // Unit tests\n ├── integration/ // Integration tests\n ├── e2e/ // End-to-end tests\n ├── fixtures/ // Test data\n └── helpers/ // Test utilities\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 7. **Testing Structure**\n\nImprove your testing organization:\n\n" - }, - { - "code": "# apps/intelligence-services/strategy-orchestrator/Dockerfile\n# apps/intelligence-services/backtest-engine/Dockerfile\n# apps/intelligence-services/signal-engine/Dockerfile\n\n# docker-compose.yml - for local development\n# docker-compose.prod.yml - for production\n", - "language": "dockerfile", - "markdownBeforeBlock": "\n## 8. **Docker & DevOps Improvements**\n\nCreate service-specific Dockerfiles and improve orchestration:\n\n" - }, - { - "code": "// libs/events/\n├── event-bus.ts\n├── events/\n│ ├── strategy.events.ts\n│ ├── signal.events.ts\n│ └── trade.events.ts\n└── handlers/\n ├── base.handler.ts\n └── strategy.handler.ts\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 9. **Event-Driven Architecture**\n\nImplement proper event handling between services:\n\n" - }, - { - "code": "// libs/security/\n├── auth/\n│ ├── jwt.service.ts\n│ ├── auth.guard.ts\n│ └── roles.decorator.ts\n├── encryption/\n│ ├── crypto.service.ts\n│ └── api-key.service.ts\n└── validation/\n ├── input.validator.ts\n └── sanitizer.ts\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 10. **Security Improvements**\n\nAdd proper security layers:\n\n" - }, - { - "code": "// libs/monitoring/\n├── health-check.ts\n├── metrics.service.ts\n├── tracing.service.ts\n└── alerts.service.ts\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 11. **Monitoring & Observability**\n\nAdd comprehensive monitoring:\n\n" - }, - { - "code": "// libs/cache/\n├── redis.service.ts\n├── cache.decorator.ts\n├── cache.strategies.ts\n└── memory.cache.ts\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 12. **Caching Strategy**\n\nImplement proper caching:\n\n" - }, - { - "code": "// apps/data-pipeline/\n├── ingestion/ // Data ingestion services\n├── processing/ // Data processing\n├── storage/ // Data storage strategies\n└── validation/ // Data quality checks\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 13. **Data Pipeline**\n\nCreate a proper data pipeline for market data:\n\n" - }, - { - "code": "// Add memoization for expensive calculations\n// Use streaming calculations for large datasets\n// Implement parallel processing for multiple backtests\n\nexport class PerformanceAnalytics {\n private static cache = new Map();\n \n static enhanceResults(result: BacktestResult): BacktestResult {\n const cacheKey = this.generateCacheKey(result);\n \n if (this.cache.has(cacheKey)) {\n return this.cache.get(cacheKey);\n }\n \n const enhanced = {\n ...result,\n ...this.calculateAdvancedMetrics(result)\n };\n \n this.cache.set(cacheKey, enhanced);\n return enhanced;\n }\n \n // Add streaming calculations for better memory usage\n static calculateMetricsStream(returns: AsyncIterable): Promise {\n // Stream processing implementation\n }\n}\n", - "language": "typescript", - "markdownBeforeBlock": "\n## 14. **Performance Optimizations**\n\nFor your class, consider:\n\n" - } - ], - "modelMessageId": "fbd7d0da-e8df-44ed-8c8b-2f4ef723bdf8", - "responseId": "d399d9b3-f2ba-4a7c-9a10-379767d9311a", - "sessionId": "0c6604d9-d786-4b94-9246-6dd7a5bc6f87", - "agentId": "github.copilot.default" - } - }, - "followups": [], - "isCanceled": false, - "agent": { - "extensionId": { - "value": "GitHub.copilot-chat", - "_lower": "github.copilot-chat" - }, - "publisherDisplayName": "GitHub", - "extensionPublisherId": "GitHub", - "extensionDisplayName": "GitHub Copilot Chat", - "id": "github.copilot.default", - "description": "Ask Copilot", - "metadata": { - "themeIcon": { - "id": "copilot" - }, - "hasFollowups": true, - "helpTextPrefix": "You can ask me general programming questions, or chat with the following participants which have specialized expertise and can perform actions:", - "helpTextVariablesPrefix": "You can also help me understand your question by using the following variables to give me extra context:", - "helpTextPostfix": { - "value": "To have a great conversation, ask me questions as if I was a real programmer:\n\n* **Show me the code** you want to talk about by having the files open and selecting the most important lines.\n* **Make refinements** by asking me follow-up questions, adding clarifications, providing errors, etc.\n* **Review my suggested code** and tell me about issues or improvements, so I can iterate on it.\n\nYou can also ask me questions about your editor selection by [starting an inline chat session](command:inlineChat.start).\n\nLearn more about [GitHub Copilot](https://docs.github.com/copilot/using-github-copilot/getting-started-with-github-copilot?tool=vscode&utm_source=editor&utm_medium=chat-panel&utm_campaign=2024q3-em-MSFT-getstarted) in [Visual Studio Code](https://code.visualstudio.com/docs/copilot/overview). Or explore the [Copilot walkthrough](command:github.copilot.open.walkthrough).", - "isTrusted": { - "enabledCommands": [ - "inlineChat.start", - "github.copilot.open.walkthrough" - ] - }, - "supportThemeIcons": false, - "supportHtml": false, - "uris": { - "command:inlineChat.start": { - "$mid": 1, - "path": "inlineChat.start", - "scheme": "command" - }, - "https://docs.github.com/copilot/using-github-copilot/getting-started-with-github-copilot?tool=vscode&utm_source=editor&utm_medium=chat-panel&utm_campaign=2024q3-em-MSFT-getstarted": { - "$mid": 1, - "path": "/copilot/using-github-copilot/getting-started-with-github-copilot", - "scheme": "https", - "authority": "docs.github.com", - "query": "tool=vscode&utm_source=editor&utm_medium=chat-panel&utm_campaign=2024q3-em-MSFT-getstarted" - }, - "https://code.visualstudio.com/docs/copilot/overview": { - "$mid": 1, - "path": "/docs/copilot/overview", - "scheme": "https", - "authority": "code.visualstudio.com" - }, - "command:github.copilot.open.walkthrough": { - "$mid": 1, - "path": "github.copilot.open.walkthrough", - "scheme": "command" - } - } - }, - "supportIssueReporting": false, - "requester": { - "name": "bojank", - "icon": { - "$mid": 1, - "path": "/u/667489", - "scheme": "https", - "authority": "avatars.githubusercontent.com", - "query": "v=4" - } - } - }, - "name": "GitHubCopilot", - "fullName": "GitHub Copilot", - "isDefault": true, - "locations": [ - "panel" - ], - "modes": [ - "ask" - ], - "slashCommands": [], - "disambiguation": [ - { - "category": "generate_code_sample", - "description": "The user wants to generate code snippets without referencing the contents of the current workspace. This category does not include generating entire projects.", - "examples": [ - "Write an example of computing a SHA256 hash." - ] - }, - { - "category": "add_feature_to_file", - "description": "The user wants to change code in a file that is provided in their request, without referencing the contents of the current workspace. This category does not include generating entire projects.", - "examples": [ - "Add a refresh button to the table widget." - ] - }, - { - "category": "question_about_specific_files", - "description": "The user has a question about a specific file or code snippet that they have provided as part of their query, and the question does not require additional workspace context to answer.", - "examples": [ - "What does this file do?" - ] - } - ] - }, - "contentReferences": [ - { - "kind": "reference", - "reference": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\PerformanceAnalytics.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/PerformanceAnalytics.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/PerformanceAnalytics.ts", - "scheme": "file" - } - } - ], - "codeCitations": [], - "timestamp": 1748917096131, - "editedFileEvents": [ - { - "eventKind": 1, - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\package.json", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/package.json", - "scheme": "file" - } - }, - { - "eventKind": 1, - "uri": { - "$mid": 1, - "fsPath": "g:\\repos\\stock-bot\\apps\\intelligence-services\\backtest-engine\\src\\core\\BacktestEngine.ts", - "_sep": 1, - "external": "file:///g%3A/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "path": "/g:/repos/stock-bot/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts", - "scheme": "file" - } - } - ] - } - ] -} \ No newline at end of file diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index e00bef4..8838558 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -218,7 +218,7 @@ WS /ws # WebSocket for strategy updates ### **3. Shared Packages** -#### **Shared Types** (`packages/shared-types`) +#### **Shared Types** (`packages/types`) ```typescript export interface MarketData { symbol: string; diff --git a/CONTEXT.md b/CONTEXT.md index bbdd870..52b8c6b 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -54,7 +54,7 @@ apps/ ### **Shared Packages** ``` packages/ -├── shared-types/ # TypeScript type definitions +├── types/ # TypeScript type definitions ├── config/ # Configuration management ├── database/ # Database utilities (planned) └── trading-core/ # Core trading logic (planned) diff --git a/README.md b/README.md index b881618..6269de6 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ apps/ ### Shared Packages ``` packages/ -├── shared-types/ # TypeScript definitions +├── types/ # TypeScript definitions ├── config/ # Configuration management ├── database/ # (Future) Database utilities └── trading-core/ # (Future) Core trading logic diff --git a/REFACTORING.md b/REFACTORING.md index 71fb179..0f679fc 100644 --- a/REFACTORING.md +++ b/REFACTORING.md @@ -10,7 +10,7 @@ This document outlines the changes made to improve separation of concerns in the ## New Libraries -### 1. `@stock-bot/shared-types` +### 1. `@stock-bot/types` Domain-specific type definitions organized by functional area: - `market/` - Market data structures (OHLCV, OrderBook, etc.) - `trading/` - Trading types (Orders, Positions, etc.) diff --git a/apps/core-services/market-data-gateway/package.json b/apps/core-services/market-data-gateway/package.json index fbdc269..413a8ab 100644 --- a/apps/core-services/market-data-gateway/package.json +++ b/apps/core-services/market-data-gateway/package.json @@ -30,7 +30,7 @@ "dotenv": "^16.3.0", "@stock-bot/http-client": "*", "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "@stock-bot/event-bus": "*", "@stock-bot/utils": "*" }, diff --git a/apps/core-services/market-data-gateway/src/services/EventPublisher.ts b/apps/core-services/market-data-gateway/src/services/EventPublisher.ts index 6c70cf8..4c679a5 100644 --- a/apps/core-services/market-data-gateway/src/services/EventPublisher.ts +++ b/apps/core-services/market-data-gateway/src/services/EventPublisher.ts @@ -1,6 +1,6 @@ import Redis from 'ioredis'; import { databaseConfig } from '@stock-bot/config'; -import type { MarketDataEvent, SignalEvent, TradingEvent } from '@stock-bot/shared-types'; +import type { MarketDataEvent, SignalEvent, TradingEvent } from '@stock-bot/types'; export class EventPublisher { private dragonfly: Redis; diff --git a/apps/core-services/market-data-gateway/src/services/MarketDataService.ts b/apps/core-services/market-data-gateway/src/services/MarketDataService.ts index aa938d8..aacee20 100644 --- a/apps/core-services/market-data-gateway/src/services/MarketDataService.ts +++ b/apps/core-services/market-data-gateway/src/services/MarketDataService.ts @@ -1,4 +1,4 @@ -import type { MarketData, OHLCV, MarketDataEvent } from '@stock-bot/shared-types'; +import type { MarketData, OHLCV, MarketDataEvent } from '@stock-bot/types'; import { dataProviderConfigs } from '@stock-bot/config'; import { EventPublisher } from './EventPublisher'; import { DataNormalizer } from './DataNormalizer'; diff --git a/apps/core-services/market-data-gateway/src/types/MarketDataGateway.ts b/apps/core-services/market-data-gateway/src/types/MarketDataGateway.ts index bf3ae59..dabd1eb 100644 --- a/apps/core-services/market-data-gateway/src/types/MarketDataGateway.ts +++ b/apps/core-services/market-data-gateway/src/types/MarketDataGateway.ts @@ -1,3 +1,5 @@ +// Market Data Gateway Types - Consolidated and organized + // Market Data Types export interface MarketDataTick { symbol: string; @@ -34,6 +36,18 @@ export interface MarketDataCandle { trades?: number; } +export interface MarketDataTrade { + id: string; + symbol: string; + timestamp: number; + price: number; + size: number; + side: 'buy' | 'sell'; + source: string; + exchange?: string; + conditions?: string[]; +} + export interface MarketDataOrder { id: string; symbol: string; @@ -47,18 +61,6 @@ export interface MarketDataOrder { level?: number; } -export interface MarketDataTrade { - id: string; - symbol: string; - timestamp: number; - price: number; - size: number; - side: 'buy' | 'sell'; - source: string; - exchange?: string; - conditions?: string[]; -} - // Data Source Configuration export interface DataSourceConfig { id: string; @@ -129,6 +131,36 @@ export interface ProcessingPipeline { }; } +// Data Processing Pipeline +export interface DataProcessor { + id: string; + name: string; + type: 'enrichment' | 'validation' | 'normalization' | 'aggregation' | 'filter'; + enabled: boolean; + priority: number; + config: Record; + process(data: MarketDataTick | MarketDataCandle | MarketDataTrade): Promise; +} + +export interface ProcessingPipeline { + id: string; + name: string; + processors: DataProcessor[]; + inputFilter: { + symbols?: string[]; + sources?: string[]; + dataTypes?: string[]; + }; + outputTargets: { + eventBus?: boolean; + database?: boolean; + cache?: boolean; + websocket?: boolean; + dataProcessor?: boolean; + featureStore?: boolean; + }; +} + // Subscription Management export interface SubscriptionRequest { id: string; @@ -200,94 +232,29 @@ export interface GatewayConfig { monitoring: { metrics: { enabled: boolean; - port: number; - path: string; - }; - logging: { - level: 'debug' | 'info' | 'warn' | 'error'; - format: 'json' | 'text'; - outputs: ('console' | 'file' | 'elasticsearch')[]; + intervalMs: number; + retention: string; }; alerts: { enabled: boolean; thresholds: { - latencyMs: number; errorRate: number; + latency: number; connectionLoss: number; }; }; }; } -// WebSocket Message Types -export interface WebSocketMessage { - type: 'subscribe' | 'unsubscribe' | 'data' | 'error' | 'heartbeat' | 'status'; - id?: string; - timestamp: number; - payload: any; -} - -export interface WebSocketSubscribeMessage extends WebSocketMessage { - type: 'subscribe'; - payload: { - symbols: string[]; - dataTypes: string[]; - filters?: Record; - }; -} - -export interface WebSocketDataMessage extends WebSocketMessage { - type: 'data'; - payload: { - dataType: string; - data: MarketDataTick | MarketDataCandle | MarketDataTrade | MarketDataOrder; - }; -} - -// Error Handling -export interface DataSourceError { - sourceId: string; - timestamp: Date; - type: 'connection' | 'authentication' | 'ratelimit' | 'data' | 'timeout'; - message: string; - details?: Record; - severity: 'low' | 'medium' | 'high' | 'critical'; -} - -export interface ProcessingError { - processorId: string; - pipelineId: string; - timestamp: Date; - data: any; - error: string; - stackTrace?: string; -} - // Metrics and Monitoring export interface DataSourceMetrics { sourceId: string; - timestamp: Date; - connections: { - active: number; - total: number; - failed: number; - }; - messages: { - received: number; - processed: number; - errors: number; - dropped: number; - }; - latency: { - avgMs: number; - p50Ms: number; - p95Ms: number; - p99Ms: number; - }; - bandwidth: { - inboundBytesPerSecond: number; - outboundBytesPerSecond: number; - }; + status: 'connected' | 'disconnected' | 'error'; + messagesReceived: number; + bytesReceived: number; + latencyMs: number; + errorCount: number; + lastUpdate: Date; } export interface GatewayMetrics { @@ -316,52 +283,6 @@ export interface GatewayMetrics { }; } -// Service Integration -export interface ServiceIntegration { - serviceName: string; - endpoint: string; - healthCheck: string; - authentication?: { - type: 'apikey' | 'jwt' | 'basic'; - credentials: Record; - }; - retryPolicy: { - maxRetries: number; - backoffMs: number; - }; -} - -export interface DataProcessorIntegration extends ServiceIntegration { - serviceName: 'data-processor'; - supportedOperations: ('ingest' | 'transform' | 'validate' | 'quality')[]; -} - -export interface FeatureStoreIntegration extends ServiceIntegration { - serviceName: 'feature-store'; - supportedOperations: ('compute' | 'store' | 'retrieve')[]; -} - -export interface DataCatalogIntegration extends ServiceIntegration { - serviceName: 'data-catalog'; - supportedOperations: ('register' | 'lineage' | 'quality' | 'governance')[]; -} - -// Event Bus Integration -export interface EventBusMessage { - id: string; - type: string; - source: string; - timestamp: Date; - data: any; - metadata?: Record; -} - -export interface MarketDataEvent extends EventBusMessage { - type: 'market.tick' | 'market.trade' | 'market.candle' | 'market.orderbook'; - source: 'market-data-gateway'; - data: MarketDataTick | MarketDataTrade | MarketDataCandle | MarketDataOrder; -} - // Health Check export interface HealthStatus { service: string; @@ -382,3 +303,42 @@ export interface HealthStatus { avgLatencyMs: number; }; } + +// WebSocket Types +export interface WebSocketMessage { + type: string; + payload: any; + timestamp: number; + id?: string; +} + +export interface WebSocketSubscribeMessage extends WebSocketMessage { + type: 'subscribe'; + payload: SubscriptionRequest; +} + +export interface WebSocketDataMessage extends WebSocketMessage { + type: 'data'; + payload: MarketDataTick | MarketDataTrade | MarketDataCandle | MarketDataOrder; +} + +// Error Types +export interface DataSourceError { + sourceId: string; + timestamp: Date; + type: 'connection' | 'authentication' | 'ratelimit' | 'data' | 'timeout'; + message: string; + details?: Record; + severity: 'low' | 'medium' | 'high' | 'critical'; + recoverable: boolean; +} + +// Event Types +export interface MarketDataEvent { + id: string; + type: 'market.tick' | 'market.trade' | 'market.candle' | 'market.orderbook'; + source: 'market-data-gateway'; + timestamp: Date; + data: MarketDataTick | MarketDataTrade | MarketDataCandle | MarketDataOrder; + metadata?: Record; +} diff --git a/apps/core-services/risk-guardian/package.json b/apps/core-services/risk-guardian/package.json index 4efa1c7..9760927 100644 --- a/apps/core-services/risk-guardian/package.json +++ b/apps/core-services/risk-guardian/package.json @@ -12,7 +12,7 @@ "hono": "^4.6.3", "ioredis": "^5.4.1", "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "ws": "^8.18.0" }, "devDependencies": { diff --git a/apps/data-services/data-catalog/package.json b/apps/data-services/data-catalog/package.json index 2519b8c..f7fcb1a 100644 --- a/apps/data-services/data-catalog/package.json +++ b/apps/data-services/data-catalog/package.json @@ -13,7 +13,7 @@ "type-check": "tsc --noEmit" }, "dependencies": { - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "@stock-bot/utils": "workspace:*", "@stock-bot/event-bus": "workspace:*", "@stock-bot/api-client": "workspace:*", diff --git a/apps/data-services/data-processor/package.json b/apps/data-services/data-processor/package.json index c557490..e1751a6 100644 --- a/apps/data-services/data-processor/package.json +++ b/apps/data-services/data-processor/package.json @@ -12,7 +12,7 @@ "type-check": "tsc --noEmit" }, "dependencies": { - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "@stock-bot/event-bus": "*", "@stock-bot/utils": "*", "@stock-bot/api-client": "*", diff --git a/apps/data-services/feature-store/package.json b/apps/data-services/feature-store/package.json index d7b1d1c..53f541a 100644 --- a/apps/data-services/feature-store/package.json +++ b/apps/data-services/feature-store/package.json @@ -12,7 +12,7 @@ "type-check": "tsc --noEmit" }, "dependencies": { - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "@stock-bot/event-bus": "*", "@stock-bot/utils": "*", "@stock-bot/api-client": "*", diff --git a/apps/intelligence-services/backtest-engine/package.json b/apps/intelligence-services/backtest-engine/package.json index 4700953..c0bb127 100644 --- a/apps/intelligence-services/backtest-engine/package.json +++ b/apps/intelligence-services/backtest-engine/package.json @@ -10,7 +10,7 @@ "test:watch": "bun test --watch src/tests/**/*.test.ts" }, "dependencies": { "hono": "^4.6.3", - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "@stock-bot/utils": "workspace:*", "@stock-bot/event-bus": "workspace:*", "@stock-bot/api-client": "workspace:*", diff --git a/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts b/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts index d44971d..f808235 100644 --- a/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts +++ b/apps/intelligence-services/backtest-engine/src/core/BacktestEngine.ts @@ -1,12 +1,12 @@ import { EventEmitter } from 'events'; -import { OHLCV } from '@stock-bot/shared-types'; -import { Order, Position } from '@stock-bot/shared-types'; +import { OHLCV } from '@stock-bot/types'; +import { Order, Position } from '@stock-bot/types'; import { createLogger } from '@stock-bot/utils'; import { financialUtils } from '@stock-bot/utils'; const logger = createLogger('backtest-engine'); -// Use OHLCV from shared-types as BarData equivalent +// Use OHLCV from types as BarData equivalent export type BarData = OHLCV; // Strategy interface to match existing pattern diff --git a/apps/intelligence-services/signal-engine/package.json b/apps/intelligence-services/signal-engine/package.json index ee30b94..d8db7f9 100644 --- a/apps/intelligence-services/signal-engine/package.json +++ b/apps/intelligence-services/signal-engine/package.json @@ -12,7 +12,7 @@ "dependencies": { "hono": "^4.6.3", "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "ws": "^8.18.0" }, "devDependencies": { diff --git a/apps/intelligence-services/strategy-orchestrator/package.json b/apps/intelligence-services/strategy-orchestrator/package.json index 92c6b5b..0bf586f 100644 --- a/apps/intelligence-services/strategy-orchestrator/package.json +++ b/apps/intelligence-services/strategy-orchestrator/package.json @@ -11,7 +11,7 @@ "hono": "^4.6.3", "ioredis": "^5.4.1", "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "ws": "^8.18.0", "node-cron": "^3.0.3", "axios": "^1.6.2" diff --git a/bun.lock b/bun.lock index 9d3e2f1..a9654b8 100644 --- a/bun.lock +++ b/bun.lock @@ -20,7 +20,7 @@ "@stock-bot/config": "*", "@stock-bot/event-bus": "*", "@stock-bot/http-client": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "@stock-bot/utils": "*", "bull": "^4.12.0", "compression": "^1.7.4", @@ -55,7 +55,7 @@ "version": "1.0.0", "dependencies": { "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "hono": "^4.6.3", "ioredis": "^5.4.1", "ws": "^8.18.0", @@ -71,7 +71,7 @@ "dependencies": { "@stock-bot/api-client": "workspace:*", "@stock-bot/event-bus": "workspace:*", - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "@stock-bot/utils": "workspace:*", "cron": "^3.1.6", "elasticsearch": "^16.7.3", @@ -93,7 +93,7 @@ "dependencies": { "@stock-bot/api-client": "*", "@stock-bot/event-bus": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "@stock-bot/utils": "*", "axios": "^1.6.2", "bull": "^4.12.2", @@ -118,7 +118,7 @@ "dependencies": { "@stock-bot/api-client": "*", "@stock-bot/event-bus": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "@stock-bot/utils": "*", "compression": "^1.7.4", "cors": "^2.8.5", @@ -150,7 +150,7 @@ "@stock-bot/api-client": "workspace:*", "@stock-bot/config": "*", "@stock-bot/event-bus": "workspace:*", - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "@stock-bot/utils": "workspace:*", "axios": "^1.6.2", "hono": "^4.6.3", @@ -166,7 +166,7 @@ "version": "1.0.0", "dependencies": { "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "hono": "^4.6.3", "ws": "^8.18.0", }, @@ -180,7 +180,7 @@ "version": "1.0.0", "dependencies": { "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "axios": "^1.6.2", "hono": "^4.6.3", "ioredis": "^5.4.1", @@ -232,7 +232,7 @@ "name": "@stock-bot/api-client", "version": "1.0.0", "dependencies": { - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "axios": "^1.6.0", }, "devDependencies": { @@ -262,7 +262,7 @@ "name": "@stock-bot/event-bus", "version": "1.0.0", "dependencies": { - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "ioredis": "^5.3.2", }, "devDependencies": { @@ -286,8 +286,8 @@ "typescript": "^5.3.0", }, }, - "libs/shared-types": { - "name": "@stock-bot/shared-types", + "libs/types": { + "name": "@stock-bot/types", "version": "1.0.0", "devDependencies": { "typescript": "^5.4.5", @@ -298,7 +298,7 @@ "version": "1.0.0", "dependencies": { "@stock-bot/config": "workspace:*", - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "date-fns": "^2.30.0", }, "devDependencies": { @@ -763,7 +763,7 @@ "@stock-bot/market-data-gateway": ["@stock-bot/market-data-gateway@workspace:apps/core-services/market-data-gateway"], - "@stock-bot/shared-types": ["@stock-bot/shared-types@workspace:libs/shared-types"], + "@stock-bot/types": ["@stock-bot/types@workspace:libs/types"], "@stock-bot/utils": ["@stock-bot/utils@workspace:libs/utils"], diff --git a/docs/current-system-flow.md b/docs/current-system-flow.md index 709695e..faa748e 100644 --- a/docs/current-system-flow.md +++ b/docs/current-system-flow.md @@ -157,7 +157,7 @@ Market Data Gateway ├── ✅ Hono (Web framework) ├── ✅ ioredis (Redis client) ├── ✅ @stock-bot/config (Workspace package) -├── ✅ @stock-bot/shared-types (Workspace package) +├── ✅ @stock-bot/types (Workspace package) └── ✅ ws (WebSocket library) Trading Dashboard diff --git a/docs/enhanced-architecture.md b/docs/enhanced-architecture.md index cbbc4d3..82a8021 100644 --- a/docs/enhanced-architecture.md +++ b/docs/enhanced-architecture.md @@ -6,12 +6,12 @@ This guide describes how the project architecture has been improved to better se We've reorganized the project's shared libraries for improved maintainability: -### 1. Shared Types (`@stock-bot/shared-types`) +### 1. Shared Types (`@stock-bot/types`) Types are now organized by domain: ``` -libs/shared-types/ +libs/types/ ├── src/ │ ├── market/ # Market data types (OHLCV, OrderBook) │ ├── trading/ # Trading types (Orders, Positions) diff --git a/docs/migration-guide.md b/docs/migration-guide.md index 01a4758..8826436 100644 --- a/docs/migration-guide.md +++ b/docs/migration-guide.md @@ -8,8 +8,8 @@ This guide will help you migrate your service to use the new library structure f ```diff "dependencies": { -- "@stock-bot/shared-types": "workspace:*", -+ "@stock-bot/shared-types": "workspace:*", +- "@stock-bot/types": "workspace:*", ++ "@stock-bot/types": "workspace:*", + "@stock-bot/utils": "workspace:*", + "@stock-bot/event-bus": "workspace:*", + "@stock-bot/api-client": "workspace:*", @@ -20,10 +20,10 @@ This guide will help you migrate your service to use the new library structure f 2. Update your imports to use the domain-specific modules: ```diff -- import { OHLCV, Strategy, Order } from '@stock-bot/shared-types'; -+ import { OHLCV } from '@stock-bot/shared-types'; -+ import { Strategy } from '@stock-bot/shared-types'; -+ import { Order } from '@stock-bot/shared-types'; +- import { OHLCV, Strategy, Order } from '@stock-bot/types'; ++ import { OHLCV } from '@stock-bot/types'; ++ import { Strategy } from '@stock-bot/types'; ++ import { Order } from '@stock-bot/types'; ``` For logging: @@ -48,7 +48,7 @@ For event-based communication: ```diff - // Manual Redis/Dragonfly usage + import { createEventBus } from '@stock-bot/event-bus'; -+ import { MarketDataEvent } from '@stock-bot/shared-types'; ++ import { MarketDataEvent } from '@stock-bot/types'; + + const eventBus = createEventBus({ + redisHost: process.env.REDIS_HOST || 'localhost', @@ -64,12 +64,12 @@ For event-based communication: ```typescript // Before -import { Strategy, BacktestConfig } from '@stock-bot/shared-types'; +import { Strategy, BacktestConfig } from '@stock-bot/types'; import Redis from 'ioredis'; // After -import { Strategy } from '@stock-bot/shared-types'; -import { BacktestConfig } from '@stock-bot/shared-types'; +import { Strategy } from '@stock-bot/types'; +import { BacktestConfig } from '@stock-bot/types'; import { createLogger } from '@stock-bot/utils'; import { createEventBus } from '@stock-bot/event-bus'; @@ -88,8 +88,8 @@ If your turbo.json configuration references specific packages, update the depend "backtest": { "dependsOn": [ "^build", -- "packages/shared-types#build" -+ "libs/shared-types#build", +- "packages/types#build" ++ "libs/types#build", + "libs/utils#build", + "libs/event-bus#build", + "libs/api-client#build" diff --git a/libs/api-client/package.json b/libs/api-client/package.json index b265df4..ea9e197 100644 --- a/libs/api-client/package.json +++ b/libs/api-client/package.json @@ -11,7 +11,7 @@ "test": "jest" }, "dependencies": { - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "axios": "^1.6.0" }, "devDependencies": { diff --git a/libs/api-client/src/BacktestClient.ts b/libs/api-client/src/BacktestClient.ts index d71ac61..4aaf86e 100644 --- a/libs/api-client/src/BacktestClient.ts +++ b/libs/api-client/src/BacktestClient.ts @@ -1,5 +1,5 @@ import { BaseApiClient } from './BaseApiClient'; -import { ApiResponse, BacktestConfig, BacktestResult } from '@stock-bot/shared-types'; +import { ApiResponse, BacktestConfig, BacktestResult } from '@stock-bot/types'; /** * Client for interacting with the Backtest Engine service diff --git a/libs/api-client/src/BaseApiClient.ts b/libs/api-client/src/BaseApiClient.ts index f727fa3..0b6f59a 100644 --- a/libs/api-client/src/BaseApiClient.ts +++ b/libs/api-client/src/BaseApiClient.ts @@ -1,5 +1,5 @@ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'; -import { ApiResponse } from '@stock-bot/shared-types'; +import { ApiResponse } from '@stock-bot/types'; /** * Base API client that all service clients extend diff --git a/libs/api-client/src/StrategyClient.ts b/libs/api-client/src/StrategyClient.ts index ba999a9..f23d8aa 100644 --- a/libs/api-client/src/StrategyClient.ts +++ b/libs/api-client/src/StrategyClient.ts @@ -1,5 +1,5 @@ import { BaseApiClient } from './BaseApiClient'; -import { ApiResponse, Strategy } from '@stock-bot/shared-types'; +import { ApiResponse, Strategy } from '@stock-bot/types'; /** * Client for interacting with the Strategy Orchestrator service diff --git a/libs/event-bus/README.md b/libs/event-bus/README.md index f360b4d..7841531 100644 --- a/libs/event-bus/README.md +++ b/libs/event-bus/README.md @@ -5,7 +5,7 @@ A Redis-based event bus implementation for inter-service communication in the st ## Features - Publish/subscribe pattern for asynchronous messaging -- Support for typed events based on `@stock-bot/shared-types` +- Support for typed events based on `@stock-bot/types` - Reliable message delivery - Channel-based subscriptions @@ -13,7 +13,7 @@ A Redis-based event bus implementation for inter-service communication in the st ```typescript import { createEventBus } from '@stock-bot/event-bus'; -import { MarketDataEvent } from '@stock-bot/shared-types'; +import { MarketDataEvent } from '@stock-bot/types'; // Create an event bus instance const eventBus = createEventBus({ diff --git a/libs/event-bus/package.json b/libs/event-bus/package.json index 5a1cf41..f321154 100644 --- a/libs/event-bus/package.json +++ b/libs/event-bus/package.json @@ -11,7 +11,7 @@ "test": "jest" }, "dependencies": { - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "ioredis": "^5.3.2" }, "devDependencies": { diff --git a/libs/event-bus/src/EventBus.ts b/libs/event-bus/src/EventBus.ts index e3d6335..d7584f3 100644 --- a/libs/event-bus/src/EventBus.ts +++ b/libs/event-bus/src/EventBus.ts @@ -1,5 +1,5 @@ import Redis from 'ioredis'; -import { Event } from '@stock-bot/shared-types'; +import { Event } from '@stock-bot/types'; export type EventHandler = (event: T) => Promise | void; diff --git a/libs/event-bus/tsconfig.json b/libs/event-bus/tsconfig.json index 2e0bad5..dd791a8 100644 --- a/libs/event-bus/tsconfig.json +++ b/libs/event-bus/tsconfig.json @@ -3,8 +3,10 @@ "compilerOptions": { "outDir": "./dist", "rootDir": "./src", - "declaration": true + "declaration": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": false, }, "include": ["src/**/*"], - "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"] + "exclude": ["node_modules", "dist", "**/*.test.ts"] } diff --git a/libs/http-client/src/BunHttpClient.ts b/libs/http-client/src/BunHttpClient.ts index 2fe3e1a..25ea0ac 100644 --- a/libs/http-client/src/BunHttpClient.ts +++ b/libs/http-client/src/BunHttpClient.ts @@ -1,5 +1,5 @@ import { EventEmitter } from 'eventemitter3'; -import type { +import { HttpClientConfig, RequestConfig, HttpResponse, @@ -123,12 +123,12 @@ export class BunHttpClient extends EventEmitter { private mergeConfig(config: RequestConfig): RequestConfig { return { + ...config, timeout: this.defaultConfig.timeout, retries: this.defaultConfig.retries, headers: { ...this.defaultConfig.headers, ...config.headers }, validateStatus: this.defaultConfig.validateStatus, url: this.buildUrl(config.url), - ...config }; } diff --git a/libs/http-client/src/RetryHandler.ts b/libs/http-client/src/RetryHandler.ts index e3bb734..1a78107 100644 --- a/libs/http-client/src/RetryHandler.ts +++ b/libs/http-client/src/RetryHandler.ts @@ -1,12 +1,11 @@ import { EventEmitter } from 'eventemitter3'; -import type { +import { RetryConfig, RequestConfig, HttpResponse, - HttpClientError, - TimeoutError, RetryExhaustedError } from './types'; +import { TimeoutError } from './types'; export class RetryHandler extends EventEmitter { private config: Required; diff --git a/libs/shared-types/README.md b/libs/shared-types/README.md index dc1c13d..fb74423 100644 --- a/libs/shared-types/README.md +++ b/libs/shared-types/README.md @@ -14,7 +14,7 @@ This library contains domain-specific TypeScript type definitions used across th ## Usage ```typescript -import { OHLCV, MarketData } from '@stock-bot/shared-types'; +import { OHLCV, MarketData } from '@stock-bot/types'; // Use the types const marketData: MarketData = { diff --git a/libs/shared-types/package.json b/libs/shared-types/package.json index 94c1de8..f991e92 100644 --- a/libs/shared-types/package.json +++ b/libs/shared-types/package.json @@ -1,5 +1,5 @@ { - "name": "@stock-bot/shared-types", + "name": "@stock-bot/types", "version": "1.0.0", "description": "Domain-specific shared TypeScript definitions for the trading bot", "main": "dist/index.js", diff --git a/libs/shared-types/src/api/api.ts b/libs/shared-types/src/api/api.ts index d4ffe08..42ae72c 100644 --- a/libs/shared-types/src/api/api.ts +++ b/libs/shared-types/src/api/api.ts @@ -7,7 +7,7 @@ export interface ServiceConfig { dependencies?: string[]; } -export interface HealthStatus { +export interface ApiHealthStatus { service: string; status: 'healthy' | 'unhealthy' | 'degraded'; timestamp: Date; diff --git a/libs/shared-types/src/communication/index.ts b/libs/shared-types/src/communication/index.ts new file mode 100644 index 0000000..772b495 --- /dev/null +++ b/libs/shared-types/src/communication/index.ts @@ -0,0 +1,5 @@ +// Communication and Messaging Types +export * from './websocket'; +export * from './subscriptions'; +export * from './messages'; +export * from './protocols'; diff --git a/libs/shared-types/src/communication/messages.ts b/libs/shared-types/src/communication/messages.ts new file mode 100644 index 0000000..426d8b4 --- /dev/null +++ b/libs/shared-types/src/communication/messages.ts @@ -0,0 +1,152 @@ +// Message Queue and Event Types +export interface EventBusMessage { + id: string; + type: string; + source: string; + timestamp: Date; + data: any; + metadata?: MessageMetadata; + headers?: Record; + correlationId?: string; + causationId?: string; +} + +export interface MessageMetadata { + version?: string; + schemaVersion?: string; + contentType?: string; + encoding?: string; + priority?: MessagePriority; + retryCount?: number; + maxRetries?: number; + expiresAt?: Date; + partitionKey?: string; +} + +export enum MessagePriority { + LOW = 'low', + NORMAL = 'normal', + HIGH = 'high', + CRITICAL = 'critical' +} + +export interface QueueMessage extends EventBusMessage { + queueName: string; + routingKey?: string; + deliveryAttempts: number; + firstDeliveryAt?: Date; + lastDeliveryAt?: Date; + deadLetterReason?: string; +} + +export interface MessageBatch { + id: string; + messages: EventBusMessage[]; + batchSize: number; + createdAt: Date; + expiresAt?: Date; + metadata?: Record; +} + +export interface MessageHandler { + id: string; + name: string; + eventTypes: string[]; + handler: (message: EventBusMessage) => Promise; + config: HandlerConfig; + status: HandlerStatus; + metrics: HandlerMetrics; +} + +export interface HandlerConfig { + concurrency?: number; + retryAttempts?: number; + retryDelay?: number; + deadLetterQueue?: string; + timeout?: number; + batchSize?: number; + filters?: MessageFilter[]; +} + +export enum HandlerStatus { + ACTIVE = 'active', + PAUSED = 'paused', + ERROR = 'error', + STOPPED = 'stopped' +} + +export interface HandlerMetrics { + messagesProcessed: number; + messagesSuccess: number; + messagesError: number; + avgProcessingTime: number; + lastProcessed: Date; + errorRate: number; +} + +export interface MessageFilter { + field: string; + operator: 'equals' | 'not_equals' | 'contains' | 'regex' | 'in' | 'not_in'; + value: any; + logicalOperator?: 'AND' | 'OR'; +} + +export interface DeadLetterMessage extends QueueMessage { + originalQueue: string; + failureReason: string; + failureTimestamp: Date; + retryHistory: RetryAttempt[]; +} + +export interface RetryAttempt { + attemptNumber: number; + timestamp: Date; + error: string; + duration: number; +} + +export interface MessageProducer { + id: string; + name: string; + producerType: 'service' | 'scheduler' | 'webhook' | 'batch'; + config: ProducerConfig; + status: ProducerStatus; + metrics: ProducerMetrics; +} + +export interface ProducerConfig { + batchSize?: number; + batchTimeout?: number; + compression?: boolean; + partitioning?: PartitioningConfig; + serialization?: SerializationConfig; +} + +export interface PartitioningConfig { + enabled: boolean; + keyField?: string; + strategy: 'hash' | 'round_robin' | 'custom'; + partitionCount?: number; +} + +export interface SerializationConfig { + format: 'json' | 'avro' | 'protobuf' | 'msgpack'; + compression?: 'gzip' | 'snappy' | 'lz4'; + schema?: string; +} + +export enum ProducerStatus { + ACTIVE = 'active', + PAUSED = 'paused', + ERROR = 'error', + STOPPED = 'stopped' +} + +export interface ProducerMetrics { + messagesSent: number; + messagesSuccess: number; + messagesError: number; + avgLatency: number; + throughputPerSecond: number; + lastSent: Date; +} diff --git a/libs/shared-types/src/communication/protocols.ts b/libs/shared-types/src/communication/protocols.ts new file mode 100644 index 0000000..f722e3b --- /dev/null +++ b/libs/shared-types/src/communication/protocols.ts @@ -0,0 +1,163 @@ +// Protocol and Integration Types +export interface HttpRequest { + method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'; + url: string; + headers?: Record; + body?: any; + timeout?: number; + retries?: number; + metadata?: Record; + validateStatus?: (status: number) => boolean; +} + +export interface HttpResponse { + data: T; + status: number; + statusText: string; + headers: Record; + config: HttpRequest; + timing: RequestTiming; +} + +export interface RequestTiming { + start: number; + end: number; + duration: number; + dns?: number; + tcp?: number; + tls?: number; + request?: number; + firstByte?: number; + download?: number; +} + +export interface ApiEndpoint { + id: string; + name: string; + baseUrl: string; + path: string; + method: string; + authentication?: ProtocolAuthenticationMethod; + rateLimit?: RateLimitInfo; + timeout: number; + retryPolicy: RetryPolicy; + headers?: Record; + queryParams?: Record; +} + +export interface ProtocolAuthenticationMethod { + type: 'none' | 'apikey' | 'bearer' | 'basic' | 'oauth2' | 'custom'; + config: AuthConfig; +} + +export interface AuthConfig { + apiKey?: string; + token?: string; + username?: string; + password?: string; + clientId?: string; + clientSecret?: string; + scope?: string[]; + tokenUrl?: string; + refreshToken?: string; + customHeaders?: Record; +} + +export interface RateLimitInfo { + requestsPerSecond: number; + requestsPerMinute: number; + requestsPerHour: number; + burstLimit: number; + windowMs: number; +} + +export interface RetryPolicy { + enabled: boolean; + maxRetries: number; + baseDelayMs: number; + maxDelayMs: number; + backoffMultiplier: number; + jitter: boolean; + retryOn: RetryCondition[]; +} + +export interface RetryCondition { + type: 'status_code' | 'timeout' | 'network_error' | 'rate_limit' | 'custom'; + values?: number[]; + condition?: string; +} + +export interface ProtocolConfig { + name: string; + version: string; + transport: 'http' | 'websocket' | 'tcp' | 'udp' | 'grpc'; + serialization: 'json' | 'protobuf' | 'avro' | 'msgpack' | 'xml'; + compression?: 'gzip' | 'deflate' | 'brotli' | 'snappy'; encryption?: EncryptionConfig; + healthCheck: ProtocolHealthCheckConfig; +} + +export interface EncryptionConfig { + enabled: boolean; + algorithm?: string; + keySize?: number; + mode?: string; + certificatePath?: string; + privateKeyPath?: string; +} + +export interface ProtocolHealthCheckConfig { + enabled: boolean; + path?: string; + interval: number; + timeout: number; + healthyThreshold: number; + unhealthyThreshold: number; +} + +export interface ServiceEndpointConfig { + serviceName: string; + version: string; + endpoints: ApiEndpoint[]; + baseConfig: ProtocolServiceConfig; + healthCheck: ProtocolHealthCheckConfig; +} + +export interface ProtocolServiceConfig { + timeout: number; + retries: number; + circuitBreaker?: CircuitBreakerConfig; + loadBalancer?: LoadBalancerConfig; + monitoring?: MonitoringConfig; +} + +export interface CircuitBreakerConfig { + enabled: boolean; + failureThreshold: number; + timeout: number; + halfOpenMaxCalls: number; + halfOpenTimeout: number; +} + +export interface LoadBalancerConfig { + strategy: 'round_robin' | 'weighted' | 'least_connections' | 'random'; + healthCheckEnabled: boolean; + targets: LoadBalancerTarget[]; +} + +export interface LoadBalancerTarget { + url: string; + weight?: number; + enabled: boolean; + metadata?: Record; +} + +export interface MonitoringConfig { + metricsEnabled: boolean; + tracingEnabled: boolean; + loggingEnabled: boolean; + alertingEnabled: boolean; + customMetrics?: string[]; +} + +// Re-export from config for convenience +export type { HttpClientConfig } from '../config/networking'; diff --git a/libs/shared-types/src/communication/subscriptions.ts b/libs/shared-types/src/communication/subscriptions.ts new file mode 100644 index 0000000..b3f8f6b --- /dev/null +++ b/libs/shared-types/src/communication/subscriptions.ts @@ -0,0 +1,200 @@ +// Subscription Management Types + +export type DataType = 'tick' | 'candle' | 'trade' | 'order' | 'quote' | 'level2' | 'quotes' | 'trades' | 'orderbook' | 'candles' | 'news' | 'fundamentals' | 'options' | 'futures' | 'crypto'; + +export enum SubscriptionPriority { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high', + CRITICAL = 'critical' +} + +export interface SubscriptionRequest { + id: string; + clientId: string; + symbols: string[]; + dataTypes: DataType[]; + filters?: SubscriptionFilter; + throttle?: ThrottleConfig; + delivery: DeliveryConfig; + priority?: SubscriptionPriority; + metadata?: Record; +} + +export interface SubscriptionFilter { + symbols?: string[]; + priceRange?: PriceRange; + volumeRange?: VolumeRange; + timeRange?: TimeRange; + custom?: Record; +} + +export interface PriceRange { + min?: number; + max?: number; +} + +export interface VolumeRange { + min?: number; + max?: number; +} + +export interface TimeRange { + start?: Date; + end?: Date; +} + +export interface ThrottleConfig { + maxMessagesPerSecond?: number; + maxBatchSize?: number; + bufferTimeMs?: number; +} + +export interface DeliveryConfig { + method: DeliveryMethod; + endpoint?: string; + options?: DeliveryOptions; +} + +export enum DeliveryMethod { + WEBSOCKET = 'websocket', + HTTP_PUSH = 'http_push', + QUEUE = 'queue', + STREAM = 'stream' +} + +export interface DeliveryOptions { + guaranteedDelivery?: boolean; + compression?: boolean; + encryption?: boolean; + authentication?: AuthenticationMethod; + headers?: Record; +} + +export enum AuthenticationMethod { + NONE = 'none', + API_KEY = 'api_key', + BEARER_TOKEN = 'bearer_token', + OAUTH = 'oauth', + MUTUAL_TLS = 'mutual_tls' +} + +export interface SubscriptionResponse { + id: string; + status: SubscriptionStatus; + message?: string; + details?: SubscriptionDetails; +} + +export enum SubscriptionStatus { + ACTIVE = 'active', + PENDING = 'pending', + PAUSED = 'paused', + CANCELLED = 'cancelled', + FAILED = 'failed' +} + +export interface SubscriptionDetails { + subscribedSymbols: string[]; + subscribedDataTypes: DataType[]; + activeFilters: SubscriptionFilter; + performance: CommunicationSubscriptionMetrics; +} + +export interface CommunicationSubscriptionMetrics { + messagesReceived: number; + messagesDropped: number; + averageLatency: number; + throughput: number; + errorRate: number; + lastActivity: Date; +} + +export interface SubscriptionConfig { + maxSubscriptionsPerClient: number; + defaultThrottleConfig: ThrottleConfig; + allowedDataTypes: DataType[]; + supportedDeliveryMethods: DeliveryMethod[]; + subscriptionTimeout: number; +} + +export interface UnsubscribeRequest { + subscriptionId: string; + clientId: string; + reason?: string; +} + +export interface BulkSubscriptionRequest { + requests: SubscriptionRequest[]; + batchId?: string; + failurePolicy: BatchFailurePolicy; +} + +export enum BatchFailurePolicy { + FAIL_ALL = 'fail_all', + FAIL_PARTIAL = 'fail_partial', + IGNORE_ERRORS = 'ignore_errors' +} + +export interface BatchSubscriptionResponse { + batchId: string; + responses: SubscriptionResponse[]; + summary: BatchSummary; +} + +export interface BatchSummary { + totalRequests: number; + successfulSubscriptions: number; + failedSubscriptions: number; + errors: string[]; +} + +export interface SubscriptionUpdate { + subscriptionId: string; + updates: Partial; + clientId: string; +} + +export interface SubscriptionEvent { + type: SubscriptionEventType; + subscriptionId: string; + clientId: string; + timestamp: Date; + data?: any; +} + +export enum SubscriptionEventType { + CREATED = 'created', + UPDATED = 'updated', + CANCELLED = 'cancelled', + ERROR = 'error', + DATA_RECEIVED = 'data_received' +} + +export interface FilterRule { + field: string; + operator: FilterOperator; + value: any; + validation?: ValidationRule; +} + +export enum FilterOperator { + EQUALS = 'equals', + NOT_EQUALS = 'not_equals', + GREATER_THAN = 'greater_than', + LESS_THAN = 'less_than', + GREATER_EQUAL = 'greater_equal', + LESS_EQUAL = 'less_equal', + IN = 'in', + NOT_IN = 'not_in', + CONTAINS = 'contains', + REGEX = 'regex' +} + +export interface ValidationRule { + pattern?: string; + min?: number; + max?: number; + enum?: any[]; + custom?: string; +} diff --git a/libs/shared-types/src/communication/websocket.ts b/libs/shared-types/src/communication/websocket.ts new file mode 100644 index 0000000..63f82c3 --- /dev/null +++ b/libs/shared-types/src/communication/websocket.ts @@ -0,0 +1,134 @@ +// WebSocket Communication Types +export interface WebSocketMessage { + type: MessageType; + id?: string; + timestamp: number; + payload: any; + metadata?: Record; + correlationId?: string; +} + +export enum MessageType { + SUBSCRIBE = 'subscribe', + UNSUBSCRIBE = 'unsubscribe', + DATA = 'data', + ERROR = 'error', + HEARTBEAT = 'heartbeat', + STATUS = 'status', + ACK = 'ack', + PING = 'ping', + PONG = 'pong' +} + +export interface WebSocketSubscribeMessage extends WebSocketMessage { + type: MessageType.SUBSCRIBE; + payload: SubscriptionPayload; +} + +export interface WebSocketUnsubscribeMessage extends WebSocketMessage { + type: MessageType.UNSUBSCRIBE; + payload: UnsubscriptionPayload; +} + +export interface WebSocketDataMessage extends WebSocketMessage { + type: MessageType.DATA; + payload: DataPayload; +} + +export interface WebSocketErrorMessage extends WebSocketMessage { + type: MessageType.ERROR; + payload: ErrorPayload; +} + +export interface WebSocketStatusMessage extends WebSocketMessage { + type: MessageType.STATUS; + payload: StatusPayload; +} + +export interface SubscriptionPayload { + symbols: string[]; + dataTypes: string[]; + filters?: WebSocketSubscriptionFilter; + throttle?: WebSocketThrottleConfig; + delivery?: WebSocketDeliveryConfig; +} + +export interface UnsubscriptionPayload { + subscriptionId?: string; + symbols?: string[]; + dataTypes?: string[]; +} + +export interface DataPayload { + dataType: string; + symbol?: string; + data: any; + sequence?: number; + source?: string; +} + +export interface ErrorPayload { + code: string; + message: string; + details?: Record; + retryable?: boolean; +} + +export interface StatusPayload { + status: 'connected' | 'disconnected' | 'reconnecting' | 'error'; + message?: string; + timestamp: number; + metadata?: Record; +} + +export interface WebSocketSubscriptionFilter { + priceRange?: { min: number; max: number }; + volumeThreshold?: number; + exchanges?: string[]; + symbols?: string[]; + timeframe?: string; + custom?: Record; +} + +export interface WebSocketThrottleConfig { + maxUpdatesPerSecond: number; + aggregationWindow?: number; + bufferSize?: number; +} + +export interface WebSocketDeliveryConfig { + method: 'websocket' | 'webhook' | 'eventbus' | 'queue'; + endpoint?: string; + format: 'json' | 'protobuf' | 'avro' | 'msgpack'; + compression?: 'gzip' | 'deflate' | 'brotli'; + batchSize?: number; + batchDelay?: number; +} + +export interface WebSocketConnection { + id: string; + clientId: string; + sessionId: string; + connectedAt: Date; + lastActivity: Date; + status: ConnectionStatus; + subscriptions: Set; + metadata: ConnectionMetadata; +} + +export enum ConnectionStatus { + CONNECTING = 'connecting', + CONNECTED = 'connected', + DISCONNECTING = 'disconnecting', + DISCONNECTED = 'disconnected', + ERROR = 'error' +} + +export interface ConnectionMetadata { + userAgent?: string; + ipAddress?: string; + origin?: string; + protocol?: string; + version?: string; + features?: string[]; +} diff --git a/libs/shared-types/src/config/database.ts b/libs/shared-types/src/config/database.ts new file mode 100644 index 0000000..ac4a696 --- /dev/null +++ b/libs/shared-types/src/config/database.ts @@ -0,0 +1,60 @@ +// Database Configuration Types +export interface DatabaseConfig { + host: string; + port: number; + database: string; + username?: string; + password?: string; + connectionTimeout?: number; + ssl?: boolean; +} + +export interface PostgresConfig extends DatabaseConfig { + maxConnections?: number; + idleTimeoutMs?: number; + connectionTimeoutMs?: number; + statementTimeout?: number; + schema?: string; +} + +export interface MongoDbConfig extends DatabaseConfig { + authSource?: string; + replicaSet?: string; + readPreference?: 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest'; + writeConcern?: string; + retryWrites?: boolean; + journal?: boolean; +} + +export interface QuestDbConfig extends DatabaseConfig { + httpPort?: number; + pgPort?: number; + requestTimeout?: number; + retryAttempts?: number; + tlsEnabled?: boolean; + defaultDatabase?: string; +} + +export interface RedisConfig { + host: string; + port: number; + password?: string; + database?: number; + maxRetries?: number; + retryDelay?: number; + connectTimeout?: number; + commandTimeout?: number; + poolSize?: number; + tls?: boolean; + enableKeepAlive?: boolean; +} + +export interface ConnectionPoolConfig { + minConnections: number; + maxConnections: number; + acquireTimeoutMs: number; + createTimeoutMs: number; + destroyTimeoutMs: number; + idleTimeoutMs: number; + reapIntervalMs: number; +} diff --git a/libs/shared-types/src/config/index.ts b/libs/shared-types/src/config/index.ts new file mode 100644 index 0000000..08172dc --- /dev/null +++ b/libs/shared-types/src/config/index.ts @@ -0,0 +1,6 @@ +// Configuration Types - Shared across all services +export * from './database'; +export * from './monitoring'; +export * from './logging'; +export * from './security'; +export * from './networking'; diff --git a/libs/shared-types/src/config/logging.ts b/libs/shared-types/src/config/logging.ts new file mode 100644 index 0000000..a538a8e --- /dev/null +++ b/libs/shared-types/src/config/logging.ts @@ -0,0 +1,48 @@ +// Logging Configuration Types +export interface LoggingConfig { + level: 'error' | 'warn' | 'info' | 'http' | 'verbose' | 'debug' | 'silly'; + format: 'json' | 'simple' | 'combined'; + console: boolean; + file: boolean; + filePath?: string; + maxSize?: string; + maxFiles?: number; + timestamp?: boolean; + callerInfo?: boolean; + silentModules?: string[]; + verboseModules?: string[]; + serviceName?: string; + serviceVersion?: string; + environment?: string; +} + +export interface LokiConfig { + host: string; + port: number; + url?: string; + username?: string; + password?: string; + tenantId?: string; + pushTimeout?: number; + batchSize?: number; + batchWait?: number; + retentionPeriod?: string; + maxChunkAge?: string; + tlsEnabled?: boolean; + tlsInsecure?: boolean; + defaultLabels?: Record; + serviceLabel?: string; + environmentLabel?: string; + flushIntervalMs?: number; +} + +export interface LogEntry { + timestamp: Date; + level: string; + message: string; + service: string; + environment: string; + metadata?: Record; + error?: string; + stackTrace?: string; +} diff --git a/libs/shared-types/src/config/monitoring.ts b/libs/shared-types/src/config/monitoring.ts new file mode 100644 index 0000000..1c25770 --- /dev/null +++ b/libs/shared-types/src/config/monitoring.ts @@ -0,0 +1,48 @@ +// Monitoring and Metrics Configuration Types +export interface PrometheusConfig { + host: string; + port: number; + url?: string; + username?: string; + password?: string; + scrapeInterval: string; + evaluationInterval: string; + retentionTime: string; + tlsEnabled?: boolean; + tlsInsecure?: boolean; +} + +export interface GrafanaConfig { + host: string; + port: number; + url?: string; + adminUser: string; + adminPassword: string; + allowSignUp?: boolean; + secretKey?: string; + databaseType: 'mysql' | 'postgres' | 'sqlite3'; + databaseUrl?: string; + disableGravatar?: boolean; + enableGzip?: boolean; +} + +export interface AlertManagerConfig { + host: string; + port: number; + webhookUrl?: string; + smtpHost?: string; + smtpPort?: number; + smtpUsername?: string; + smtpPassword?: string; + slackWebhookUrl?: string; +} + +export interface MetricsConfig { + enabled: boolean; + port: number; + path: string; + collectDefaultMetrics?: boolean; + prefix?: string; + labels?: Record; + buckets?: number[]; +} diff --git a/libs/shared-types/src/config/networking.ts b/libs/shared-types/src/config/networking.ts new file mode 100644 index 0000000..d968c4b --- /dev/null +++ b/libs/shared-types/src/config/networking.ts @@ -0,0 +1,50 @@ +// Networking and Communication Configuration Types +import { CorsConfig } from './security'; + +export interface ServerConfig { + host: string; + port: number; + maxConnections?: number; + keepAliveTimeout?: number; + bodyParserLimit?: string; + compression?: boolean; + gracefulShutdownTimeout?: number; +} + +export interface WebSocketConfig { + enabled: boolean; + port?: number; + path?: string; + heartbeatInterval?: number; + maxConnections?: number; + compression?: boolean; + cors?: CorsConfig; +} + + +export interface HttpClientConfig { + baseURL?: string; + timeout?: number; + headers?: Record; + retries?: number; + retryDelay?: number; + maxConcurrency?: number; + keepAlive?: boolean; + validateStatus?: (status: number) => boolean; +} + +export interface RetryConfig { + maxRetries: number; + baseDelay: number; + maxDelay: number; + exponentialBackoff: boolean; + retryCondition?: (error: any) => boolean; +} + +export interface CircuitBreakerConfig { + enabled: boolean; + failureThreshold: number; + recoveryTimeout: number; + monitoringPeriod: number; + expectedFailureRate: number; +} diff --git a/libs/shared-types/src/config/security.ts b/libs/shared-types/src/config/security.ts new file mode 100644 index 0000000..de6e8eb --- /dev/null +++ b/libs/shared-types/src/config/security.ts @@ -0,0 +1,46 @@ +// Security Configuration Types +export interface AuthenticationConfig { + jwtSecret: string; + jwtExpiresIn: string; + refreshTokenExpiresIn: string; + passwordMinLength: number; + passwordRequireNumbers: boolean; + passwordRequireSpecialChars: boolean; + passwordRequireUppercase: boolean; + passwordRequireLowercase: boolean; + maxLoginAttempts: number; + lockoutDurationMinutes: number; +} + +export interface TlsConfig { + enabled: boolean; + certFile?: string; + keyFile?: string; + caFile?: string; + skipVerify?: boolean; + minVersion?: string; + cipherSuites?: string[]; +} + +export interface ApiKeyConfig { + type: 'apikey' | 'oauth' | 'basic' | 'jwt'; + credentials: Record; + expiresIn?: string; + permissions?: string[]; +} + +export interface CorsConfig { + origins: string[]; + methods: string[]; + headers: string[]; + credentials?: boolean; + maxAge?: number; +} + +export interface RateLimitConfig { + windowMs: number; + maxRequests: number; + skipSuccessfulRequests?: boolean; + skipFailedRequests?: boolean; + keyGenerator?: string; +} diff --git a/libs/shared-types/src/errors/application.ts b/libs/shared-types/src/errors/application.ts new file mode 100644 index 0000000..6412f2a --- /dev/null +++ b/libs/shared-types/src/errors/application.ts @@ -0,0 +1,79 @@ +/** + * Application-specific error types + */ + +import { BaseError, ErrorCategory, ErrorSeverity } from './base'; + +export interface ApplicationError extends BaseError { + applicationName: string; + version: string; + environment: string; +} + +export interface ServiceError extends ApplicationError { + serviceName: string; + serviceVersion: string; + endpoint?: string; +} + +export interface MarketDataError extends ServiceError { + symbol?: string; + exchange?: string; + dataType?: string; + timeframe?: string; +} + +export interface TradingError extends ServiceError { + orderId?: string; + symbol?: string; + side?: 'buy' | 'sell'; + quantity?: number; + price?: number; +} + +export interface StrategyError extends ServiceError { + strategyId: string; + strategyName: string; + phase: StrategyPhase; + signal?: string; +} + +export enum StrategyPhase { + INITIALIZATION = 'initialization', + ANALYSIS = 'analysis', + SIGNAL_GENERATION = 'signal_generation', + EXECUTION = 'execution', + MONITORING = 'monitoring', + CLEANUP = 'cleanup' +} + +export interface DataProcessingError extends ServiceError { + pipelineId?: string; + stepId?: string; + inputData?: string; + processingStage: ProcessingStage; +} + +export enum ProcessingStage { + INGESTION = 'ingestion', + VALIDATION = 'validation', + TRANSFORMATION = 'transformation', + ENRICHMENT = 'enrichment', + STORAGE = 'storage', + PUBLISHING = 'publishing' +} + +export interface FeatureStoreError extends ServiceError { + featureGroupId?: string; + featureName?: string; + operation: FeatureOperation; +} + +export enum FeatureOperation { + CREATE = 'create', + READ = 'read', + UPDATE = 'update', + DELETE = 'delete', + COMPUTE = 'compute', + SERVE = 'serve' +} diff --git a/libs/shared-types/src/errors/base.ts b/libs/shared-types/src/errors/base.ts new file mode 100644 index 0000000..5695b82 --- /dev/null +++ b/libs/shared-types/src/errors/base.ts @@ -0,0 +1,85 @@ +/** + * Base error handling types and interfaces + */ + +export interface ErrorCode { + code: string; + category: ErrorCategory; + severity: ErrorSeverity; + retryable: boolean; +} + +export enum ErrorCategory { + VALIDATION = 'validation', + AUTHENTICATION = 'authentication', + AUTHORIZATION = 'authorization', + NOT_FOUND = 'not_found', + CONFLICT = 'conflict', + RATE_LIMIT = 'rate_limit', + INTERNAL = 'internal', + EXTERNAL = 'external', + NETWORK = 'network', + TIMEOUT = 'timeout', + CONFIGURATION = 'configuration', + DATA = 'data' +} + +export enum ErrorSeverity { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high', + CRITICAL = 'critical' +} + +export interface BaseError { + id: string; + code: string; + message: string; + details?: Record; + timestamp: Date; + category: ErrorCategory; + severity: ErrorSeverity; + retryable: boolean; + context?: ErrorContext; + stack?: string; +} + +export interface ErrorContext { + service: string; + component: string; + operation: string; + userId?: string; + sessionId?: string; + requestId?: string; + traceId?: string; + correlationId?: string; + metadata?: Record; +} + +export interface ErrorResponse { + error: BaseError; + timestamp: Date; + path: string; + method: string; + statusCode: number; +} + +export interface ErrorHandler { + handle(error: BaseError): Promise; + canHandle(error: BaseError): boolean; +} + +export interface ErrorRecovery { + strategy: RecoveryStrategy; + maxRetries: number; + backoffMs: number; + timeout: number; +} + +export enum RecoveryStrategy { + RETRY = 'retry', + FALLBACK = 'fallback', + CIRCUIT_BREAKER = 'circuit_breaker', + GRACEFUL_DEGRADATION = 'graceful_degradation', + FAIL_FAST = 'fail_fast' +} diff --git a/libs/shared-types/src/errors/business.ts b/libs/shared-types/src/errors/business.ts new file mode 100644 index 0000000..d18cff1 --- /dev/null +++ b/libs/shared-types/src/errors/business.ts @@ -0,0 +1,85 @@ +/** + * Business domain error types + */ + +import { BaseError } from './base'; + +export interface BusinessError extends BaseError { + domain: BusinessDomain; + operation: string; + entityId?: string; + entityType?: string; +} + +export enum BusinessDomain { + TRADING = 'trading', + MARKET_DATA = 'market_data', + PORTFOLIO = 'portfolio', + RISK_MANAGEMENT = 'risk_management', + STRATEGY = 'strategy', + EXECUTION = 'execution', + COMPLIANCE = 'compliance', + REPORTING = 'reporting' +} + +export interface TradingBusinessError extends BusinessError { + symbol: string; + orderId?: string; + errorType: TradingErrorType; +} + +export enum TradingErrorType { + INSUFFICIENT_FUNDS = 'insufficient_funds', + INVALID_SYMBOL = 'invalid_symbol', + MARKET_CLOSED = 'market_closed', + ORDER_REJECTED = 'order_rejected', + POSITION_LIMIT_EXCEEDED = 'position_limit_exceeded', + PRICE_OUT_OF_RANGE = 'price_out_of_range', + DUPLICATE_ORDER = 'duplicate_order' +} + +export interface RiskManagementError extends BusinessError { + riskType: RiskType; + threshold?: number; + currentValue?: number; + riskLevel: RiskLevel; +} + +export enum RiskType { + POSITION_SIZE = 'position_size', + CONCENTRATION = 'concentration', + VOLATILITY = 'volatility', + DRAWDOWN = 'drawdown', + EXPOSURE = 'exposure', + LEVERAGE = 'leverage', + VAR = 'var' +} + +export enum RiskLevel { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high', + CRITICAL = 'critical' +} + +export interface ComplianceError extends BusinessError { + ruleId: string; + ruleName: string; + violationType: ComplianceViolationType; + complianceSeverity: BusinessComplianceSeverity; +} + +export enum ComplianceViolationType { + REGULATORY = 'regulatory', + INTERNAL_POLICY = 'internal_policy', + RISK_LIMIT = 'risk_limit', + TRADING_RESTRICTION = 'trading_restriction', + REPORTING_REQUIREMENT = 'reporting_requirement' +} + +export enum BusinessComplianceSeverity { + INFO = 'info', + WARNING = 'warning', + VIOLATION = 'violation', + BREACH = 'breach' +} diff --git a/libs/shared-types/src/errors/index.ts b/libs/shared-types/src/errors/index.ts new file mode 100644 index 0000000..300c8fa --- /dev/null +++ b/libs/shared-types/src/errors/index.ts @@ -0,0 +1,6 @@ +// Error handling types +export * from './base'; +export * from './application'; +export * from './validation'; +export * from './network'; +export * from './business'; diff --git a/libs/shared-types/src/errors/network.ts b/libs/shared-types/src/errors/network.ts new file mode 100644 index 0000000..8dbb0e7 --- /dev/null +++ b/libs/shared-types/src/errors/network.ts @@ -0,0 +1,75 @@ +/** + * Network and communication error types + */ + +import { BaseError } from './base'; + +export interface NetworkError extends BaseError { + endpoint: string; + method: string; + statusCode?: number; + networkCode: NetworkErrorCode; +} + +export enum NetworkErrorCode { + CONNECTION_TIMEOUT = 'connection_timeout', + READ_TIMEOUT = 'read_timeout', + CONNECTION_REFUSED = 'connection_refused', + DNS_RESOLUTION = 'dns_resolution', + SSL_HANDSHAKE = 'ssl_handshake', + PROXY_ERROR = 'proxy_error', + NETWORK_UNREACHABLE = 'network_unreachable', + RATE_LIMITED = 'rate_limited', + SERVICE_UNAVAILABLE = 'service_unavailable' +} + +export interface HttpError extends NetworkError { + statusCode: number; + statusText: string; + headers?: Record; + responseBody?: string; +} + +export interface WebSocketError extends NetworkError { + connectionState: WebSocketState; + closeCode?: number; + closeReason?: string; +} + +export enum WebSocketState { + CONNECTING = 'connecting', + OPEN = 'open', + CLOSING = 'closing', + CLOSED = 'closed', + ERROR = 'error' +} + +export interface ApiError extends HttpError { + apiName: string; + apiVersion: string; + endpoint: string; + requestId?: string; + errorCode?: string; + errorMessage?: string; +} + +export interface ExternalServiceError extends NetworkError { + serviceName: string; + serviceVersion?: string; + providerName: string; + circuitBreakerState?: CircuitBreakerState; +} + +export enum CircuitBreakerState { + CLOSED = 'closed', + OPEN = 'open', + HALF_OPEN = 'half_open' +} + +export interface RetryConfig { + maxRetries: number; + baseDelayMs: number; + maxDelayMs: number; + backoffMultiplier: number; + retryableErrors: NetworkErrorCode[]; +} diff --git a/libs/shared-types/src/errors/validation.ts b/libs/shared-types/src/errors/validation.ts new file mode 100644 index 0000000..0bb419a --- /dev/null +++ b/libs/shared-types/src/errors/validation.ts @@ -0,0 +1,72 @@ +/** + * Validation error types + */ + +import { BaseError, ErrorCategory, ErrorSeverity } from './base'; + +export interface ValidationError extends BaseError { + field: string; + value?: any; + constraint: string; + validationType: ValidationType; +} + +export enum ValidationType { + REQUIRED = 'required', + TYPE = 'type', + FORMAT = 'format', + RANGE = 'range', + LENGTH = 'length', + PATTERN = 'pattern', + CUSTOM = 'custom', + BUSINESS_RULE = 'business_rule' +} + +export interface SchemaValidationError extends ValidationError { + schema: string; + schemaVersion: string; + path: string; +} + +export interface DataValidationError extends ValidationError { + dataType: string; + expectedFormat: string; + actualFormat?: string; +} + +export interface BusinessRuleValidationError extends ValidationError { + ruleId: string; + ruleName: string; + ruleDescription: string; + businessContext?: Record; +} + +export interface ValidationResult { + valid: boolean; + errors: ValidationError[]; + warnings: ValidationWarning[]; +} + +export interface ValidationWarning { + field: string; + message: string; + code: string; + severity: 'low' | 'medium'; +} + +export interface ValidationRule { + id: string; + name: string; + description: string; + type: ValidationType; + constraint: any; + message: string; + enabled: boolean; +} + +export interface ValidationConfig { + strict: boolean; + stopOnFirstError: boolean; + rules: ValidationRule[]; + customValidators: Record; +} diff --git a/libs/shared-types/src/features/base.ts b/libs/shared-types/src/features/base.ts new file mode 100644 index 0000000..f90c6e4 --- /dev/null +++ b/libs/shared-types/src/features/base.ts @@ -0,0 +1,110 @@ +/** + * Base feature store types + */ + +export interface Feature { + id: string; + name: string; + description?: string; + dataType: FeatureDataType; + valueType: FeatureValueType; + tags: string[]; + metadata: Record; + createdAt: Date; + updatedAt: Date; + version: string; + status: FeatureStatus; + owner: string; +} + +export enum FeatureDataType { + NUMERICAL = 'numerical', + CATEGORICAL = 'categorical', + BOOLEAN = 'boolean', + TEXT = 'text', + TIMESTAMP = 'timestamp', + ARRAY = 'array', + OBJECT = 'object' +} + +export enum FeatureValueType { + INT32 = 'int32', + INT64 = 'int64', + FLOAT32 = 'float32', + FLOAT64 = 'float64', + STRING = 'string', + BYTES = 'bytes', + BOOL = 'bool', + UNIX_TIMESTAMP = 'unix_timestamp' +} + +export enum FeatureStatus { + DRAFT = 'draft', + ACTIVE = 'active', + DEPRECATED = 'deprecated', + ARCHIVED = 'archived', + ERROR = 'error' +} + +export interface FeatureValue { + featureId: string; + value: any; + timestamp: Date; + version?: string; + confidence?: number; + metadata?: Record; +} + +export interface FeatureVector { + entityId: string; + features: FeatureValue[]; + timestamp: Date; + version?: string; +} + +export interface FeatureQuery { + featureIds: string[]; + entityIds: string[]; + timestamp?: Date; + version?: string; + includeMetadata?: boolean; +} + +export interface FeatureResponse { + vectors: FeatureVector[]; + metadata: { + totalCount: number; + retrievedAt: Date; + version: string; + }; +} + +export interface FeatureComputation { + id: string; + featureId: string; + expression: string; + dependencies: string[]; + schedule?: ComputationSchedule; + resources: ComputationResources; + status: ComputationStatus; +} + +export interface ComputationSchedule { + cron: string; + timezone: string; + enabled: boolean; +} + +export interface ComputationResources { + cpu: string; + memory: string; + timeout: number; +} + +export enum ComputationStatus { + PENDING = 'pending', + RUNNING = 'running', + COMPLETED = 'completed', + FAILED = 'failed', + CANCELLED = 'cancelled' +} diff --git a/libs/shared-types/src/features/groups.ts b/libs/shared-types/src/features/groups.ts new file mode 100644 index 0000000..69c1955 --- /dev/null +++ b/libs/shared-types/src/features/groups.ts @@ -0,0 +1,124 @@ +/** + * Feature group types + */ + +import { Feature, FeatureStatus } from './base'; + +export interface FeatureGroup { + id: string; + name: string; + description?: string; + features: Feature[]; + tags: string[]; + metadata: Record; + createdAt: Date; + updatedAt: Date; + version: string; + status: FeatureStatus; + owner: string; + entityIdColumns: string[]; + eventTimeColumn?: string; + source: FeatureGroupSource; +} + +export interface FeatureGroupSource { + type: SourceType; + config: SourceConfig; + schedule?: SourceSchedule; +} + +export enum SourceType { + BATCH = 'batch', + STREAMING = 'streaming', + REQUEST_RESPONSE = 'request_response', + PUSH = 'push' +} + +export interface SourceConfig { + // Base source configuration + [key: string]: any; +} + +export interface BatchSourceConfig extends SourceConfig { + dataSource: string; + query?: string; + path?: string; + format: DataFormat; + options?: Record; +} + +export interface StreamingSourceConfig extends SourceConfig { + topic: string; + bootstrapServers: string[]; + consumerGroup: string; + format: DataFormat; + deserializer?: string; +} + +export enum DataFormat { + PARQUET = 'parquet', + AVRO = 'avro', + JSON = 'json', + CSV = 'csv', + DELTA = 'delta', + ICEBERG = 'iceberg' +} + +export interface SourceSchedule { + cron: string; + timezone: string; + enabled: boolean; + retryConfig: RetryConfig; +} + +export interface RetryConfig { + maxRetries: number; + backoffMs: number; + maxBackoffMs: number; + backoffMultiplier: number; +} + +export interface FeatureGroupStats { + featureGroupId: string; + totalFeatures: number; + activeFeatures: number; + lastUpdated: Date; + dataFreshness: Date; + recordCount: number; + storageSize: number; + computeCost: number; +} + +export interface FeatureGroupVersion { + version: string; + featureGroupId: string; + createdAt: Date; + createdBy: string; + changes: FeatureGroupChange[]; + status: VersionStatus; +} + +export interface FeatureGroupChange { + type: ChangeType; + featureId?: string; + field: string; + oldValue?: any; + newValue?: any; + description?: string; +} + +export enum ChangeType { + FEATURE_ADDED = 'feature_added', + FEATURE_REMOVED = 'feature_removed', + FEATURE_MODIFIED = 'feature_modified', + SCHEMA_CHANGED = 'schema_changed', + SOURCE_CHANGED = 'source_changed', + METADATA_UPDATED = 'metadata_updated' +} + +export enum VersionStatus { + DRAFT = 'draft', + ACTIVE = 'active', + DEPRECATED = 'deprecated', + ARCHIVED = 'archived' +} diff --git a/libs/shared-types/src/features/index.ts b/libs/shared-types/src/features/index.ts new file mode 100644 index 0000000..1e8a7ec --- /dev/null +++ b/libs/shared-types/src/features/index.ts @@ -0,0 +1,6 @@ +// Feature store and feature engineering types +export * from './base'; +export * from './groups'; +export * from './serving'; +export * from './lineage'; +export * from './monitoring'; diff --git a/libs/shared-types/src/features/lineage.ts b/libs/shared-types/src/features/lineage.ts new file mode 100644 index 0000000..67d8d37 --- /dev/null +++ b/libs/shared-types/src/features/lineage.ts @@ -0,0 +1,131 @@ +/** + * Feature lineage and dependency tracking types + */ + +export interface FeatureLineage { + featureId: string; + upstreamDependencies: LineageDependency[]; + downstreamDependents: LineageDependency[]; + dataFlow: DataFlowNode[]; + lastUpdated: Date; +} + +export interface LineageDependency { + id: string; + name: string; + type: DependencyType; + relationship: RelationshipType; + metadata?: Record; +} + +export enum DependencyType { + FEATURE = 'feature', + FEATURE_GROUP = 'feature_group', + DATA_SOURCE = 'data_source', + TRANSFORMATION = 'transformation', + MODEL = 'model', + PIPELINE = 'pipeline' +} + +export enum RelationshipType { + DERIVES_FROM = 'derives_from', + DEPENDS_ON = 'depends_on', + TRANSFORMS = 'transforms', + AGGREGATES = 'aggregates', + JOINS = 'joins', + FILTERS = 'filters' +} + +export interface DataFlowNode { + id: string; + name: string; + type: NodeType; + operation: string; + inputs: string[]; + outputs: string[]; + properties: Record; +} + +export enum NodeType { + SOURCE = 'source', + TRANSFORMATION = 'transformation', + AGGREGATION = 'aggregation', + JOIN = 'join', + FILTER = 'filter', + SINK = 'sink' +} + +export interface LineageQuery { + featureId: string; + direction: LineageDirection; + depth?: number; + includeMetadata?: boolean; + filters?: LineageFilter[]; +} + +export enum LineageDirection { + UPSTREAM = 'upstream', + DOWNSTREAM = 'downstream', + BOTH = 'both' +} + +export interface LineageFilter { + field: string; + operator: FilterOperator; + value: any; +} + +export enum FilterOperator { + EQUALS = 'equals', + NOT_EQUALS = 'not_equals', + CONTAINS = 'contains', + STARTS_WITH = 'starts_with', + IN = 'in', + NOT_IN = 'not_in' +} + +export interface LineageAnalysis { + featureId: string; + impactAnalysis: ImpactAnalysis; + riskAssessment: RiskAssessment; + recommendations: LineageRecommendation[]; +} + +export interface ImpactAnalysis { + affectedFeatures: string[]; + affectedModels: string[]; + affectedPipelines: string[]; + estimatedImpactScore: number; + criticalityLevel: CriticalityLevel; +} + +export enum CriticalityLevel { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high', + CRITICAL = 'critical' +} + +export interface RiskAssessment { + breakageRisk: number; + dataQualityRisk: number; + performanceRisk: number; + complianceRisk: number; + overallRisk: number; +} + +export interface LineageRecommendation { + type: RecommendationType; + priority: number; + description: string; + actionItems: string[]; + estimatedEffort: string; +} + +export enum RecommendationType { + OPTIMIZATION = 'optimization', + RISK_MITIGATION = 'risk_mitigation', + REFACTORING = 'refactoring', + DEPRECATION = 'deprecation', + ENHANCEMENT = 'enhancement' +} diff --git a/libs/shared-types/src/features/monitoring.ts b/libs/shared-types/src/features/monitoring.ts new file mode 100644 index 0000000..599664c --- /dev/null +++ b/libs/shared-types/src/features/monitoring.ts @@ -0,0 +1,157 @@ +/** + * Feature monitoring and observability types + */ + +export interface FeatureMonitoring { + featureId: string; + monitoringConfig: MonitoringConfig; + alerts: FeatureAlert[]; + metrics: FeatureMetrics; + status: MonitoringStatus; +} + +export interface MonitoringConfig { + enabled: boolean; + samplingRate: number; + alertThresholds: AlertThreshold[]; + monitoringWindows: MonitoringWindow[]; + customChecks: CustomCheck[]; +} + +export interface AlertThreshold { + metric: string; + operator: ThresholdOperator; + value: number; + severity: AlertSeverity; + window: string; +} + +export enum ThresholdOperator { + GREATER_THAN = 'gt', + LESS_THAN = 'lt', + GREATER_THAN_OR_EQUAL = 'gte', + LESS_THAN_OR_EQUAL = 'lte', + EQUALS = 'eq', + NOT_EQUALS = 'ne' +} + +export enum AlertSeverity { + INFO = 'info', + WARNING = 'warning', + ERROR = 'error', + CRITICAL = 'critical' +} + +export interface MonitoringWindow { + name: string; + duration: string; + aggregation: AggregationType; +} + +export enum AggregationType { + SUM = 'sum', + AVERAGE = 'average', + MIN = 'min', + MAX = 'max', + COUNT = 'count', + PERCENTILE = 'percentile' +} + +export interface CustomCheck { + id: string; + name: string; + expression: string; + frequency: string; + enabled: boolean; +} + +export interface FeatureAlert { + id: string; + featureId: string; + type: AlertType; + severity: AlertSeverity; + message: string; + triggeredAt: Date; + resolvedAt?: Date; + status: AlertStatus; + metadata: Record; +} + +export enum AlertType { + DATA_DRIFT = 'data_drift', + SCHEMA_CHANGE = 'schema_change', + QUALITY_DEGRADATION = 'quality_degradation', + PERFORMANCE_ISSUE = 'performance_issue', + FRESHNESS_VIOLATION = 'freshness_violation', + CUSTOM = 'custom' +} + +export enum AlertStatus { + ACTIVE = 'active', + ACKNOWLEDGED = 'acknowledged', + RESOLVED = 'resolved', + SUPPRESSED = 'suppressed' +} + +export interface FeatureMetrics { + featureId: string; + timestamp: Date; + qualityMetrics: QualityMetrics; + performanceMetrics: PerformanceMetrics; + usageMetrics: UsageMetrics; + distributionMetrics: DistributionMetrics; +} + +export interface QualityMetrics { + completeness: number; + accuracy: number; + consistency: number; + validity: number; + uniqueness: number; + nullRate: number; + outlierRate: number; +} + +export interface PerformanceMetrics { + computeTimeMs: number; + memoryUsageMB: number; + throughputRps: number; + errorRate: number; + p50LatencyMs: number; + p95LatencyMs: number; + p99LatencyMs: number; +} + +export interface UsageMetrics { + requestCount: number; + uniqueConsumers: number; + avgRequestsPerConsumer: number; + popularityScore: number; + lastAccessedAt: Date; +} + +export interface DistributionMetrics { + mean: number; + median: number; + stddev: number; + min: number; + max: number; + skewness: number; + kurtosis: number; + percentiles: Record; + histogram: HistogramBin[]; +} + +export interface HistogramBin { + lowerBound: number; + upperBound: number; + count: number; + frequency: number; +} + +export enum MonitoringStatus { + ACTIVE = 'active', + PAUSED = 'paused', + ERROR = 'error', + DISABLED = 'disabled' +} diff --git a/libs/shared-types/src/features/serving.ts b/libs/shared-types/src/features/serving.ts new file mode 100644 index 0000000..84df256 --- /dev/null +++ b/libs/shared-types/src/features/serving.ts @@ -0,0 +1,134 @@ +/** + * Feature serving and retrieval types + */ + +import { FeatureVector, FeatureQuery } from './base'; + +export interface FeatureStore { + name: string; + type: FeatureStoreType; + config: FeatureStoreConfig; + capabilities: FeatureStoreCapabilities; +} + +export enum FeatureStoreType { + ONLINE = 'online', + OFFLINE = 'offline', + HYBRID = 'hybrid' +} + +export interface FeatureStoreConfig { + connectionString?: string; + credentials?: Record; + caching?: CachingConfig; + performance?: PerformanceConfig; +} + +export interface CachingConfig { + enabled: boolean; + ttlSeconds: number; + maxSize: number; + strategy: CacheStrategy; +} + +export enum CacheStrategy { + LRU = 'lru', + LFU = 'lfu', + TTL = 'ttl', + WRITE_THROUGH = 'write_through', + WRITE_BEHIND = 'write_behind' +} + +export interface PerformanceConfig { + maxConcurrentRequests: number; + timeoutMs: number; + batchSize: number; + compressionEnabled: boolean; +} + +export interface FeatureStoreCapabilities { + supportsPointInTimeCorrectness: boolean; + supportsStreaming: boolean; + supportsBatch: boolean; + supportsTransactions: boolean; + supportsVersioning: boolean; + maxFeatureVectorSize: number; +} + +export interface FeatureServingRequest { + query: FeatureQuery; + options?: ServingOptions; + metadata?: Record; +} + +export interface ServingOptions { + consistencyLevel: ConsistencyLevel; + maxLatencyMs?: number; + fallbackStrategy?: FallbackStrategy; + includeStatistics?: boolean; +} + +export enum ConsistencyLevel { + EVENTUAL = 'eventual', + STRONG = 'strong', + BOUNDED_STALENESS = 'bounded_staleness' +} + +export enum FallbackStrategy { + DEFAULT_VALUES = 'default_values', + CACHED_VALUES = 'cached_values', + COMPUTED_VALUES = 'computed_values', + FAIL_FAST = 'fail_fast' +} + +export interface FeatureServingResponse { + vectors: FeatureVector[]; + statistics?: ServingStatistics; + metadata: { + requestId: string; + servedAt: Date; + latencyMs: number; + sourceStore: string; + }; +} + +export interface ServingStatistics { + cacheHitRate: number; + avgLatencyMs: number; + errorRate: number; + throughputRps: number; +} + +export interface OnlineServingConfig { + lowLatencyStores: string[]; + fallbackStores: string[]; + caching: CachingConfig; + circuitBreaker: CircuitBreakerConfig; +} + +export interface CircuitBreakerConfig { + enabled: boolean; + failureThreshold: number; + timeoutMs: number; + resetTimeoutMs: number; +} + +export interface OfflineServingConfig { + batchSize: number; + parallelism: number; + outputFormat: string; + partitioning: PartitioningConfig; +} + +export interface PartitioningConfig { + columns: string[]; + strategy: PartitioningStrategy; + buckets?: number; +} + +export enum PartitioningStrategy { + HASH = 'hash', + RANGE = 'range', + LIST = 'list', + TIME = 'time' +} diff --git a/libs/shared-types/src/governance/access.ts b/libs/shared-types/src/governance/access.ts new file mode 100644 index 0000000..367c469 --- /dev/null +++ b/libs/shared-types/src/governance/access.ts @@ -0,0 +1,282 @@ +// Access Control and Security Types + +export interface AccessPolicy { + id: string; + name: string; + description?: string; + rules: AccessRule[]; + scope: AccessScope; + enabled: boolean; + metadata?: Record; +} + +export interface AccessRule { + id: string; + name: string; + subjects: AccessSubject[]; + actions: AccessAction[]; + resources: AccessResource[]; + conditions?: AccessCondition[]; + effect: AccessEffect; + priority: number; +} + +export interface AccessSubject { + type: SubjectType; + identifier: string; + attributes?: Record; +} + +export enum SubjectType { + USER = 'user', + GROUP = 'group', + ROLE = 'role', + SERVICE = 'service', + APPLICATION = 'application' +} + +export interface AccessAction { + type: ActionType; + scope?: string[]; +} + +export enum ActionType { + READ = 'read', + WRITE = 'write', + DELETE = 'delete', + EXECUTE = 'execute', + ADMIN = 'admin', + AUDIT = 'audit' +} + +export interface AccessResource { + type: ResourceType; + identifier: string; + attributes?: Record; +} + +export enum ResourceType { + DATASET = 'dataset', + TABLE = 'table', + COLUMN = 'column', + FILE = 'file', + API = 'api', + SERVICE = 'service', + FUNCTION = 'function' +} + +export interface AccessCondition { + type: ConditionType; + operator: ConditionOperator; + value: any; +} + +export enum ConditionType { + TIME = 'time', + IP_ADDRESS = 'ip_address', + LOCATION = 'location', + DEVICE = 'device', + CLASSIFICATION = 'classification', + CUSTOM = 'custom' +} + +export enum ConditionOperator { + EQUALS = 'equals', + NOT_EQUALS = 'not_equals', + IN = 'in', + NOT_IN = 'not_in', + GREATER_THAN = 'greater_than', + LESS_THAN = 'less_than', + CONTAINS = 'contains', + REGEX = 'regex' +} + +export enum AccessEffect { + ALLOW = 'allow', + DENY = 'deny' +} + +export interface AccessScope { + environments: string[]; + regions: string[]; + organizations: string[]; + projects: string[]; +} + +export interface AccessRequest { + id: string; + subject: AccessSubject; + action: AccessAction; + resource: AccessResource; + context: AccessContext; + timestamp: Date; + status: RequestStatus; +} + +export interface AccessContext { + ipAddress?: string; + userAgent?: string; + location?: GeoLocation; + device?: DeviceInfo; + session?: SessionInfo; + additional?: Record; +} + +export interface GeoLocation { + country: string; + region: string; + city: string; + latitude: number; + longitude: number; +} + +export interface DeviceInfo { + id: string; + type: DeviceType; + os: string; + browser?: string; + trusted: boolean; +} + +export enum DeviceType { + DESKTOP = 'desktop', + MOBILE = 'mobile', + TABLET = 'tablet', + SERVER = 'server', + IOT = 'iot' +} + +export interface SessionInfo { + id: string; + startTime: Date; + lastActivity: Date; + authenticated: boolean; + mfaVerified: boolean; +} + +export enum RequestStatus { + PENDING = 'pending', + APPROVED = 'approved', + DENIED = 'denied', + EXPIRED = 'expired', + REVOKED = 'revoked' +} + +export interface AccessAuditLog { + id: string; + timestamp: Date; + subject: AccessSubject; + action: AccessAction; + resource: AccessResource; + decision: AccessDecision; + reason: string; + context: AccessContext; +} + +export interface AccessDecision { + effect: AccessEffect; + policies: string[]; + evaluationTime: number; + cached: boolean; +} + +export interface AccessDataClassification { + level: ClassificationLevel; + categories: DataCategory[]; + handling: HandlingRequirement[]; + retention: AccessRetentionPolicy; + sensitivity: SensitivityMarking[]; +} + +export enum ClassificationLevel { + PUBLIC = 'public', + INTERNAL = 'internal', + CONFIDENTIAL = 'confidential', + RESTRICTED = 'restricted', + SECRET = 'secret', + TOP_SECRET = 'top_secret' +} + +export enum DataCategory { + PII = 'pii', + PHI = 'phi', + FINANCIAL = 'financial', + TRADE_SECRET = 'trade_secret', + INTELLECTUAL_PROPERTY = 'intellectual_property', + REGULATORY = 'regulatory' +} + +export interface HandlingRequirement { + type: HandlingType; + mandatory: boolean; + description: string; +} + +export enum HandlingType { + ENCRYPTION_AT_REST = 'encryption_at_rest', + ENCRYPTION_IN_TRANSIT = 'encryption_in_transit', + ACCESS_LOGGING = 'access_logging', + BACKUP_RESTRICTION = 'backup_restriction', + GEOGRAPHIC_RESTRICTION = 'geographic_restriction', + TIME_RESTRICTION = 'time_restriction' +} + +export interface AccessRetentionPolicy { + period: RetentionPeriod; + disposal: DisposalMethod; + exceptions: RetentionException[]; +} + +export interface RetentionPeriod { + duration: number; + unit: AccessTimeUnit; + triggers: RetentionTrigger[]; +} + +export enum AccessTimeUnit { + DAYS = 'days', + WEEKS = 'weeks', + MONTHS = 'months', + YEARS = 'years' +} + +export enum RetentionTrigger { + CREATION_DATE = 'creation_date', + LAST_ACCESS = 'last_access', + BUSINESS_EVENT = 'business_event', + LEGAL_HOLD = 'legal_hold' +} + +export enum DisposalMethod { + SOFT_DELETE = 'soft_delete', + HARD_DELETE = 'hard_delete', + ANONYMIZATION = 'anonymization', + ENCRYPTION_KEY_DESTRUCTION = 'encryption_key_destruction' +} + +export interface RetentionException { + reason: string; + period: RetentionPeriod; + approver: string; + expiration: Date; +} + +export interface SensitivityMarking { + type: MarkingType; + value: string; + scope: MarkingScope; +} + +export enum MarkingType { + CLASSIFICATION = 'classification', + HANDLING = 'handling', + DISSEMINATION = 'dissemination', + CUSTOM = 'custom' +} + +export enum MarkingScope { + DATASET = 'dataset', + FIELD = 'field', + RECORD = 'record', + VALUE = 'value' +} diff --git a/libs/shared-types/src/governance/catalog.ts b/libs/shared-types/src/governance/catalog.ts new file mode 100644 index 0000000..c3e1f45 --- /dev/null +++ b/libs/shared-types/src/governance/catalog.ts @@ -0,0 +1,253 @@ +/** + * Data catalog and metadata types + */ + +export interface DataAsset { + id: string; + name: string; + type: AssetType; + description?: string; + tags: string[]; + schema: DataSchema; + location: AssetLocation; + metadata: AssetMetadata; + governance: GovernanceInfo; + createdAt: Date; + updatedAt: Date; + version: string; +} + +export enum AssetType { + TABLE = 'table', + VIEW = 'view', + DATASET = 'dataset', + FEATURE_GROUP = 'feature_group', + MODEL = 'model', + PIPELINE = 'pipeline', + REPORT = 'report', + API = 'api' +} + +export interface DataSchema { + columns: ColumnDefinition[]; + primaryKeys: string[]; + foreignKeys: ForeignKey[]; + indexes: IndexDefinition[]; + constraints: ConstraintDefinition[]; +} + +export interface ColumnDefinition { + name: string; + dataType: string; + nullable: boolean; + defaultValue?: any; + description?: string; + tags: string[]; + constraints: string[]; + statistics?: ColumnStatistics; +} + +export interface ColumnStatistics { + distinctCount: number; + nullCount: number; + minValue?: any; + maxValue?: any; + avgLength?: number; + topValues: ValueCount[]; +} + +export interface ValueCount { + value: any; + count: number; + frequency: number; +} + +export interface ForeignKey { + columnNames: string[]; + referencedTable: string; + referencedColumns: string[]; + name?: string; +} + +export interface IndexDefinition { + name: string; + columns: string[]; + type: IndexType; + unique: boolean; +} + +export enum IndexType { + BTREE = 'btree', + HASH = 'hash', + BITMAP = 'bitmap', + FULLTEXT = 'fulltext' +} + +export interface ConstraintDefinition { + name: string; + type: ConstraintType; + columns: string[]; + expression?: string; +} + +export enum ConstraintType { + PRIMARY_KEY = 'primary_key', + FOREIGN_KEY = 'foreign_key', + UNIQUE = 'unique', + CHECK = 'check', + NOT_NULL = 'not_null' +} + +export interface AssetLocation { + type: LocationType; + uri: string; + connection: string; + path?: string; + format?: string; + options?: Record; +} + +export enum LocationType { + DATABASE = 'database', + FILE_SYSTEM = 'file_system', + OBJECT_STORE = 'object_store', + STREAMING = 'streaming', + API_ENDPOINT = 'api_endpoint' +} + +export interface AssetMetadata { + businessContext: BusinessContext; + technicalContext: TechnicalContext; + qualityProfile: QualityProfile; + usage: UsageProfile; + lineage: LineageInfo; +} + +export interface QualityProfile { + completeness: number; + accuracy: number; + consistency: number; + validity: number; + freshness: number; + lastAssessed: Date; +} + +export interface UsageProfile { + accessCount: number; + lastAccessed: Date; + popularQueries: string[]; + topUsers: string[]; + usagePattern: UsagePattern; +} + +export enum UsagePattern { + BATCH = 'batch', + STREAMING = 'streaming', + INTERACTIVE = 'interactive', + MIXED = 'mixed' +} + +export interface LineageInfo { + upstream: DataLineageNode[]; + downstream: DataLineageNode[]; + transformations: TransformationInfo[]; + lastUpdated: Date; +} + +export interface DataLineageNode { + id: string; + type: NodeType; + name: string; + path: string; + system: string; +} + +export enum NodeType { + SOURCE = 'source', + TARGET = 'target', + TRANSFORM = 'transform', + VIEW = 'view', + TABLE = 'table', + FILE = 'file' +} + +export interface TransformationInfo { + id: string; + type: string; + description: string; + code?: string; + parameters?: Record; +} + +export interface BusinessContext { + domain: string; + subdomain?: string; + businessOwner: string; + businessDescription?: string; + businessRules: string[]; + criticalityLevel: CriticalityLevel; +} + +export enum CriticalityLevel { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high', + CRITICAL = 'critical' +} + +export interface TechnicalContext { + dataOwner: string; + maintainer: string; + technology: string; + updateFrequency: UpdateFrequency; + retentionPolicy: RetentionPolicy; + backupPolicy: BackupPolicy; +} + +export enum UpdateFrequency { + REAL_TIME = 'real_time', + STREAMING = 'streaming', + HOURLY = 'hourly', + DAILY = 'daily', + WEEKLY = 'weekly', + MONTHLY = 'monthly', + YEARLY = 'yearly', + MANUAL = 'manual' +} + +export interface RetentionPolicy { + retentionPeriod: string; + archiveAfter?: string; + deleteAfter?: string; + retentionReason: string; +} + +export interface BackupPolicy { + enabled: boolean; + frequency: string; + retentionPeriod: string; + location: string; +} + +export interface GovernanceInfo { + classification: DataClassification; + sensitivityLevel: SensitivityLevel; + accessPolicy: string; + complianceRequirements: string[]; + dataProtectionMeasures: string[]; + approvalWorkflow?: string; +} + +export enum DataClassification { + PUBLIC = 'public', + INTERNAL = 'internal', + CONFIDENTIAL = 'confidential', + RESTRICTED = 'restricted' +} + +export enum SensitivityLevel { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high', + CRITICAL = 'critical' +} diff --git a/libs/shared-types/src/governance/compliance.ts b/libs/shared-types/src/governance/compliance.ts new file mode 100644 index 0000000..bbbdd5a --- /dev/null +++ b/libs/shared-types/src/governance/compliance.ts @@ -0,0 +1,183 @@ +// Compliance and Regulatory Types + +export interface CompliancePolicy { + id: string; + name: string; + description?: string; + regulation: RegulationType; + requirements: ComplianceRequirement[]; + scope: ComplianceScope; + enabled: boolean; + metadata?: Record; +} + +export enum RegulationType { + SOX = 'sox', + GDPR = 'gdpr', + CCPA = 'ccpa', + HIPAA = 'hipaa', + PCI_DSS = 'pci_dss', + SOC2 = 'soc2', + ISO27001 = 'iso27001', + CUSTOM = 'custom' +} + +export interface ComplianceRequirement { + id: string; + name: string; + description: string; + controls: ComplianceControl[]; + severity: ComplianceSeverity; + mandatory: boolean; +} + +export enum ComplianceSeverity { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high', + CRITICAL = 'critical' +} + +export interface ComplianceControl { + id: string; + type: ControlType; + implementation: ControlImplementation; + verification: ControlVerification; + status: ControlStatus; +} + +export enum ControlType { + PREVENTIVE = 'preventive', + DETECTIVE = 'detective', + CORRECTIVE = 'corrective', + COMPENSATING = 'compensating' +} + +export interface ControlImplementation { + automated: boolean; + frequency: ControlFrequency; + responsible: string[]; + documentation: string[]; +} + +export enum ControlFrequency { + CONTINUOUS = 'continuous', + DAILY = 'daily', + WEEKLY = 'weekly', + MONTHLY = 'monthly', + QUARTERLY = 'quarterly', + ANNUALLY = 'annually', + ON_DEMAND = 'on_demand' +} + +export interface ControlVerification { + method: VerificationMethod; + evidence: EvidenceType[]; + frequency: ControlFrequency; + responsible: string[]; +} + +export enum VerificationMethod { + AUTOMATED_TEST = 'automated_test', + MANUAL_REVIEW = 'manual_review', + AUDIT = 'audit', + WALKTHROUGH = 'walkthrough', + OBSERVATION = 'observation' +} + +export enum EvidenceType { + SCREENSHOT = 'screenshot', + LOG_FILE = 'log_file', + DOCUMENT = 'document', + REPORT = 'report', + ATTESTATION = 'attestation', + SYSTEM_OUTPUT = 'system_output' +} + +export enum ControlStatus { + EFFECTIVE = 'effective', + INEFFECTIVE = 'ineffective', + NOT_TESTED = 'not_tested', + DEFICIENT = 'deficient', + NOT_APPLICABLE = 'not_applicable' +} + +export interface ComplianceScope { + systems: string[]; + processes: string[]; + dataTypes: string[]; + locations: string[]; + timeframe: TimeFrame; +} + +export interface TimeFrame { + start: Date; + end: Date; + ongoing: boolean; +} + +export interface ComplianceAssessment { + id: string; + policyId: string; + timestamp: Date; + assessor: string; + status: AssessmentStatus; + findings: ComplianceFinding[]; + recommendations: ComplianceRecommendation[]; + score: number; +} + +export enum AssessmentStatus { + COMPLIANT = 'compliant', + NON_COMPLIANT = 'non_compliant', + PARTIALLY_COMPLIANT = 'partially_compliant', + NOT_ASSESSED = 'not_assessed' +} + +export interface ComplianceFinding { + id: string; + requirementId: string; + controlId: string; + severity: ComplianceSeverity; + description: string; + evidence: string[]; + remediation: string; + dueDate?: Date; + status: FindingStatus; +} + +export enum FindingStatus { + OPEN = 'open', + IN_PROGRESS = 'in_progress', + CLOSED = 'closed', + DEFERRED = 'deferred', + ACCEPTED_RISK = 'accepted_risk' +} + +export interface ComplianceRecommendation { + id: string; + priority: RecommendationPriority; + description: string; + implementation: string; + effort: EffortLevel; + impact: ImpactLevel; +} + +export enum RecommendationPriority { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high', + URGENT = 'urgent' +} + +export enum EffortLevel { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high' +} + +export enum ImpactLevel { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high' +} diff --git a/libs/shared-types/src/governance/index.ts b/libs/shared-types/src/governance/index.ts new file mode 100644 index 0000000..2f69cbf --- /dev/null +++ b/libs/shared-types/src/governance/index.ts @@ -0,0 +1,6 @@ +// Data governance and metadata management types +export * from './catalog'; +export * from './quality'; +export * from './lifecycle'; +export * from './compliance'; +export * from './access'; diff --git a/libs/shared-types/src/governance/lifecycle.ts b/libs/shared-types/src/governance/lifecycle.ts new file mode 100644 index 0000000..c0791e1 --- /dev/null +++ b/libs/shared-types/src/governance/lifecycle.ts @@ -0,0 +1,160 @@ +// Data Lifecycle Management Types + +export interface LifecyclePolicy { + id: string; + name: string; + description?: string; + rules: LifecycleRule[]; + scope: LifecycleScope; + enabled: boolean; + metadata?: Record; +} + +export interface LifecycleRule { + id: string; + name: string; + condition: LifecycleCondition; + actions: LifecycleAction[]; + priority: number; + enabled: boolean; +} + +export interface LifecycleCondition { + age?: AgeCriteria; + size?: SizeCriteria; + usage?: UsageCriteria; + tags?: TagCriteria; + custom?: string; +} + +export interface AgeCriteria { + unit: LifecycleTimeUnit; + value: number; +} + +export enum LifecycleTimeUnit { + DAYS = 'days', + WEEKS = 'weeks', + MONTHS = 'months', + YEARS = 'years' +} + +export interface SizeCriteria { + unit: SizeUnit; + value: number; +} + +export enum SizeUnit { + BYTES = 'bytes', + KB = 'kb', + MB = 'mb', + GB = 'gb', + TB = 'tb' +} + +export interface UsageCriteria { + accessCount: number; + lastAccessed: Date; +} + +export interface TagCriteria { + tags: Record; + operator: TagOperator; +} + +export enum TagOperator { + AND = 'and', + OR = 'or', + NOT = 'not' +} + +export interface LifecycleAction { + type: LifecycleActionType; + config: LifecycleActionConfig; +} + +export enum LifecycleActionType { + ARCHIVE = 'archive', + DELETE = 'delete', + COMPRESS = 'compress', + MIGRATE = 'migrate', + NOTIFY = 'notify', + CUSTOM = 'custom' +} + +export interface LifecycleActionConfig { + destination?: string; + notification?: NotificationConfig; + compression?: CompressionConfig; + migration?: MigrationConfig; + custom?: Record; +} + +export interface NotificationConfig { + recipients: string[]; + subject: string; + template: string; +} + +export interface CompressionConfig { + algorithm: CompressionAlgorithm; + level: number; +} + +export enum CompressionAlgorithm { + GZIP = 'gzip', + BZIP2 = 'bzip2', + LZ4 = 'lz4', + ZSTD = 'zstd' +} + +export interface MigrationConfig { + destination: string; + preserveMetadata: boolean; + verification: boolean; +} + +export interface LifecycleScope { + datasets?: string[]; + collections?: string[]; + tags?: Record; + pattern?: string; +} + +export interface LifecycleExecution { + id: string; + policyId: string; + timestamp: Date; + status: ExecutionStatus; + summary: ExecutionSummary; + details: ExecutionDetail[]; +} + +export enum ExecutionStatus { + PENDING = 'pending', + RUNNING = 'running', + COMPLETED = 'completed', + FAILED = 'failed', + CANCELLED = 'cancelled' +} + +export interface ExecutionSummary { + totalItems: number; + processedItems: number; + failedItems: number; + duration: number; +} + +export interface ExecutionDetail { + itemId: string; + action: LifecycleActionType; + status: ItemStatus; + message?: string; + timestamp: Date; +} + +export enum ItemStatus { + SUCCESS = 'success', + FAILED = 'failed', + SKIPPED = 'skipped' +} diff --git a/libs/shared-types/src/governance/quality.ts b/libs/shared-types/src/governance/quality.ts new file mode 100644 index 0000000..870e66f --- /dev/null +++ b/libs/shared-types/src/governance/quality.ts @@ -0,0 +1,107 @@ +// Data Quality Management Types + +export interface DataQualityProfile { + id: string; + name: string; + description?: string; + rules: DataQualityRule[]; + thresholds: QualityThreshold[]; + schedule?: QualitySchedule; + enabled: boolean; + metadata?: Record; +} + +export interface DataQualityRule { + id: string; + name: string; + type: QualityRuleType; + condition: string; + severity: QualitySeverity; + message?: string; + enabled: boolean; +} + +export enum QualityRuleType { + COMPLETENESS = 'completeness', + UNIQUENESS = 'uniqueness', + VALIDITY = 'validity', + CONSISTENCY = 'consistency', + ACCURACY = 'accuracy', + TIMELINESS = 'timeliness', + CUSTOM = 'custom' +} + +export enum QualitySeverity { + LOW = 'low', + MEDIUM = 'medium', + HIGH = 'high', + CRITICAL = 'critical' +} + +export interface QualityThreshold { + metric: string; + operator: ThresholdOperator; + value: number; + severity: QualitySeverity; +} + +export enum ThresholdOperator { + GREATER_THAN = 'gt', + GREATER_THAN_EQUAL = 'gte', + LESS_THAN = 'lt', + LESS_THAN_EQUAL = 'lte', + EQUAL = 'eq', + NOT_EQUAL = 'ne' +} + +export interface QualitySchedule { + cron: string; + timezone: string; + enabled: boolean; +} + +export interface QualityReport { + id: string; + profileId: string; + datasetId: string; + timestamp: Date; + status: QualityStatus; + metrics: QualityMetrics; + violations: QualityViolation[]; + summary: QualitySummary; +} + +export enum QualityStatus { + PASSED = 'passed', + WARNING = 'warning', + FAILED = 'failed', + ERROR = 'error' +} + +export interface QualityMetrics { + completeness: number; + uniqueness: number; + validity: number; + consistency: number; + accuracy: number; + timeliness: number; + overall: number; +} + +export interface QualityViolation { + ruleId: string; + ruleName: string; + severity: QualitySeverity; + count: number; + percentage: number; + samples?: any[]; + message: string; +} + +export interface QualitySummary { + totalRecords: number; + validRecords: number; + invalidRecords: number; + score: number; + status: QualityStatus; +} diff --git a/libs/shared-types/src/index.ts b/libs/shared-types/src/index.ts index c93664b..e190dac 100644 --- a/libs/shared-types/src/index.ts +++ b/libs/shared-types/src/index.ts @@ -13,5 +13,103 @@ export * from './strategy/backtest'; // Events export * from './events/events'; -// API Types -export * from './api/api'; +// API Types - Use aliases to avoid conflicts +export { + ServiceConfig, + ApiHealthStatus, + ApiResponse, + PaginatedResponse, + ErrorResponse as ApiErrorResponse, + SuccessResponse +} from './api/api'; + +// Configuration Types (Core config only to avoid conflicts) +export * from './config/database'; +export * from './config/logging'; +export * from './config/security'; + +// Monitoring Types - Use aliases to avoid conflicts +export { + HealthStatus, + HealthCheckConfig as MonitoringHealthCheckConfig, + DependencyHealth, + HealthMetrics, + ReadinessCheck, + LivenessCheck +} from './monitoring/health'; +export * from './monitoring/metrics'; + +// Data Processing Types - Use aliases to avoid conflicts +export { + DataSourceConfig, + DataRateLimitConfig, + DataConnectionConfig, + DataAuthenticationConfig, + SubscriptionConfig as DataSubscriptionConfig, + RetryPolicyConfig +} from './data/sources'; +export * from './data/processors'; + +// Communication Types - Main subscription system preferred +export * from './communication/subscriptions'; +export * from './communication/messages'; + +// Error Handling Types - Use aliases to avoid conflicts +export { + BaseError, + ErrorContext, + ErrorResponse as BaseErrorResponse, + ErrorCode, + ErrorSeverity as BaseErrorSeverity +} from './errors/base'; +export { + ValidationError, + ValidationRule as ErrorValidationRule, + SchemaValidationError, + BusinessRuleValidationError +} from './errors/validation'; +export * from './errors/network'; +export * from './errors/business'; +export * from './errors/application'; + +// Governance Types - Catalog types with alias to avoid conflicts +export { + DataAsset, + AssetType, + DataSchema as CatalogDataSchema, + ColumnDefinition, + ColumnStatistics, + ValueCount, + ForeignKey as CatalogForeignKey, + IndexDefinition, + IndexType, + ConstraintDefinition, + ConstraintType, + AssetLocation, + LocationType, + AssetMetadata, + QualityProfile, + UsageProfile, + UsagePattern, + LineageInfo, + DataLineageNode, + NodeType, + TransformationInfo, + BusinessContext, + CriticalityLevel, + TechnicalContext, + UpdateFrequency, + RetentionPolicy as CatalogRetentionPolicy, + BackupPolicy, + GovernanceInfo, + DataClassification as CatalogDataClassification, + SensitivityLevel +} from './governance/catalog'; + +// All modules successfully enabled - conflicts resolved with type renaming and aliases +export * from './communication/websocket'; +export * from './communication/protocols'; +export * from './governance/quality'; +export * from './governance/lifecycle'; +export * from './governance/compliance'; +export * from './governance/access'; diff --git a/libs/shared-types/src/market/market-data.ts b/libs/shared-types/src/market/market-data.ts index 554a548..3f6c35a 100644 --- a/libs/shared-types/src/market/market-data.ts +++ b/libs/shared-types/src/market/market-data.ts @@ -1,4 +1,65 @@ // Market Data Types +export interface MarketDataTick { + symbol: string; + timestamp: number; + price: number; + volume: number; + bid?: number; + ask?: number; + bidSize?: number; + askSize?: number; + source: string; + exchange?: string; + lastTradeSize?: number; + dayHigh?: number; + dayLow?: number; + dayOpen?: number; + prevClose?: number; + change?: number; + changePercent?: number; +} + +export interface MarketDataCandle { + symbol: string; + timestamp: number; + open: number; + high: number; + low: number; + close: number; + volume: number; + timeframe: string; + source: string; + exchange?: string; + vwap?: number; + trades?: number; +} + +export interface MarketDataTrade { + id: string; + symbol: string; + timestamp: number; + price: number; + size: number; + side: 'buy' | 'sell'; + source: string; + exchange?: string; + conditions?: string[]; +} + +export interface MarketDataOrder { + id: string; + symbol: string; + timestamp: number; + side: 'buy' | 'sell'; + price: number; + size: number; + source: string; + exchange?: string; + orderType?: 'market' | 'limit' | 'stop'; + level?: number; +} + +// Legacy types for backward compatibility export interface OHLCV { symbol: string; timestamp: Date; diff --git a/libs/shared-types/src/monitoring/alerts.ts b/libs/shared-types/src/monitoring/alerts.ts new file mode 100644 index 0000000..1d00143 --- /dev/null +++ b/libs/shared-types/src/monitoring/alerts.ts @@ -0,0 +1,83 @@ +// Alert and Notification Types +export interface Alert { + id: string; + ruleId: string; + severity: 'info' | 'warning' | 'error' | 'critical'; + title: string; + message: string; + timestamp: Date; + resolved: boolean; + resolvedAt?: Date; + metadata?: Record; + source: string; + tags?: string[]; +} + +export interface AlertRule { + id: string; + name: string; + metric: string; + condition: 'gt' | 'lt' | 'eq' | 'ne' | 'gte' | 'lte'; + threshold: number; + duration: number; + enabled: boolean; + severity?: 'info' | 'warning' | 'error' | 'critical'; + description?: string; + labels?: Record; + annotations?: Record; +} + +export interface AlertChannel { + id: string; + name: string; + type: 'email' | 'slack' | 'webhook' | 'pagerduty' | 'discord'; + config: AlertChannelConfig; + enabled: boolean; + filters?: AlertFilter[]; +} + +export interface AlertChannelConfig { + url?: string; + token?: string; + channel?: string; + username?: string; + password?: string; + headers?: Record; + template?: string; +} + +export interface AlertFilter { + field: string; + operator: 'equals' | 'contains' | 'regex' | 'not_equals'; + value: string; +} + +export interface NotificationConfig { + enabled: boolean; + channels: AlertChannel[]; + defaultChannel: string; + retryAttempts: number; + retryDelay: number; + batchSize: number; + batchDelay: number; +} + +export interface AlertHistory { + alertId: string; + action: 'triggered' | 'resolved' | 'acknowledged' | 'silenced'; + timestamp: Date; + user?: string; + reason?: string; + metadata?: Record; +} + +export interface AlertSummary { + total: number; + critical: number; + error: number; + warning: number; + info: number; + resolved: number; + active: number; + timeRange: string; +} diff --git a/libs/shared-types/src/monitoring/health.ts b/libs/shared-types/src/monitoring/health.ts new file mode 100644 index 0000000..4f6d965 --- /dev/null +++ b/libs/shared-types/src/monitoring/health.ts @@ -0,0 +1,52 @@ +// Health Check Types +export interface HealthStatus { + service: string; + status: 'healthy' | 'degraded' | 'unhealthy'; + timestamp: Date; + uptime: number; + version: string; + dependencies: DependencyHealth[]; + metrics: HealthMetrics; + message?: string; + details?: Record; +} + +export interface DependencyHealth { + name: string; + status: 'healthy' | 'unhealthy'; + latencyMs?: number; + error?: string; + lastChecked?: Date; + version?: string; +} + +export interface HealthMetrics { + connectionsActive: number; + messagesPerSecond: number; + errorRate: number; + avgLatencyMs: number; + memoryUsageMB?: number; + cpuUsagePercent?: number; +} + +export interface HealthCheckConfig { + intervalMs: number; + timeoutMs: number; + retries: number; + enabledChecks: string[]; + endpoints: Record; +} + +export interface ReadinessCheck { + name: string; + check: () => Promise; + timeout: number; + critical: boolean; +} + +export interface LivenessCheck { + name: string; + check: () => Promise; + timeout: number; + restartOnFailure: boolean; +} diff --git a/libs/shared-types/src/monitoring/index.ts b/libs/shared-types/src/monitoring/index.ts new file mode 100644 index 0000000..8e97199 --- /dev/null +++ b/libs/shared-types/src/monitoring/index.ts @@ -0,0 +1,5 @@ +// Health Check and Monitoring Types +export * from './health'; +export * from './metrics'; +export * from './alerts'; +export * from './system'; diff --git a/libs/shared-types/src/monitoring/metrics.ts b/libs/shared-types/src/monitoring/metrics.ts new file mode 100644 index 0000000..b54cb46 --- /dev/null +++ b/libs/shared-types/src/monitoring/metrics.ts @@ -0,0 +1,131 @@ +// Metrics Collection Types +export interface Metric { + name: string; + type: 'counter' | 'gauge' | 'histogram' | 'summary'; + value: number; + labels?: Record; + timestamp: Date; + unit?: string; + description?: string; +} + +export interface MetricPoint { + timestamp: number; + value: number; + labels?: Record; +} + +export interface TimeSeriesMetric { + name: string; + points: MetricPoint[]; + retentionMs: number; +} + +export interface AggregatedMetrics { + totalMessages: number; + messagesPerSecond: number; + averageLatency: number; + errorRate: number; + activeConnections: number; + activeSubscriptions: number; + cacheHitRate: number; + uptime: number; + timestamp: string; + dataSources: Map; + processing: ProcessingMetrics; + subscriptions: MonitoringSubscriptionMetrics; +} + +export interface DataSourceMetrics { + sourceId: string; + timestamp: Date; + connections: ConnectionMetrics; + messages: MessageMetrics; + latency: LatencyMetrics; + bandwidth: BandwidthMetrics; +} + +export interface ConnectionMetrics { + active: number; + total: number; + failed: number; +} + +export interface MessageMetrics { + received: number; + processed: number; + errors: number; + dropped: number; +} + +export interface LatencyMetrics { + avgMs: number; + p50Ms: number; + p95Ms: number; + p99Ms: number; +} + +export interface BandwidthMetrics { + inboundBytesPerSecond: number; + outboundBytesPerSecond: number; +} + +export interface ProcessingMetrics { + totalProcessed: number; + processedPerSecond: number; + processingLatency: number; + errorCount: number; + queueDepth: number; + processorMetrics: Map; +} + +export interface MonitoringSubscriptionMetrics { + totalSubscriptions: number; + activeClients: number; + messagesSent: number; + sendRate: number; + bandwidthUsage: number; +} + +export interface SystemMetrics { + uptime: number; + memory: MemoryMetrics; + cpu: CpuMetrics; + network: NetworkMetrics; + disk: DiskMetrics; + timestamp: string; +} + +export interface MemoryMetrics { + used: number; + total: number; + free: number; + heapUsed: number; + heapTotal: number; + external: number; +} + +export interface CpuMetrics { + user: number; + system: number; + idle: number; + usage: number; +} + +export interface NetworkMetrics { + bytesIn: number; + bytesOut: number; + packetsIn: number; + packetsOut: number; + errors: number; +} + +export interface DiskMetrics { + used: number; + total: number; + free: number; + readOps: number; + writeOps: number; + readBytes: number; + writeBytes: number; +} diff --git a/libs/shared-types/src/monitoring/system.ts b/libs/shared-types/src/monitoring/system.ts new file mode 100644 index 0000000..4aef7a8 --- /dev/null +++ b/libs/shared-types/src/monitoring/system.ts @@ -0,0 +1,57 @@ +import { ApiKeyConfig } from '../config/security'; +import { RetryConfig } from '../config/networking'; + +// System and Service Integration Types +export interface ServiceHealth { + serviceId: string; + status: 'healthy' | 'degraded' | 'unhealthy' | 'unreachable'; + lastCheck: number; + responseTime: number; + errorCount: number; + version?: string; + metadata?: Record; +} + +export interface IntegrationMetrics { + totalRequests: number; + successfulRequests: number; + failedRequests: number; + averageResponseTime: number; + lastRequestTime: number; + errorRate: number; + uptime: number; +} + +export interface ServiceIntegration { + serviceName: string; + endpoint: string; + healthCheck: string; + authentication?: ApiKeyConfig; + retryPolicy: RetryConfig; + timeout?: number; + enabled: boolean; +} + +export interface ServiceEndpoint { + id: string; + name: string; + url: string; + method: string; + headers?: Record; + timeout: number; + retries: number; + healthCheck?: boolean; +} + +export interface ServiceRegistry { + services: Map; + lastUpdated: Date; + version: string; +} + +export interface ServiceDiscovery { + provider: 'consul' | 'etcd' | 'kubernetes' | 'static'; + config: Record; + refreshInterval: number; + healthCheckInterval: number; +} diff --git a/libs/utils/package.json b/libs/utils/package.json index 1e91b1d..2053cce 100644 --- a/libs/utils/package.json +++ b/libs/utils/package.json @@ -10,7 +10,7 @@ "clean": "rm -rf dist", "test": "jest" }, "dependencies": { - "@stock-bot/shared-types": "workspace:*", + "@stock-bot/types": "workspace:*", "@stock-bot/config": "workspace:*", "date-fns": "^2.30.0" }, diff --git a/package-lock.json b/package-lock.json index 3988a41..7ea07f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "version": "1.0.0", "dependencies": { "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "hono": "^4.6.3", "ioredis": "^5.4.1", "ws": "^8.18.0" @@ -39,7 +39,7 @@ "version": "1.0.0", "dependencies": { "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "hono": "^4.6.3", "ioredis": "^5.4.1", "ws": "^8.18.0" @@ -53,7 +53,7 @@ "version": "1.0.0", "dependencies": { "@stock-bot/config": "*", - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "hono": "^4.6.3", "ioredis": "^5.4.1", "node-cron": "^3.0.3", @@ -1886,8 +1886,8 @@ "resolved": "packages/config", "link": true }, - "node_modules/@stock-bot/shared-types": { - "resolved": "packages/shared-types", + "node_modules/@stock-bot/types": { + "resolved": "packages/types", "link": true }, "node_modules/@tailwindcss/node": { @@ -7960,7 +7960,7 @@ "name": "@stock-bot/config", "version": "1.0.0", "dependencies": { - "@stock-bot/shared-types": "*", + "@stock-bot/types": "*", "dotenv": "^16.4.5" }, "devDependencies": { @@ -7968,8 +7968,8 @@ "typescript": "^5.4.5" } }, - "packages/shared-types": { - "name": "@stock-bot/shared-types", + "packages/types": { + "name": "@stock-bot/types", "version": "1.0.0", "devDependencies": { "typescript": "^5.4.5" diff --git a/scripts/build-libs.ps1 b/scripts/build-libs.ps1 index a80e019..756d336 100644 --- a/scripts/build-libs.ps1 +++ b/scripts/build-libs.ps1 @@ -4,7 +4,7 @@ Write-Host "Building and installing new libraries..." -ForegroundColor Cyan # Build order is important due to dependencies $libs = @( - "shared-types", + "types", "utils", "event-bus", "api-client" diff --git a/scripts/create-package-aliases.ps1 b/scripts/create-package-aliases.ps1 index 67867db..7b6059a 100644 --- a/scripts/create-package-aliases.ps1 +++ b/scripts/create-package-aliases.ps1 @@ -78,7 +78,7 @@ You don't need to change your imports yet, but this path will be removed in a fu # Create aliases for each library Write-ColorOutput "Yellow" "Creating package aliases for backward compatibility..." -Create-PackageAlias "shared-types" +Create-PackageAlias "types" # Create additional aliases as needed for other libraries diff --git a/tsconfig.json b/tsconfig.json index 6f7686d..0dd0f7f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -45,7 +45,7 @@ { "path": "./libs/config" }, { "path": "./libs/event-bus" }, { "path": "./libs/http-client" }, - { "path": "./libs/shared-types" }, + { "path": "./libs/types" }, { "path": "./libs/utils" }, ]