feat(quant): Human-in-the-Loop Expert Trader Advisory & Dynamic Learning Engine

This commit is contained in:
2026-10-23 06:44:22 +06:00
parent 0fb1168f58
commit 49c0d7457b
10 changed files with 1130 additions and 20 deletions
+58
View File
@@ -375,3 +375,61 @@ async def n8n_inbound_webhook(req: N8nTriggerRequest):
res = connector.close_all_positions(settings.TARGET_SYMBOL)
return {"status": "success", "action": "kill_all", "result": res}
return {"status": "received", "action": req.action}
# Human-in-the-Loop Expert Advisor Framework Endpoints
class SubmitStrategyRequest(BaseModel):
advice: str
author_id: Optional[str] = "7107005438"
author_name: Optional[str] = "Pro Trader Advisor"
class RegisterAdvisorRequest(BaseModel):
user_id: str
user_name: str
token: str
@app.get("/api/v1/hermes/advisor/invite")
def get_advisor_invite():
"""Generates the Telegram invite deep-link for Redwan's expert friend."""
from app.engine.expert_manager import expert_manager
return expert_manager.generate_invite_link()
@app.get("/api/v1/hermes/advisor/strategies")
def get_advisor_strategies():
"""Returns all active quantitative strategies learned from the expert friend."""
from app.engine.expert_manager import expert_manager
strategies = expert_manager.list_strategies()
return {
"strategies": strategies,
"total": len(strategies)
}
@app.post("/api/v1/hermes/advisor/strategy")
async def submit_advisor_strategy(req: SubmitStrategyRequest):
"""Parses natural language trading advice from the expert friend and ingests as active rule."""
from app.engine.expert_manager import expert_manager
res = await expert_manager.parse_and_learn_strategy(
raw_advice=req.advice,
author_id=req.author_id or "7107005438",
author_name=req.author_name or "Expert Advisor"
)
return res
@app.get("/api/v1/hermes/advisor/advisors")
def get_advisors_list():
"""Lists authorized human advisors and their contribution metrics."""
from app.engine.expert_manager import expert_manager
advisors = expert_manager.list_advisors()
return {
"advisors": advisors,
"total": len(advisors)
}
@app.post("/api/v1/hermes/advisor/register")
def register_new_advisor(req: RegisterAdvisorRequest):
"""Validates friend's invite token and authorizes them as an Expert Advisor."""
from app.engine.expert_manager import expert_manager
return expert_manager.register_advisor(
user_id=req.user_id,
user_name=req.user_name,
token=req.token
)