What Risk Assessments Does the Risk Manager Agent Perform in AutoHedge?
The Risk Manager agent performs four core risk assessments—recommended position size, maximum drawdown risk, market risk exposure, and overall risk score—to evaluate trade safety and capital allocation before execution.
The AutoHedge repository implements a dedicated Risk Manager agent that functions as a critical safeguard in automated trading workflows. When evaluating potential trades, this agent analyzes quantitative market data and position specifics to determine appropriate capital deployment and exposure limits. Understanding exactly what risk assessments the Risk Manager agent performs enables traders to interpret output metrics correctly and customize risk parameters within the autohedge/prompts.py configuration.
The Four Core Risk Assessments
The agent's behavior is governed by the RISK_PROMPT constant defined in autohedge/prompts.py (lines 84-118). This system prompt mandates four specific deliverables that the agent must generate when processing a trade opportunity.
Recommended Position Size
This assessment determines the optimal capital allocation based on the trade’s risk-to-reward profile. The agent calculates what percentage of the portfolio should be committed to the position, balancing potential returns against downside protection. According to autohedge/prompts.py (lines 85-90), the prompt explicitly instructs the agent to output a specific sizing recommendation derived from the quantitative inputs.
Maximum Drawdown Risk
The agent estimates the worst-case loss that could be incurred before the trade recovers, helping traders prepare for adverse price movements. This metric quantifies the potential peak-to-trough decline expressed as a percentage. The prompt definition in autohedge/prompts.py (lines 91-93) directs the agent to calculate and report this maximum drawdown figure.
Market Risk Exposure
This evaluation analyzes market-wide factors that could affect trade performance, including volatility regimes, liquidity conditions, and overall sentiment indicators. As specified in autohedge/prompts.py (lines 94-96), the agent must assess external systemic risks beyond the specific asset’s technical price action.
Overall Risk Score
The agent synthesizes all analysis into a single consolidated rating, typically normalized on a 0-1 scale, facilitating rapid decision-making. This composite metric appears in the prompt at autohedge/prompts.py (lines 111-116), providing an at-a-glance risk classification that aggregates position sizing, drawdown potential, and market factors.
Additional Risk Evaluation Criteria
Beyond the four mandatory outputs, the RISK_PROMPT instructs the agent to evaluate supplementary risk factors during analysis:
- Position-size evaluation – Aligning the proposed trade size with the trader’s specific risk tolerance and account constraints.
- Potential drawdown calculation – Forecasting specific loss scenarios and recovery timeframes beyond the maximum threshold.
- Market-risk factor assessment – Deep-diving into volatility skews, liquidity depth, and sentiment divergence.
- Correlation-risk monitoring – Detecting dangerous statistical links between the target asset and existing portfolio positions that could amplify portfolio-wide losses.
How the Risk Manager Agent Processes Data
The agent initialization occurs in autohedge/workers.py (lines 35-44), where the system constructs the risk_agent instance. This configuration appends the static RISK_PROMPT with runtime context, specifically injecting current date-time information (lines 36-39) to ensure time-relevant analysis before transmitting requests to the underlying language model.
To generate valid assessments, the agent requires a structured input containing the trade thesis (direction and rationale) and a quantitative analysis object. This data package must include technical scores, volume scores, trend strength metrics, volatility measurements, probability scores, and key price levels (support, resistance, and pivot points).
Implementing the Risk Manager Agent
To invoke the Risk Manager agent in your AutoHedge implementation, import the pre-configured agent from the workers module and pass a formatted string containing the trade thesis and quantitative data:
from autohedge.workers import risk_agent
# Example input supplied by the Quant-Analysis agent
sample_input = """
Stock: AAPL
Thesis: Long position based on strong earnings and bullish technical indicators.
Quant Analysis: {
"technical_score": 0.78,
"volume_score": 0.65,
"trend_strength": 0.82,
"volatility": 0.22,
"probability_score": 0.71,
"key_levels": {"support": 150.0, "resistance": 165.0, "pivot": 157.5}
}
"""
# Execute the risk assessment
risk_assessment = risk_agent.run(sample_input)
print(risk_assessment)
The output returns a structured text block containing the four core assessments:
Recommended position size: 3% of portfolio
Maximum drawdown risk: 2.5%
Market risk exposure: Moderate (high volatility)
Overall risk score: 0.68 (on a 0-1 scale)
Summary
- The Risk Manager agent in AutoHedge evaluates trades through four mandatory assessments defined in
autohedge/prompts.py: recommended position size, maximum drawdown risk, market risk exposure, and overall risk score. - These assessments are executed through the
risk_agentinstance configured inautohedge/workers.py(lines 35-44), which combines the base prompt with real-time context. - The agent requires quantitative technical analysis—including volatility metrics, probability scores, and key price levels—alongside the trade thesis to generate accurate risk metrics.
- Supplementary evaluation criteria include correlation monitoring, position-size alignment with risk tolerance, and specific market-factor analysis.
- All outputs follow a standardized format enabling automated parsing and integration with downstream position-sizing algorithms.
Frequently Asked Questions
What inputs does the Risk Manager agent require to perform risk assessments?
The Risk Manager agent requires a structured input string containing the trade thesis (bullish/bearish direction and fundamental rationale) and a Quant Analysis JSON object. This object must include technical scores, volume scores, trend strength values, volatility measurements, probability scores, and key price levels (support, resistance, and pivot). The agent processes these inputs against the RISK_PROMPT defined in autohedge/prompts.py to generate the four core risk assessments.
Where is the Risk Manager agent configured in the AutoHedge codebase?
The agent is instantiated in autohedge/workers.py (lines 35-44) as the risk_agent variable. This configuration appends the RISK_PROMPT from autohedge/prompts.py with current datetime context (lines 36-39) and sets model parameters. The complete prompt definition resides in autohedge/prompts.py (lines 84-118).
How does the Risk Manager agent determine the recommended position size?
According to autohedge/prompts.py (lines 85-90), the agent calculates position size by analyzing the trade’s risk-to-reward profile using the provided quantitative inputs. It weighs volatility, probability scores, and technical support/resistance levels to recommend a specific portfolio percentage that aligns with the estimated risk exposure and potential drawdown.
What distinguishes maximum drawdown risk from the overall risk score?
Maximum drawdown risk, defined in autohedge/prompts.py (lines 91-93), represents a specific metric estimating the worst-case percentage loss before trade recovery. The overall risk score (lines 111-116) is a composite normalized rating (typically 0-1) that synthesizes drawdown potential, market exposure, and position sizing into a single metric for rapid trade comparison and filtering.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →