Strategy Reference
Strategies are the decision-making engine behind every YorN agent. This reference covers the full strategy lifecycle, signal generation, position sizing, risk management, and how the AI generates custom strategies from your plain English descriptions.
Strategy Lifecycle
Every strategy follows a four-phase lifecycle on each evaluation cycle. The agent engine calls these hooks in order, and any phase can halt execution for the current cycle.
evaluate()
Analyze market data and generate a Signal with action and confidence.
position_size()
Calculate the number of contracts based on signal confidence and balance.
risk_check()
Validate the proposed trade against risk limits and portfolio constraints.
on_fill()
Callback after trade execution. Update internal state and log results.
Lifecycle Hooks
The following hooks are available for override in your Strategy subclass:
Signal Generation
The evaluate method is the core of every strategy. It receives market data and returns a Signal object (or None to skip). Signals encode the trading decision with enough metadata for the executor and risk manager to process.
Signal Fields
Confidence Thresholds
The agent engine applies a minimum confidence threshold before passing signals to the executor. By default, the threshold is 0.6 but can be configured per agent:
Position Sizing
The position_size method determines how many contracts to buy or sell for a given signal. Position sizing is critical for risk management and should scale with confidence and available balance.
Built-in Sizing Methods
Risk Rules
The risk_check method is the final gate before trade execution. It validates the proposed trade against portfolio-level constraints. If it returns False, the trade is rejected and logged.
Daily Loss Limit
Maximum total loss per day across all trades. Agent pauses when breached. Config: daily_loss_limit
Max Position Size
Maximum number of contracts in a single trade. Hard cap regardless of sizing method. Config: max_position
Trade Cooldown
Minimum time between consecutive trades to prevent overtrading. Config: cooldown (seconds)
Max Open Positions
Limits concurrent open positions to control exposure. Config: max_open_positions
AI-Generated Strategies
YorN generates custom strategies from your plain English descriptions. Describe what you want your agent to do, and the AI produces a complete strategy with signal generation logic, position sizing, and risk rules tailored to your market category.
| Category | Example Description | What the AI Generates |
|---|---|---|
| Sports | "Trade NBA games where the home team has won 3+ in a row and the spread is at least 5 points" | Signal logic with home court advantage filters, streak detection, and spread thresholds |
| Economics | "Buy FOMC hold contracts when fed funds futures imply >80% probability of no change" | Signal logic with futures data integration, probability thresholds, and entry timing windows |
| Weather | "Trade temperature extreme markets when at least 3 ensemble models agree on the forecast" | Signal logic with multi-model consensus checks, lead time filters, and confidence scoring |
| Politics | "Trade election markets when polling momentum shifts by more than 2 points in a week" | Signal logic with poll aggregation, momentum detection, and trend strength filters |
The AI generates a complete strategy based on your description. Every parameter can be tuned after generation, and you can refine the strategy by providing additional instructions in plain English.
Creating an AI-Generated Strategy
Custom Strategies
Pro and Enterprise tier users can write fully custom strategies. Custom strategies give you complete control over the evaluation logic while still benefiting from YorN's execution, risk management, and monitoring infrastructure.
Custom strategies still undergo AST safety validation. All the same restrictions apply: no imports, no I/O, no network calls, no system access.
Full Custom Strategy Example
Next Steps
- Coordination Modes -- Run multiple strategies as a coordinated team
- Agent Creation -- Learn the full agent creation workflow
- API Reference -- Programmatic strategy management endpoints