build-trading-strategies

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Build Trading Strategies

构建交易策略

Quick Start

快速入门

This skill generates complete, production-ready strategy code using AI. This is the most expensive tool in Robonet ($1-$4.50 per generation).
Load the tools first:
Use MCPSearch to select: mcp__workbench__create_strategy
Use MCPSearch to select: mcp__workbench__create_prediction_market_strategy
Basic usage:
create_strategy(
    strategy_name="RSIMeanReversion_M",
    description="Buy when RSI(14) < 30 and price at lower Bollinger Band (20,2).
                 Sell when RSI > 70 or price at middle Bollinger Band.
                 Stop loss at 2% below entry. Position size 90% of available margin."
)
Returns complete Python strategy code ready for backtesting.
When to use this skill:
  • You have a clear strategy concept and want working code
  • You've explored data and know what indicators/symbols to use
  • You're ready to commit to expensive development ($1-$4.50)
When NOT to use this skill:
  • You're still exploring ideas → Use
    design-trading-strategies
    first ($0.05-$1.00)
  • You have existing code to improve → Use
    improve-trading-strategies
    ($0.50-$3.00)
  • You haven't checked data availability → Use
    browse-robonet-data
    first (free-$0.001)
本技能借助AI生成完整的、可投入生产的策略代码。这是Robonet中成本最高的工具(每次生成费用1-4.50美元)。
先加载工具:
Use MCPSearch to select: mcp__workbench__create_strategy
Use MCPSearch to select: mcp__workbench__create_prediction_market_strategy
基础用法:
create_strategy(
    strategy_name="RSIMeanReversion_M",
    description="Buy when RSI(14) < 30 and price at lower Bollinger Band (20,2).
                 Sell when RSI > 70 or price at middle Bollinger Band.
                 Stop loss at 2% below entry. Position size 90% of available margin."
)
返回结果为可直接用于回测的完整Python策略代码。
何时使用本技能:
  • 你已有清晰的策略概念,需要可运行的代码
  • 你已完成数据探索,明确要使用的指标/交易对
  • 你已准备好承担较高的开发成本(1-4.50美元)
何时不应使用本技能:
  • 你仍在探索策略思路 → 先使用
    design-trading-strategies
    (费用0.05-1.00美元)
  • 你已有现有代码需要优化 → 使用
    improve-trading-strategies
    (费用0.50-3.00美元)
  • 你尚未确认数据可用性 → 先使用
    browse-robonet-data
    (免费-0.001美元)

Available Tools (2)

可用工具(2个)

create_strategy

create_strategy

Purpose: Generate complete crypto trading strategy code with AI
Parameters:
  • strategy_name
    (required, string): Name following pattern
    {Name}_{RiskLevel}[_suffix]
    • Risk levels: H (high), M (medium), L (low)
    • Examples: "RSIMeanReversion_M", "MomentumBreakout_H_v2"
  • description
    (required, string): Detailed requirements including:
    • Entry conditions (specific indicator values and thresholds)
    • Exit conditions (stop loss, take profit, trailing stops)
    • Position sizing (percentage of margin to use)
    • Risk management (max loss per trade)
    • Indicators to use (exact names from browse-robonet-data)
    • Timeframe context (5m scalping vs 1h swing trading)
Returns: Complete Python strategy code with:
  • should_long()
    - Check if conditions met for long entry
  • should_short()
    - Check if conditions met for short entry
  • go_long()
    - Execute long entry with position sizing
  • go_short()
    - Execute short entry with position sizing
  • Optional methods:
    on_open_position()
    ,
    update_position()
    ,
    should_cancel_entry()
Pricing: Real LLM cost + margin (max $4.50)
  • Typical cost: $1.00-$3.00 depending on complexity
  • Most expensive tool in Robonet
Execution Time: ~30-60 seconds
Use when:
  • Building new crypto perpetual trading strategy
  • You have clear, detailed requirements
  • You've verified indicators/symbols available (browse-robonet-data)
  • Ready to commit to expensive operation
用途: 借助AI生成完整的加密货币交易策略代码
参数:
  • strategy_name
    (必填,字符串): 命名需遵循
    {Name}_{RiskLevel}[_suffix]
    格式
    • 风险等级: H(高)、M(中)、L(低)
    • 示例: "RSIMeanReversion_M", "MomentumBreakout_H_optimized"
  • description
    (必填,字符串): 详细需求需包含:
    • 入场条件(具体指标数值和阈值)
    • 出场条件(止损、止盈、追踪止损)
    • 仓位管理(可用保证金的使用比例)
    • 风险管理(每笔交易的最大亏损)
    • 要使用的指标(需与browse-robonet-data中的名称完全一致)
    • 时间框架背景(5分钟 scalp 交易 vs 1小时波段交易)
返回结果: 完整的Python策略代码,包含:
  • should_long()
    - 检查是否满足多单入场条件
  • should_short()
    - 检查是否满足空单入场条件
  • go_long()
    - 执行多单入场并处理仓位大小
  • go_short()
    - 执行空单入场并处理仓位大小
  • 可选方法:
    on_open_position()
    ,
    update_position()
    ,
    should_cancel_entry()
定价: 实际LLM成本+溢价(最高4.50美元)
  • 典型成本: 1.00-3.00美元,取决于策略复杂度
  • Robonet中成本最高的工具
执行时间: ~30-60秒
适用场景:
  • 构建新的加密货币永续合约交易策略
  • 你有清晰、详细的需求
  • 你已验证指标/交易对可用(通过browse-robonet-data)
  • 已准备好承担较高的操作成本

create_prediction_market_strategy

create_prediction_market_strategy

Purpose: Generate Polymarket strategy code with YES/NO token trading logic
Parameters:
  • strategy_name
    (required, string): Name following same pattern as create_strategy
  • description
    (required, string): Detailed requirements for YES/NO token logic:
    • Conditions for buying YES tokens (probability thresholds)
    • Conditions for buying NO tokens
    • Exit criteria (profit targets, time-based exits)
    • Position sizing (percentage per market)
    • Market selection criteria (categories, liquidity requirements)
Returns: Complete Python strategy code with:
  • should_buy_yes()
    - Check if conditions met for YES token entry
  • should_buy_no()
    - Check if conditions met for NO token entry
  • go_yes()
    - Execute YES token purchase with sizing
  • go_no()
    - Execute NO token purchase with sizing
  • Optional methods:
    should_sell_yes()
    ,
    should_sell_no()
    ,
    on_market_resolution()
Pricing: Real LLM cost + margin (max $4.50)
  • Typical cost: $1.00-$3.00
Execution Time: ~30-60 seconds
Use when:
  • Building Polymarket prediction market strategies
  • Trading on real-world events (politics, economics, sports)
  • Want YES/NO token exposure based on probability analysis
用途: 生成带有YES/NO代币交易逻辑的Polymarket策略代码
参数:
  • strategy_name
    (必填,字符串): 命名规则与create_strategy一致
  • description
    (必填,字符串): YES/NO代币逻辑的详细需求:
    • 买入YES代币的条件(概率阈值)
    • 买入NO代币的条件
    • 出场标准(盈利目标、时间触发出场)
    • 仓位管理(每个市场的资金比例)
    • 市场选择标准(类别、流动性要求)
返回结果: 完整的Python策略代码,包含:
  • should_buy_yes()
    - 检查是否满足YES代币入场条件
  • should_buy_no()
    - 检查是否满足NO代币入场条件
  • go_yes()
    - 执行YES代币买入并处理仓位大小
  • go_no()
    - 执行NO代币买入并处理仓位大小
  • 可选方法:
    should_sell_yes()
    ,
    should_sell_no()
    ,
    on_market_resolution()
定价: 实际LLM成本+溢价(最高4.50美元)
  • 典型成本: 1.00-3.00美元
执行时间: ~30-60秒
适用场景:
  • 构建Polymarket预测市场策略
  • 基于现实事件(政治、经济、体育)进行交易
  • 希望通过概率分析获取YES/NO代币敞口

Core Concepts

核心概念

Jesse Framework Structure

Jesse框架结构

All crypto strategies must implement these required methods:
python
class MyStrategy(Strategy):
    def should_long(self) -> bool:
        """Check if all conditions are met for long entry"""
        # Return True to signal long entry opportunity
        # Called every candle

    def should_short(self) -> bool:
        """Check if all conditions are met for short entry"""
        # Return True to signal short entry opportunity
        # Called every candle

    def go_long(self):
        """Execute long entry with position sizing"""
        # Calculate position size (qty)
        # Place buy order
        # Set stop loss and take profit in on_open_position()

    def go_short(self):
        """Execute short entry with position sizing"""
        # Calculate position size (qty)
        # Place sell order
        # Set stop loss and take profit in on_open_position()
Optional but recommended methods:
python
    def on_open_position(self, order):
        """Set stop loss and take profit after entry"""
        # Called when position opens
        # Set self.stop_loss and self.take_profit

    def update_position(self):
        """Update position (trailing stops, etc.)"""
        # Called every candle while in position
        # Modify stop loss for trailing stops

    def should_cancel_entry(self) -> bool:
        """Cancel unfilled entry orders"""
        # Return True to cancel pending entry order
所有加密货币策略必须实现以下必填方法:
python
class MyStrategy(Strategy):
    def should_long(self) -> bool:
        """Check if all conditions are met for long entry"""
        # Return True to signal long entry opportunity
        # Called every candle

    def should_short(self) -> bool:
        """Check if all conditions are met for short entry"""
        # Return True to signal short entry opportunity
        # Called every candle

    def go_long(self):
        """Execute long entry with position sizing"""
        # Calculate position size (qty)
        # Place buy order
        # Set stop loss and take profit in on_open_position()

    def go_short(self):
        """Execute short entry with position sizing"""
        # Calculate position size (qty)
        # Place sell order
        # Set stop loss and take profit in on_open_position()
可选但推荐实现的方法:
python
    def on_open_position(self, order):
        """Set stop loss and take profit after entry"""
        # Called when position opens
        # Set self.stop_loss and self.take_profit

    def update_position(self):
        """Update position (trailing stops, etc.)"""
        # Called every candle while in position
        # Modify stop loss for trailing stops

    def should_cancel_entry(self) -> bool:
        """Cancel unfilled entry orders"""
        # Return True to cancel pending entry order

Strategy Naming Convention

策略命名规范

Follow this pattern:
{Name}_{RiskLevel}[_suffix]
Risk Levels:
  • H (High): Aggressive strategies, high leverage, tight stops, >20% drawdown acceptable
  • M (Medium): Balanced strategies, moderate leverage, standard stops, 10-20% drawdown
  • L (Low): Conservative strategies, low leverage, wide stops, <10% drawdown
Examples:
  • RSIMeanReversion_M
    - Base strategy, medium risk
  • MomentumBreakout_H_optimized
    - After optimization, high risk
  • TrendFollower_L_allora
    - With Allora ML enhancement, low risk
  • BollingerBands_M_v2
    - Version 2 of strategy
Why naming matters:
  • Helps organize strategies by risk profile
  • Clear versioning (_v2, _v3) tracks evolution
  • Suffixes (_optimized, _allora) indicate enhancements
  • Consistent naming enables easy filtering and comparison
遵循以下格式:
{Name}_{RiskLevel}[_suffix]
风险等级:
  • H(高): 激进型策略,高杠杆,窄止损,可接受>20%的回撤
  • M(中): 平衡型策略,中等杠杆,标准止损,回撤10-20%
  • L(低): 保守型策略,低杠杆,宽止损,回撤<10%
示例:
  • RSIMeanReversion_M
    - 基础策略,中等风险
  • MomentumBreakout_H_optimized
    - 优化后策略,高风险
  • TrendFollower_L_allora
    - 集成Allora机器学习增强,低风险
  • BollingerBands_M_v2
    - 策略第2版
命名的重要性:
  • 便于按风险特征整理策略
  • 清晰的版本号(_v2、_v3)追踪策略演进
  • 后缀(_optimized、_allora)标识增强特性
  • 统一命名便于筛选和对比

Position Sizing Patterns

仓位管理模式

Recommended position sizing: 85-95% of available margin
Common approaches:
1. Fixed percentage (simple, predictable):
python
def go_long(self):
    qty = utils.size_to_qty(self.balance * 0.90, self.price)
    self.buy = qty, self.price
2. Volatility-based (adaptive to market conditions):
python
def go_long(self):
    atr = ta.atr(self.candles, period=14)
    # Reduce size in high volatility
    size_multiplier = 0.90 if atr < self.price * 0.02 else 0.70
    qty = utils.size_to_qty(self.balance * size_multiplier, self.price)
    self.buy = qty, self.price
3. Risk-based (size based on stop loss distance):
python
def go_long(self):
    atr = ta.atr(self.candles, period=14)
    stop_distance = atr * 2  # Stop at 2× ATR
    # Risk 2% of balance per trade
    risk_amount = self.balance * 0.02
    qty = risk_amount / stop_distance
    self.buy = qty, self.price
Best practice: Specify position sizing approach in description when creating strategy
推荐仓位比例: 可用保证金的85-95%
常见方法:
1. 固定比例(简单、可预测):
python
def go_long(self):
    qty = utils.size_to_qty(self.balance * 0.90, self.price)
    self.buy = qty, self.price
2. 基于波动率(根据市场条件自适应):
python
def go_long(self):
    atr = ta.atr(self.candles, period=14)
    # 高波动率时降低仓位
    size_multiplier = 0.90 if atr < self.price * 0.02 else 0.70
    qty = utils.size_to_qty(self.balance * size_multiplier, self.price)
    self.buy = qty, self.price
3. 基于风险(根据止损距离确定仓位):
python
def go_long(self):
    atr = ta.atr(self.candles, period=14)
    stop_distance = atr * 2  # 止损设置为2倍ATR
    # 每笔交易风险控制在账户的2%
    risk_amount = self.balance * 0.02
    qty = risk_amount / stop_distance
    self.buy = qty, self.price
最佳实践: 创建策略时,在需求描述中明确仓位管理方法

Risk Management Requirements

风险管理要求

Every strategy should include:
1. Stop Loss (mandatory):
python
def on_open_position(self, order):
    atr = ta.atr(self.candles, period=14)
    # Stop at 2× ATR below entry (long) or above entry (short)
    self.stop_loss = qty, self.price - (atr * 2)  # Long
    # or
    self.stop_loss = qty, self.price + (atr * 2)  # Short
2. Take Profit (recommended):
python
def on_open_position(self, order):
    atr = ta.atr(self.candles, period=14)
    # Target at 3× ATR (risk/reward = 1.5)
    self.take_profit = qty, self.price + (atr * 3)  # Long
3. Position sizing (see above)
Red flags (avoid these):
  • No stop loss (unlimited downside)
  • Stop loss too tight (<0.5% from entry) - will be stopped out by noise
  • Stop loss too wide (>5% from entry) - excessive risk per trade
  • Position size >95% of margin - insufficient buffer for margin calls
  • No take profit - positions may give back gains
每个策略都应包含:
1. 止损(必填):
python
def on_open_position(self, order):
    atr = ta.atr(self.candles, period=14)
    # 多单止损设置为入场价下方2倍ATR
    self.stop_loss = qty, self.price - (atr * 2)  # 多单
    # 或
    self.stop_loss = qty, self.price + (atr * 2)  # 空单
2. 止盈(推荐):
python
def on_open_position(self, order):
    atr = ta.atr(self.candles, period=14)
    # 止盈设置为3倍ATR(风险/回报比1.5)
    self.take_profit = qty, self.price + (atr * 3)  # 多单
3. 仓位管理(见上文)
需避免的问题:
  • 无止损(下行风险无限制)
  • 止损过窄(距离入场价<0.5%)- 易被市场噪音止损
  • 止损过宽(距离入场价>5%)- 单交易风险过高
  • 仓位占比>95%可用保证金 - 保证金不足风险高
  • 无止盈 - 盈利可能回吐

Available Indicators

可用指标

170+ technical indicators via
jesse.indicators
:
Use exact names when describing strategy requirements:
Momentum (16 indicators):
  • RSI, MACD, Stochastic, ADX, CCI, MFI, ROC, Williams %R, etc.
Trend (12 indicators):
  • EMA, SMA, DEMA, TEMA, WMA, Supertrend, Parabolic SAR, VWAP, HMA, etc.
Volatility (8 indicators):
  • Bollinger Bands, ATR, Keltner Channels, Donchian Channels, Standard Deviation, etc.
Volume (10 indicators):
  • OBV, Volume Profile, Chaikin Money Flow, etc.
How to find indicators:
(Use browse-robonet-data skill)
get_all_technical_indicators(category="momentum")
In strategy description, use exact names: ✓ "Use RSI with period 14" ✓ "Use Bollinger Bands with period 20, std 2" ✗ "Use relative strength" (ambiguous) ✗ "Use BB" (unclear abbreviation)
通过
jesse.indicators
可使用170+技术指标
:
描述策略需求时请使用准确的指标名称:
动量类(16个指标):
  • RSI、MACD、Stochastic、ADX、CCI、MFI、ROC、Williams %R等
趋势类(12个指标):
  • EMA、SMA、DEMA、TEMA、WMA、Supertrend、Parabolic SAR、VWAP、HMA等
波动率类(8个指标):
  • Bollinger Bands、ATR、Keltner Channels、Donchian Channels、Standard Deviation等
成交量类(10个指标):
  • OBV、Volume Profile、Chaikin Money Flow等
如何查找指标:
(使用browse-robonet-data技能)
get_all_technical_indicators(category="momentum")
策略描述中请使用准确名称: ✓ "使用周期为14的RSI" ✓ "使用周期20、标准差2的Bollinger Bands" ✗ "使用相对强度指标"(表述模糊) ✗ "使用BB"(缩写不明确)

Best Practices

最佳实践

Cost Management

成本管理

This is the most expensive tool ($1-$4.50). Minimize waste:
Before using create_strategy:
  1. ✅ Browse data with
    browse-robonet-data
    (verify symbols/indicators available)
  2. ✅ Optionally generate ideas with
    design-trading-strategies
    ($0.05-$1.00 exploration)
  3. ✅ Have detailed requirements written out
  4. ✅ Understand Jesse framework basics
Avoid these costly mistakes:
  • ❌ Creating strategy without checking indicator availability → Wasted $2.50
  • ❌ Vague description ("build a good BTC strategy") → Poor results, need to regenerate
  • ❌ Unclear requirements → Code doesn't match expectations, wasted generation
  • ❌ Not specifying risk management → Need to regenerate with stops/sizing
Cost-saving pattern:
1. browse-robonet-data ($0.001) → Verify resources
2. design-trading-strategies ($0.30) → Explore 3 ideas
3. Pick best idea and refine description
4. create_strategy ($2.50) → Generate once, correctly
Total: $2.80 with high success rate

vs.

1. create_strategy ($2.50) → Vague requirements
2. Doesn't work, try again ($2.50)
3. Still not right ($2.50)
Total: $7.50 with frustration
这是成本最高的工具(1-4.50美元)。请尽量避免浪费:
使用create_strategy前:
  1. ✅ 使用
    browse-robonet-data
    浏览数据(验证交易对/指标可用)
  2. ✅ (可选)使用
    design-trading-strategies
    生成思路(0.05-1.00美元的探索成本)
  3. ✅ 撰写详细的需求描述
  4. ✅ 了解Jesse框架基础
需避免的 costly 错误:
  • ❌ 未检查指标可用性就创建策略 → 浪费2.50美元
  • ❌ 描述模糊("构建一个盈利的BTC策略")→ 结果不佳,需要重新生成
  • ❌ 需求不明确 → 代码与预期不符,浪费生成成本
  • ❌ 未指定风险管理 → 需要重新生成以添加止损/仓位管理
成本优化流程:
1. browse-robonet-data(0.001美元)→ 验证资源
2. design-trading-strategies(0.30美元)→ 探索3个思路
3. 选择最佳思路并细化描述
4. create_strategy(2.50美元)→ 一次生成正确的代码
总成本: 2.80美元,成功率高

对比:

1. create_strategy(2.50美元)→ 需求模糊
2. 结果不符,重试(2.50美元)
3. 仍不符合预期(2.50美元)
总成本: 7.50美元,且体验糟糕

Writing Effective Descriptions

撰写有效的需求描述

Anatomy of a good description:
Entry Conditions:
- Specific indicator with exact parameters
- Exact thresholds
- Multiple conditions with AND/OR logic

Exit Conditions:
- Stop loss method and distance
- Take profit method and target
- Trailing stop if applicable

Position Sizing:
- Percentage of margin to use
- Or risk-based sizing method

Risk Management:
- Maximum loss per trade
- Any position limits

Context:
- Timeframe (5m, 1h, 4h, 1d)
- Market regime (trending, ranging)
Example of GOOD description:
"RSI Mean Reversion strategy for BTC-USDT on 1h timeframe.

ENTRY (Long):
- RSI(14) < 30 (oversold)
- Price touches lower Bollinger Band (20-period, 2 std dev)
- Confirm with volume: current volume > 1.2× 20-period average

EXIT (Long):
- Take profit: Price reaches middle Bollinger Band
- Stop loss: 2% below entry price
- Trailing stop: Once profit >3%, trail stop at 1.5% below highest price

POSITION SIZING:
- Use 90% of available margin per trade
- Single position at a time (no pyramiding)

RISK MANAGEMENT:
- Maximum loss: 2% of account per trade
- No new trades if in drawdown >10%"
Example of BAD description:
"Build a profitable BTC strategy using RSI and Bollinger Bands"
Problems:
  • No entry conditions specified (what RSI value?)
  • No exit conditions (when to close?)
  • No position sizing (how much to risk?)
  • No timeframe (1m? 1d?)
  • Too vague → Will require regeneration
优质描述的结构:
入场条件:
- 带具体参数的特定指标
- 明确的阈值
- 带AND/OR逻辑的多条件

出场条件:
- 止损方法和距离
- 止盈方法和目标
- (可选)追踪止损规则

仓位管理:
- 可用保证金的使用比例
- 或基于风险的仓位方法

风险管理:
- 每笔交易的最大亏损
- 任何仓位限制

背景信息:
- 时间框架(5m、1h、4h、1d)
- 市场状态(趋势、震荡)
优质描述示例:
"针对BTC-USDT的1小时时间框架RSI均值回归策略。

多单入场:
- RSI(14) < 30(超卖)
- 价格触及Bollinger Bands下轨(周期20,标准差2)
- 成交量确认:当前成交量>20周期平均成交量的1.2倍

多单出场:
- 止盈:价格触及Bollinger Bands中轨
- 止损:入场价下方2%
- 追踪止损:盈利>3%后,止损设置为最高价下方1.5%

仓位管理:
- 每笔交易使用90%的可用保证金
- 单次仅持有一个仓位(不加仓)

风险管理:
- 每笔交易最大亏损:账户的2%
- 账户回撤>10%时不再开新仓"
糟糕描述示例:
"使用RSI和Bollinger Bands构建一个盈利的BTC策略"
问题:
  • 未指定入场条件(RSI数值是多少?)
  • 未指定出场条件(何时平仓?)
  • 未指定仓位管理(风险比例是多少?)
  • 未指定时间框架(1分钟?1天?)
  • 过于模糊 → 需要重新生成

Validation Checklist

验证清单

After strategy is generated, verify code includes:
  • All required methods (should_long, should_short, go_long, go_short)
  • Stop loss logic (in on_open_position or go_long/go_short)
  • Take profit logic (recommended)
  • Position sizing (qty calculation in go_long/go_short)
  • Valid indicator calls (e.g.,
    ta.rsi(self.candles, period=14)
    )
  • Proper entry/exit conditions matching description
  • No syntax errors (code is runnable)
  • Indicator parameters are reasonable (not over-optimized)
If validation fails:
  • Use
    improve-trading-strategies
    skill to fix issues ($0.50-$3.00)
  • Cheaper than regenerating with
    create_strategy
    ($1-$4.50)
策略生成后,检查代码是否包含:
  • 所有必填方法(should_long、should_short、go_long、go_short)
  • 止损逻辑(在on_open_position或go_long/go_short中)
  • 止盈逻辑(推荐包含)
  • 仓位管理(go_long/go_short中的仓位计算)
  • 有效的指标调用(例如
    ta.rsi(self.candles, period=14)
  • 与描述匹配的入场/出场条件
  • 无语法错误(代码可运行)
  • 指标参数合理(未过度优化)
如果验证不通过:
  • 使用
    improve-trading-strategies
    技能修复问题(0.50-3.00美元)
  • 比使用
    create_strategy
    重新生成更便宜(1-4.50美元)

Timeframe Considerations

时间框架考量

Match strategy logic to timeframe:
Scalping (1m-5m):
  • Tight stops (0.2-0.5%)
  • Quick exits (minutes to hours)
  • High-frequency indicators (short periods)
  • Focus on execution and fees
Intraday (15m-1h):
  • Moderate stops (0.5-2%)
  • Hold hours to 1 day
  • Standard indicator periods (14, 20, 50)
  • Balance between frequency and noise
Swing Trading (4h-1d):
  • Wide stops (2-5%)
  • Hold days to weeks
  • Longer indicator periods (50, 100, 200)
  • Focus on larger trends
Specify timeframe in description:
"For 1h timeframe..." (helps AI tune indicator parameters appropriately)
策略逻辑需与时间框架匹配:
Scalping(1m-5m):
  • 窄止损(0.2-0.5%)
  • 快速出场(分钟到小时级)
  • 高频指标(短周期)
  • 关注执行效率和手续费
日内交易(15m-1h):
  • 中等止损(0.5-2%)
  • 持仓时间(小时到1天)
  • 标准指标周期(14、20、50)
  • 平衡交易频率和市场噪音
波段交易(4h-1d):
  • 宽止损(2-5%)
  • 持仓时间(天到周)
  • 长周期指标(50、100、200)
  • 关注大趋势
在描述中明确时间框架:
"针对1小时时间框架..."(帮助AI调整指标参数)

Common Workflows

常见工作流

Workflow 1: Build from Scratch

工作流1:从零开始构建

Goal: Create new strategy from concept
1. Explore data (use browse-robonet-data):
   get_all_symbols() → Choose BTC-USDT
   get_all_technical_indicators(category="momentum") → Pick RSI
   get_all_technical_indicators(category="volatility") → Pick Bollinger Bands

2. Optional: Generate ideas (use design-trading-strategies):
   generate_ideas(strategy_count=3) → Get concepts
   Pick best concept as starting point

3. Write detailed description:
   - Entry: RSI < 30 AND price at lower BB
   - Exit: Price at middle BB OR stop loss 2%
   - Sizing: 90% margin
   - Timeframe: 1h

4. Create strategy:
   create_strategy(
       strategy_name="RSIMeanReversion_M",
       description="[detailed description from step 3]"
   )

5. Validate generated code:
   - Check all required methods present
   - Verify indicators match description
   - Confirm risk management included

6. Test immediately (use test-trading-strategies):
   run_backtest(strategy_name="RSIMeanReversion_M", ...)
Cost: ~$2-4 total ($0.30 ideas + $2.50 creation + $0.001 test)
目标: 从概念创建新策略
1. 探索数据(使用browse-robonet-data):
   get_all_symbols() → 选择BTC-USDT
   get_all_technical_indicators(category="momentum") → 选择RSI
   get_all_technical_indicators(category="volatility") → 选择Bollinger Bands

2. (可选)生成思路(使用design-trading-strategies):
   generate_ideas(strategy_count=3) → 获取策略概念
   选择最佳概念作为起点

3. 撰写详细描述:
   - 入场:RSI < 30 且价格触及Bollinger Bands下轨
   - 出场:价格触及Bollinger Bands中轨 或 止损2%
   - 仓位:90%保证金
   - 时间框架:1小时

4. 创建策略:
   create_strategy(
       strategy_name="RSIMeanReversion_M",
       description="[步骤3的详细描述]"
   )

5. 验证生成的代码:
   - 检查所有必填方法是否存在
   - 验证指标与描述一致
   - 确认包含风险管理逻辑

6. 立即测试(使用test-trading-strategies):
   run_backtest(strategy_name="RSIMeanReversion_M", ...)
成本: 总计~2-4美元(0.30美元思路生成 + 2.50美元策略创建 + 0.001美元测试)

Workflow 2: Build from Idea

工作流2:从思路构建

Goal: Transform AI-generated concept into working code
1. Generate ideas (use design-trading-strategies):
   generate_ideas(strategy_count=3)

   Idea #2: "Bollinger Band Breakout"
   Entry: Price breaks above upper BB with high volume
   Exit: Price returns to middle BB
   Uses: Bollinger Bands, Volume

2. Refine idea into detailed description:
   "Bollinger Band Breakout strategy for ETH-USDT on 4h timeframe.

   ENTRY (Long):
   - Price closes above upper Bollinger Band (20, 2)
   - Current volume > 1.5× 20-period average volume
   - ADX(14) > 25 (confirm trend strength)

   EXIT (Long):
   - Price closes below middle Bollinger Band
   - Or stop loss 3% below entry
   - Or take profit at 9% above entry (3:1 reward:risk)

   POSITION SIZING: 85% of margin
   RISK: Max 3% loss per trade"

3. Create strategy:
   create_strategy(
       strategy_name="BollingerBreakout_H",
       description="[detailed description from step 2]"
   )

4. Test and validate:
   run_backtest(strategy_name="BollingerBreakout_H", ...)
Cost: ~$3 ($0.30 ideas + $2.50 creation + $0.001 test)
目标: 将AI生成的概念转换为可运行代码
1. 生成思路(使用design-trading-strategies):
   generate_ideas(strategy_count=3)

   思路#2: "Bollinger Band突破策略"
   入场:价格放量突破Bollinger Bands上轨
   出场:价格回到Bollinger Bands中轨
   使用指标:Bollinger Bands、成交量

2. 将思路细化为详细描述:
   "针对ETH-USDT的4小时时间框架Bollinger Band突破策略。

   多单入场:
   - 收盘价突破Bollinger Bands上轨(周期20,标准差2)
   - 当前成交量>20周期平均成交量的1.5倍
   - ADX(14) >25(确认趋势强度)

   多单出场:
   - 收盘价跌破Bollinger Bands中轨
   - 或 入场价下方3%止损
   - 或 入场价上方9%止盈(风险/回报比3:1)

   仓位管理:85%保证金
   风险管理:每笔交易最大亏损3%"

3. 创建策略:
   create_strategy(
       strategy_name="BollingerBreakout_H",
       description="[步骤2的详细描述]"
   )

4. 测试和验证:
   run_backtest(strategy_name="BollingerBreakout_H", ...)
成本: ~3美元(0.30美元思路生成 + 2.50美元策略创建 + 0.001美元测试)

Workflow 3: Build Prediction Market Strategy

工作流3:构建预测市场策略

Goal: Create Polymarket YES/NO token trading strategy
1. Browse prediction markets (use browse-robonet-data):
   get_data_availability(data_type="polymarket")
   → See available markets

2. Analyze market data:
   get_prediction_market_data(condition_id="...")
   → Study YES/NO token price history

3. Write detailed description:
   "Polymarket probability arbitrage strategy for crypto_rolling markets.

   BUY YES TOKEN when:
   - YES token price < 0.40 (implied 40% probability)
   - Market has >$10k volume (sufficient liquidity)
   - Time to resolution > 2 hours (avoid last-minute volatility)

   BUY NO TOKEN when:
   - NO token price < 0.40 (YES price > 0.60)
   - Same liquidity and time criteria

   EXIT:
   - Sell when price reaches 0.55 (15% profit target)
   - Or hold until market resolution
   - Stop loss: Sell if price drops to 0.25 (37.5% loss)

   POSITION SIZING: 5% of capital per market
   MAX POSITIONS: 10 simultaneous markets"

4. Create prediction market strategy:
   create_prediction_market_strategy(
       strategy_name="PolymarketArbitrage_M",
       description="[detailed description from step 3]"
   )

5. Test on historical markets:
   run_prediction_market_backtest(...)
Cost: ~$2.50 + $0.001 test = $2.501
目标: 创建Polymarket YES/NO代币交易策略
1. 浏览预测市场数据(使用browse-robonet-data):
   get_data_availability(data_type="polymarket")
   → 查看可用市场

2. 分析市场数据:
   get_prediction_market_data(condition_id="...")
   → 研究YES/NO代币价格历史

3. 撰写详细描述:
   "针对crypto_rolling市场的Polymarket概率套利策略。

   买入YES代币的条件:
   - YES代币价格 < 0.40(隐含40%概率)
   - 市场成交量>10,000美元(流动性充足)
   - 距结算时间>2小时(避免尾盘波动)

   买入NO代币的条件:
   - NO代币价格 < 0.40(YES价格>0.60)
   - 满足相同的流动性和时间要求

   出场:
   - 价格达到0.55时卖出(15%盈利目标)
   - 或持有至市场结算
   - 止损:价格跌至0.25时卖出(37.5%亏损)

   仓位管理:每个市场投入5%的资金
   最大持仓:同时持有10个市场的仓位"

4. 创建预测市场策略:
   create_prediction_market_strategy(
       strategy_name="PolymarketArbitrage_M",
       description="[步骤3的详细描述]"
   )

5. 在历史市场中测试:
   run_prediction_market_backtest(...)
成本: ~2.501美元(2.50美元策略创建 + 0.001美元测试)

Advanced Usage

高级用法

Multi-Timeframe Strategies

多时间框架策略

Describe higher timeframe context in strategy requirements:
"ETH-USDT swing trading strategy on 1h timeframe with 4h trend filter.

HIGHER TIMEFRAME (4h):
- Only take long trades when 4h EMA(50) is rising
- Only take short trades when 4h EMA(50) is falling

ENTRY TIMEFRAME (1h):
- [standard entry conditions on 1h]
..."
AI will generate code that checks higher timeframe conditions.
在策略需求中描述更高时间框架的过滤条件:
"针对ETH-USDT的1小时时间框架波段交易策略,搭配4小时趋势过滤。

高时间框架(4小时):
- 仅当4小时EMA(50)上升时做多
- 仅当4小时EMA(50)下降时做空

入场时间框架(1小时):
- [1小时时间框架的标准入场条件]
..."
AI会生成包含高时间框架条件检查的代码。

Complex Entry Logic

复杂入场逻辑

Specify precise logic for multiple conditions:
"Entry requires ALL of these conditions (AND logic):
1. RSI(14) < 30
2. Price < Lower Bollinger Band (20, 2)
3. MACD histogram positive (bullish divergence)
4. Volume > 1.3× average

OR entry if these alternative conditions met:
1. Price makes higher low
2. RSI makes higher low (bullish divergence)
3. Volume surge (>2× average)"
AI can handle complex multi-condition logic if clearly specified.
明确指定多条件的精确逻辑:
"入场需满足以下所有条件(AND逻辑):
1. RSI(14) < 30
2. 价格 < Bollinger Bands下轨(周期20,标准差2)
3. MACD直方图为正(看涨背离)
4. 成交量>平均成交量的1.3倍

或满足以下替代条件时入场:
1. 价格形成更高的低点
2. RSI形成更高的低点(看涨背离)
3. 成交量暴增(>平均成交量的2倍)"
如果描述清晰,AI可以处理复杂的多条件逻辑。

Dynamic Position Sizing

动态仓位管理

Specify adaptive sizing in description:
"Position sizing based on volatility:
- When ATR(14) < 2% of price: Use 95% margin (low volatility)
- When ATR between 2-4%: Use 85% margin (normal)
- When ATR > 4%: Use 70% margin (high volatility)

This reduces risk during volatile periods."
在描述中指定自适应仓位规则:
"基于波动率调整仓位:
- 当ATR(14) < 价格的2%时:使用95%的保证金(低波动率)
- 当ATR在2-4%之间时:使用85%的保证金(正常波动率)
- 当ATR>4%时:使用70%的保证金(高波动率)

此规则可在高波动时期降低风险。"

Troubleshooting

故障排除

"Generated Code Has Errors"

"生成的代码有错误"

Issue: Strategy code doesn't run or has syntax errors
Solutions:
  • Use
    improve-trading-strategies
    skill with
    refine_strategy
    to fix errors
  • Cheaper than regenerating ($0.50-$3.00 vs $1-$4.50)
  • Specify exact error message in refine description
问题: 策略代码无法运行或存在语法错误
解决方案:
  • 使用
    improve-trading-strategies
    技能的
    refine_strategy
    功能修复错误
  • 比重新生成更便宜(0.50-3.00美元 vs 1-4.50美元)
  • 在优化描述中指定具体的错误信息

"Strategy Doesn't Match Description"

"策略与描述不符"

Issue: Generated logic differs from what you requested
Solutions:
  • Description may have been ambiguous
  • Use
    improve-trading-strategies
    skill to refine specific parts
  • For major mismatch, may need to regenerate with clearer description
问题: 生成的逻辑与你的需求不一致
解决方案:
  • 描述可能存在歧义
  • 使用
    improve-trading-strategies
    技能优化特定部分
  • 如果差异较大,可能需要重新生成并使用更清晰的描述

"Indicators Not Available"

"指标不可用"

Issue: Strategy uses indicators that don't exist in Jesse
Solutions:
  • Should have used
    browse-robonet-data
    first to verify indicators
  • Use
    refine_strategy
    to replace with valid indicators
  • Check indicator spelling (RSI not rsi, MACD not macd)
问题: 策略使用了Jesse中不存在的指标
解决方案:
  • 你本应先使用
    browse-robonet-data
    验证指标可用性
  • 使用
    refine_strategy
    替换为有效的指标
  • 检查指标拼写(RSI而非rsi,MACD而非macd)

"Strategy Too Complex"

"策略过于复杂"

Issue: Generated code is overly complicated with 8+ indicators
Solutions:
  • Simplify description (request fewer indicators)
  • Use
    refine_strategy
    to remove unnecessary complexity
  • Complex strategies often overfit and perform poorly
问题: 生成的代码过于复杂,使用了8个以上的指标
解决方案:
  • 简化描述(减少指标数量)
  • 使用
    refine_strategy
    移除不必要的复杂度
  • 复杂策略通常容易过拟合,表现不佳

"No Risk Management Included"

"未包含风险管理"

Issue: Generated code lacks stop loss or position sizing
Solutions:
  • Description must explicitly request risk management
  • Use
    refine_strategy
    to add stop loss and sizing
  • Always specify: "Include stop loss at X% and position size of Y%"
问题: 生成的代码缺少止损或仓位管理
解决方案:
  • 描述中必须明确要求风险管理
  • 使用
    refine_strategy
    添加止损和仓位管理
  • 请始终明确说明:"包含X%的止损和Y%的仓位比例"

Next Steps

后续步骤

After building a strategy:
Test the strategy (CRITICAL - do this next):
  • Use
    test-trading-strategies
    skill to backtest
  • Cost: $0.001 per backtest
  • Validate performance before ANY further work
  • Check: Sharpe >1.0, drawdown <20%, win rate 45-65%
Improve the strategy (if needed):
  • Use
    improve-trading-strategies
    skill to refine code
  • Cost: $0.50-$4.00 per operation
  • Cheaper than regenerating from scratch
  • Options: refine_strategy, optimize_strategy, enhance_with_allora
Deploy to production (only after thorough testing):
  • Use
    deploy-live-trading
    skill (HIGH RISK)
  • Cost: $0.50 deployment fee
  • NEVER deploy without extensive backtesting (6+ months recommended)
  • Start small, monitor closely
策略构建完成后:
测试策略(非常关键 - 立即执行):
  • 使用
    test-trading-strategies
    技能进行回测
  • 成本:每次回测0.001美元
  • 进行任何进一步操作前验证策略表现
  • 检查:夏普比率>1.0,回撤<20%,胜率45-65%
优化策略(如果需要):
  • 使用
    improve-trading-strategies
    技能优化代码
  • 成本:每次操作0.50-4.00美元
  • 比从零重新生成更便宜
  • 可选功能: refine_strategy、optimize_strategy、enhance_with_allora
部署到生产环境(仅在充分测试后执行):
  • 使用
    deploy-live-trading
    技能(高风险)
  • 成本:0.50美元部署费
  • 未经充分回测(建议6个月以上)绝不部署
  • 从小仓位开始,密切监控

Summary

总结

This skill provides AI-powered strategy code generation:
  • 2 tools: create_strategy (crypto), create_prediction_market_strategy (Polymarket)
  • Cost: $1.00-$4.50 per generation (MOST EXPENSIVE tool)
  • Execution: 30-60 seconds
  • Output: Production-ready Python code with Jesse framework structure
Core principle: This is expensive. Prepare thoroughly before using:
  1. Browse data (verify resources available)
  2. Optionally generate ideas (explore concepts cheaply)
  3. Write detailed description (clear requirements)
  4. Generate once, correctly
  5. Test immediately
Critical warning: Generated code may have bugs or not match expectations. ALWAYS test with
test-trading-strategies
before deploying. NEVER deploy untested strategies to live trading.
Cost optimization: Spending 5 minutes preparing ($0-$0.30 exploration) saves dollars in wasted generations and improves success rate dramatically.
本技能提供基于AI的策略代码生成:
  • 2个工具: create_strategy(加密货币)、create_prediction_market_strategy(Polymarket)
  • 成本: 每次生成1.00-4.50美元(成本最高的工具)
  • 执行时间: 30-60秒
  • 输出: 符合Jesse框架结构的可投入生产的Python代码
核心原则: 本工具成本较高。使用前请充分准备:
  1. 浏览数据(验证资源可用)
  2. (可选)生成思路(低成本探索概念)
  3. 撰写详细的需求描述
  4. 一次生成正确的代码
  5. 立即测试
重要警告: 生成的代码可能存在bug或与预期不符。部署前务必使用
test-trading-strategies
进行测试。绝不将未测试的策略部署到实盘交易。
成本优化: 花5分钟做准备(0-0.30美元的探索成本)可以节省数美元的重复生成成本,并大幅提高成功率。