@timmeck/trading-brain 2.31.52 → 2.31.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/init/engine-factory.d.ts +21 -0
- package/dist/init/engine-factory.js +153 -0
- package/dist/init/engine-factory.js.map +1 -0
- package/dist/ipc/router.d.ts +3 -0
- package/dist/ipc/router.js +26 -0
- package/dist/ipc/router.js.map +1 -1
- package/dist/paper/__tests__/portfolio-optimizer.test.d.ts +1 -0
- package/dist/paper/__tests__/portfolio-optimizer.test.js +103 -0
- package/dist/paper/__tests__/portfolio-optimizer.test.js.map +1 -0
- package/dist/paper/portfolio-optimizer.d.ts +47 -0
- package/dist/paper/portfolio-optimizer.js +135 -0
- package/dist/paper/portfolio-optimizer.js.map +1 -0
- package/dist/trading-core.js +8 -110
- package/dist/trading-core.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
**Adaptive Trading Intelligence & Signal Learning System for Claude Code — 151 MCP Tools, 72+ Engines**
|
|
9
9
|
|
|
10
|
-
Trading Brain is an MCP server that gives Claude Code a persistent trading memory. It learns from every trade outcome — strengthening connections between signals, strategies, and results through a Hebbian synapse network ("signals that win together wire together"). Paper trading with live market data (CoinGecko, Yahoo Finance, CCXT WebSocket). Over time, it develops statistical confidence in signal combinations, adapts calibration parameters, and runs 72+ autonomous engines in a 51-step feedback cycle to discover patterns, reason about causality, evolve strategies genetically, and improve itself. Full intelligence suite: RAG, Knowledge Graph, feedback learning, tool tracking, user model, proactive suggestions. Multi-provider LLM (Anthropic + Ollama).
|
|
10
|
+
Trading Brain is an MCP server that gives Claude Code a persistent trading memory. It learns from every trade outcome — strengthening connections between signals, strategies, and results through a Hebbian synapse network ("signals that win together wire together"). Paper trading with live market data (CoinGecko, Yahoo Finance, CCXT WebSocket). Over time, it develops statistical confidence in signal combinations, adapts calibration parameters, and runs 72+ autonomous engines in a 51-step feedback cycle to discover patterns, reason about causality, evolve strategies genetically, and improve itself. Full intelligence suite: RAG, Knowledge Graph, feedback learning, tool tracking, user model, proactive suggestions. Multi-provider LLM (Anthropic + Ollama). PortfolioOptimizer with Kelly criterion position sizing and HHI diversification scoring. StrategyMutator for evolutionary strategy breeding (mutation, crossover, tournament selection). 500 tests. Workflow checkpointing, structured LLM output, observability tracing, agent training, dynamic tool scoping.
|
|
11
11
|
|
|
12
12
|
## Quick Start
|
|
13
13
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intelligence engines factory — extracted from TradingCore.start() (Sessions 55-76).
|
|
3
|
+
* Pure extraction, no logic changes.
|
|
4
|
+
*/
|
|
5
|
+
import type Database from 'better-sqlite3';
|
|
6
|
+
import type { Services } from '../ipc/router.js';
|
|
7
|
+
import type { ResearchOrchestrator, AutonomousResearchScheduler, ThoughtStream, LLMService, GoalEngine, ParameterRegistry, CrossBrainNotifier } from '@timmeck/brain-core';
|
|
8
|
+
import type { PaperEngine } from '../paper/paper-engine.js';
|
|
9
|
+
export interface IntelligenceDeps {
|
|
10
|
+
db: Database.Database;
|
|
11
|
+
services: Services;
|
|
12
|
+
orchestrator: ResearchOrchestrator;
|
|
13
|
+
researchScheduler: AutonomousResearchScheduler;
|
|
14
|
+
thoughtStream: ThoughtStream;
|
|
15
|
+
llmService: LLMService;
|
|
16
|
+
goalEngine: GoalEngine;
|
|
17
|
+
parameterRegistry: ParameterRegistry;
|
|
18
|
+
paperEngine: PaperEngine | null;
|
|
19
|
+
notifier: CrossBrainNotifier | null;
|
|
20
|
+
}
|
|
21
|
+
export declare function createIntelligenceEngines(deps: IntelligenceDeps): void;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { PortfolioOptimizer } from '../paper/portfolio-optimizer.js';
|
|
2
|
+
import { getLogger } from '../utils/logger.js';
|
|
3
|
+
import { RAGEngine, RAGIndexer, KnowledgeGraphEngine, FactExtractor, SemanticCompressor, FeedbackEngine, ToolTracker, ToolPatternAnalyzer, ProactiveEngine, UserModel, CodeHealthMonitor, TeachingProtocol, Curriculum, ConsensusEngine, ActiveLearner, RepoAbsorber, GuardrailEngine, CausalPlanner, ResearchRoadmap, runRoadmapMigration, CreativeEngine, runCreativeMigration, ActionBridgeEngine, runActionBridgeMigration, createTradeHandler, ContentForge, runContentForgeMigration, CodeForge, runCodeForgeMigration, StrategyForge, runStrategyForgeMigration, CrossBrainSignalRouter, runSignalRouterMigration, StrategyMutator, } from '@timmeck/brain-core';
|
|
4
|
+
export function createIntelligenceEngines(deps) {
|
|
5
|
+
const { db, services, orchestrator, researchScheduler, llmService, thoughtStream, goalEngine, parameterRegistry, notifier } = deps;
|
|
6
|
+
const logger = getLogger();
|
|
7
|
+
// ── Intelligence Upgrade (Sessions 55-65) ──
|
|
8
|
+
const ragEngine = new RAGEngine(db, { brainName: 'trading-brain' });
|
|
9
|
+
const ragIndexer = new RAGIndexer(db);
|
|
10
|
+
ragIndexer.setRAGEngine(ragEngine);
|
|
11
|
+
services.ragEngine = ragEngine;
|
|
12
|
+
services.ragIndexer = ragIndexer;
|
|
13
|
+
const knowledgeGraph = new KnowledgeGraphEngine(db, { brainName: 'trading-brain' });
|
|
14
|
+
const factExtractor = new FactExtractor(db, { brainName: 'trading-brain' });
|
|
15
|
+
services.knowledgeGraph = knowledgeGraph;
|
|
16
|
+
services.factExtractor = factExtractor;
|
|
17
|
+
const semanticCompressor = new SemanticCompressor(db, { brainName: 'trading-brain' });
|
|
18
|
+
semanticCompressor.setRAGEngine(ragEngine);
|
|
19
|
+
services.semanticCompressor = semanticCompressor;
|
|
20
|
+
const feedbackEngine = new FeedbackEngine(db, { brainName: 'trading-brain' });
|
|
21
|
+
services.feedbackEngine = feedbackEngine;
|
|
22
|
+
const toolTracker = new ToolTracker(db, { brainName: 'trading-brain' });
|
|
23
|
+
const toolPatternAnalyzer = new ToolPatternAnalyzer(db);
|
|
24
|
+
services.toolTracker = toolTracker;
|
|
25
|
+
services.toolPatternAnalyzer = toolPatternAnalyzer;
|
|
26
|
+
const proactiveEngine = new ProactiveEngine(db, { brainName: 'trading-brain' });
|
|
27
|
+
proactiveEngine.setThoughtStream(thoughtStream);
|
|
28
|
+
services.proactiveEngine = proactiveEngine;
|
|
29
|
+
const userModel = new UserModel(db, { brainName: 'trading-brain' });
|
|
30
|
+
services.userModel = userModel;
|
|
31
|
+
const codeHealthMonitor = new CodeHealthMonitor(db, { brainName: 'trading-brain' });
|
|
32
|
+
codeHealthMonitor.setThoughtStream(thoughtStream);
|
|
33
|
+
services.codeHealthMonitor = codeHealthMonitor;
|
|
34
|
+
const teachingProtocol = new TeachingProtocol(db, { brainName: 'trading-brain' });
|
|
35
|
+
services.teachingProtocol = teachingProtocol;
|
|
36
|
+
const curriculum = new Curriculum(db);
|
|
37
|
+
services.curriculum = curriculum;
|
|
38
|
+
const consensusEngine = new ConsensusEngine(db, { brainName: 'trading-brain' });
|
|
39
|
+
services.consensusEngine = consensusEngine;
|
|
40
|
+
const activeLearner = new ActiveLearner(db, { brainName: 'trading-brain' });
|
|
41
|
+
activeLearner.setThoughtStream(thoughtStream);
|
|
42
|
+
services.activeLearner = activeLearner;
|
|
43
|
+
const repoAbsorber = new RepoAbsorber(db);
|
|
44
|
+
repoAbsorber.setThoughtStream(thoughtStream);
|
|
45
|
+
repoAbsorber.setRAGEngine(ragEngine);
|
|
46
|
+
repoAbsorber.setKnowledgeGraph(knowledgeGraph);
|
|
47
|
+
services.repoAbsorber = repoAbsorber;
|
|
48
|
+
// GuardrailEngine — self-protection: parameter bounds, circuit breaker, health checks
|
|
49
|
+
const guardrailEngine = new GuardrailEngine(db, { brainName: 'trading-brain' });
|
|
50
|
+
guardrailEngine.setParameterRegistry(parameterRegistry);
|
|
51
|
+
if (goalEngine)
|
|
52
|
+
guardrailEngine.setGoalEngine(goalEngine);
|
|
53
|
+
guardrailEngine.setThoughtStream(thoughtStream);
|
|
54
|
+
services.guardrailEngine = guardrailEngine;
|
|
55
|
+
// CausalPlanner — root-cause diagnosis + intervention planning
|
|
56
|
+
const causalPlanner = new CausalPlanner(researchScheduler.causalGraph);
|
|
57
|
+
causalPlanner.setGoalEngine(goalEngine);
|
|
58
|
+
services.causalPlanner = causalPlanner;
|
|
59
|
+
// ResearchRoadmap — goal dependencies + multi-step research plans
|
|
60
|
+
runRoadmapMigration(db);
|
|
61
|
+
const researchRoadmap = new ResearchRoadmap(db, goalEngine);
|
|
62
|
+
researchRoadmap.setThoughtStream(thoughtStream);
|
|
63
|
+
services.researchRoadmap = researchRoadmap;
|
|
64
|
+
// CreativeEngine — cross-domain idea generation
|
|
65
|
+
runCreativeMigration(db);
|
|
66
|
+
const creativeEngine = new CreativeEngine(db, { brainName: 'trading-brain' });
|
|
67
|
+
creativeEngine.setKnowledgeDistiller(orchestrator.knowledgeDistiller);
|
|
68
|
+
creativeEngine.setHypothesisEngine(researchScheduler.hypothesisEngine);
|
|
69
|
+
if (llmService)
|
|
70
|
+
creativeEngine.setLLMService(llmService);
|
|
71
|
+
creativeEngine.setThoughtStream(thoughtStream);
|
|
72
|
+
services.creativeEngine = creativeEngine;
|
|
73
|
+
// ActionBridge — risk-assessed auto-execution
|
|
74
|
+
runActionBridgeMigration(db);
|
|
75
|
+
const actionBridge = new ActionBridgeEngine(db, { brainName: 'trading-brain' });
|
|
76
|
+
services.actionBridge = actionBridge;
|
|
77
|
+
// Register execute_trade handler → StrategyForge proposals trigger PaperEngine
|
|
78
|
+
const paperEngineRef = deps.paperEngine;
|
|
79
|
+
const paperServiceRef = services.paper;
|
|
80
|
+
if (paperEngineRef) {
|
|
81
|
+
actionBridge.registerHandler('execute_trade', createTradeHandler({
|
|
82
|
+
runCycle: () => paperEngineRef.runCycle(),
|
|
83
|
+
getPortfolio: paperServiceRef ? () => paperServiceRef.getPortfolio() : undefined,
|
|
84
|
+
}));
|
|
85
|
+
logger.info('Registered execute_trade handler → PaperEngine');
|
|
86
|
+
}
|
|
87
|
+
// ContentForge — autonomous content pipeline
|
|
88
|
+
runContentForgeMigration(db);
|
|
89
|
+
const contentForge = new ContentForge(db, { brainName: 'trading-brain' });
|
|
90
|
+
if (llmService)
|
|
91
|
+
contentForge.setLLMService(llmService);
|
|
92
|
+
contentForge.setActionBridge(actionBridge);
|
|
93
|
+
services.contentForge = contentForge;
|
|
94
|
+
// CodeForge — pattern extraction & code generation
|
|
95
|
+
runCodeForgeMigration(db);
|
|
96
|
+
const codeForge = new CodeForge(db, { brainName: 'trading-brain' });
|
|
97
|
+
codeForge.setActionBridge(actionBridge);
|
|
98
|
+
if (guardrailEngine)
|
|
99
|
+
codeForge.setGuardrailEngine(guardrailEngine);
|
|
100
|
+
services.codeForge = codeForge;
|
|
101
|
+
// StrategyForge — autonomous strategy creation & execution
|
|
102
|
+
runStrategyForgeMigration(db);
|
|
103
|
+
const strategyForge = new StrategyForge(db, { brainName: 'trading-brain' });
|
|
104
|
+
strategyForge.setActionBridge(actionBridge);
|
|
105
|
+
strategyForge.setKnowledgeDistiller(orchestrator.knowledgeDistiller);
|
|
106
|
+
services.strategyForge = strategyForge;
|
|
107
|
+
// Strategy Bootstrap Check — flag if positions exist but no strategies
|
|
108
|
+
try {
|
|
109
|
+
const activeStrategies = strategyForge.getStatus()?.active ?? 0;
|
|
110
|
+
const openPositions = services.paper?.getStatus()?.openPositions ?? 0;
|
|
111
|
+
if (openPositions > 0 && activeStrategies === 0) {
|
|
112
|
+
logger.warn('[strategy-bootstrap] Paper positions exist but 0 active strategies — bootstrap needed');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch { /* best effort */ }
|
|
116
|
+
// StrategyMutator — evolutionary strategy operations
|
|
117
|
+
const strategyMutator = new StrategyMutator(db);
|
|
118
|
+
services.strategyMutator = strategyMutator;
|
|
119
|
+
// PortfolioOptimizer — dynamic position sizing + health checks
|
|
120
|
+
const portfolioOptimizer = new PortfolioOptimizer(db);
|
|
121
|
+
services.portfolioOptimizer = portfolioOptimizer;
|
|
122
|
+
// Wire intelligence engines into orchestrator
|
|
123
|
+
orchestrator.setFactExtractor(factExtractor);
|
|
124
|
+
orchestrator.setKnowledgeGraph(knowledgeGraph);
|
|
125
|
+
orchestrator.setSemanticCompressor(semanticCompressor);
|
|
126
|
+
orchestrator.setProactiveEngine(proactiveEngine);
|
|
127
|
+
orchestrator.setActiveLearner(activeLearner);
|
|
128
|
+
orchestrator.setRAGIndexer(ragIndexer);
|
|
129
|
+
orchestrator.setTeachingProtocol(teachingProtocol);
|
|
130
|
+
orchestrator.setCodeHealthMonitor(codeHealthMonitor);
|
|
131
|
+
orchestrator.setRepoAbsorber(repoAbsorber);
|
|
132
|
+
orchestrator.setGuardrailEngine(guardrailEngine);
|
|
133
|
+
orchestrator.setCausalPlanner(causalPlanner);
|
|
134
|
+
orchestrator.setResearchRoadmap(researchRoadmap);
|
|
135
|
+
orchestrator.setCreativeEngine(creativeEngine);
|
|
136
|
+
orchestrator.setActionBridge(actionBridge);
|
|
137
|
+
orchestrator.setContentForge(contentForge);
|
|
138
|
+
orchestrator.setCodeForge(codeForge);
|
|
139
|
+
orchestrator.setStrategyForge(strategyForge);
|
|
140
|
+
// CrossBrainSignalRouter — bidirectional signal routing
|
|
141
|
+
runSignalRouterMigration(db);
|
|
142
|
+
const signalRouter = new CrossBrainSignalRouter(db, 'trading-brain');
|
|
143
|
+
if (notifier)
|
|
144
|
+
signalRouter.setNotifier(notifier);
|
|
145
|
+
// Handle incoming engagement signals → log for correlation
|
|
146
|
+
signalRouter.onSignal('engagement_signal', (signal) => {
|
|
147
|
+
const topic = signal.payload.topic ?? 'unknown';
|
|
148
|
+
logger.info(`[signal-router] Received engagement signal: ${topic} from ${signal.sourceBrain}`);
|
|
149
|
+
});
|
|
150
|
+
services.signalRouter = signalRouter;
|
|
151
|
+
logger.info('Intelligence upgrade active (RAG, KG, Feedback, ToolTracker, UserModel, Proactive, CodeHealth, Teaching, Consensus, ActiveLearning, RepoAbsorber, Guardrails, CausalPlanner, Roadmap, Creative, ActionBridge, ContentForge, CodeForge, StrategyForge, SignalRouter)');
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=engine-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-factory.js","sourceRoot":"","sources":["../../src/init/engine-factory.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAAE,aAAa,EAC1D,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EACpE,eAAe,EAAE,SAAS,EAAE,iBAAiB,EAC7C,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAC1E,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,mBAAmB,EACpE,cAAc,EAAE,oBAAoB,EACpC,kBAAkB,EAAE,wBAAwB,EAAE,kBAAkB,EAChE,YAAY,EAAE,wBAAwB,EACtC,SAAS,EAAE,qBAAqB,EAChC,aAAa,EAAE,yBAAyB,EACxC,sBAAsB,EAAE,wBAAwB,EAChD,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAoB7B,MAAM,UAAU,yBAAyB,CAAC,IAAsB;IAC9D,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IACnI,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,8CAA8C;IAC9C,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;IACpE,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACtC,UAAU,CAAC,YAAY,CAAC,S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,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IACrD,YAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAC3C,YAAY,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACjD,YAAY,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC7C,YAAY,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACjD,YAAY,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAC/C,YAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAC3C,YAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAC3C,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACrC,YAAY,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAE7C,wDAAwD;IACxD,wBAAwB,CAAC,EAAE,CAAC,CAAC;IAC7B,MAAM,YAAY,GAAG,IAAI,sBAAsB,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;IACrE,IAAI,QAAQ;QAAE,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACjD,2DAA2D;IAC3D,YAAY,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC,MAAM,EAAE,EAAE;QACpD,MAAM,KAAK,GAAI,MAAM,CAAC,OAAO,CAAC,KAAgB,IAAI,SAAS,CAAC;QAC5D,MAAM,CAAC,IAAI,CAAC,+CAA+C,KAAK,SAAS,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IACjG,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,GAAG,YAAY,CAAC;IAErC,MAAM,CAAC,IAAI,CAAC,qQAAqQ,CAAC,CAAC;AACrR,CAAC"}
|
package/dist/ipc/router.d.ts
CHANGED
|
@@ -125,6 +125,9 @@ export interface Services {
|
|
|
125
125
|
contentForge?: import('@timmeck/brain-core').ContentForge;
|
|
126
126
|
codeForge?: import('@timmeck/brain-core').CodeForge;
|
|
127
127
|
strategyForge?: import('@timmeck/brain-core').StrategyForge;
|
|
128
|
+
signalRouter?: import('@timmeck/brain-core').CrossBrainSignalRouter;
|
|
129
|
+
strategyMutator?: import('@timmeck/brain-core').StrategyMutator;
|
|
130
|
+
portfolioOptimizer?: import('../paper/portfolio-optimizer.js').PortfolioOptimizer;
|
|
128
131
|
}
|
|
129
132
|
export declare class IpcRouter {
|
|
130
133
|
private services;
|
package/dist/ipc/router.js
CHANGED
|
@@ -941,6 +941,32 @@ export class IpcRouter {
|
|
|
941
941
|
throw new Error('StrategyForge not available'); return s.strategyForge.retire(p(params).id, p(params).reason); }],
|
|
942
942
|
['strategy.status', () => { if (!s.strategyForge)
|
|
943
943
|
throw new Error('StrategyForge not available'); return s.strategyForge.getStatus(); }],
|
|
944
|
+
['strategy.bridge.status', () => {
|
|
945
|
+
if (!s.strategyForge || !s.actionBridge)
|
|
946
|
+
throw new Error('StrategyForge or ActionBridge not available');
|
|
947
|
+
return {
|
|
948
|
+
strategyForge: s.strategyForge.getStatus(),
|
|
949
|
+
actionBridge: s.actionBridge.getStatus(),
|
|
950
|
+
pipeline: 'StrategyForge → ActionBridge → PaperEngine',
|
|
951
|
+
handlerRegistered: true,
|
|
952
|
+
};
|
|
953
|
+
}],
|
|
954
|
+
// ─── Cross-Brain Signals ────────────────────────────────────
|
|
955
|
+
['signal.cross.emit', async (params) => { if (!s.signalRouter)
|
|
956
|
+
throw new Error('SignalRouter not available'); return { signalId: await s.signalRouter.emit(p(params)) }; }],
|
|
957
|
+
['signal.cross.history', (params) => { if (!s.signalRouter)
|
|
958
|
+
throw new Error('SignalRouter not available'); return s.signalRouter.getHistory(p(params).limit); }],
|
|
959
|
+
['signal.cross.status', () => { if (!s.signalRouter)
|
|
960
|
+
throw new Error('SignalRouter not available'); return s.signalRouter.getStatus(); }],
|
|
961
|
+
// ─── Strategy Mutation & Portfolio Optimization ────────────────
|
|
962
|
+
['strategy.mutate', () => { if (!s.strategyMutator || !s.strategyForge)
|
|
963
|
+
throw new Error('Not available'); const strategies = s.strategyForge.getActive(); return s.strategyMutator.evolveGeneration(strategies); }],
|
|
964
|
+
['strategy.generation', () => { if (!s.strategyMutator)
|
|
965
|
+
throw new Error('Not available'); return { generation: s.strategyMutator.getGeneration() }; }],
|
|
966
|
+
['portfolio.health', () => { if (!s.portfolioOptimizer || !s.paper)
|
|
967
|
+
throw new Error('Not available'); const portfolio = s.paper.getPortfolio(); return s.portfolioOptimizer.checkHealth(portfolio.equity, portfolio.positions.map((p) => ({ symbol: p.symbol, usdtAmount: p.usdtAmount }))); }],
|
|
968
|
+
['portfolio.history', (params) => { if (!s.portfolioOptimizer)
|
|
969
|
+
throw new Error('Not available'); return s.portfolioOptimizer.getHistory(p(params).limit); }],
|
|
944
970
|
['status', () => ({
|
|
945
971
|
name: 'trading-brain',
|
|
946
972
|
version: getCurrentVersion(),
|