trading
Position sizing, risk management, and order execution for crypto trading
- License 许可
- MIT
- 最近更新
- 2026-03-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- trading
- description
- Position sizing, risk management, and order execution for crypto trading
02 资源文件 49
- 其他.gitignore661 B
- 其他.streamlit/config.toml353 B
- 参考文档data/README.md488 B
- 其他data/rl_feedback.jsonl2.5 KB
- 参考文档LLM_POLICY_ANALYSIS.md9.5 KB
- 参考文档models/README.md496 B
- 参考文档MODERN_UI_FEATURES.md6.0 KB
- 参考文档MODERN_UI_GUIDE.md3.2 KB
- 参考文档NEW_FEATURES.md8.6 KB
- 参考文档NN_IMPLEMENTATION.md14.2 KB
- 其他pyproject.toml787 B
- 参考文档README.md4.5 KB
- 参考文档references/risk-parameters.md2.8 KB
- 参考文档requirements.txt401 B
- 参考文档RUN_APP.md—
- 脚本run_enhanced.sh—
- 脚本run.sh755 B
- 脚本src/__init__.py130 B
- 脚本src/app_tabs_extension.py7.9 KB
- 脚本src/app.py72.3 KB
- 脚本src/config.py4.9 KB
- 脚本src/data_models.py7.0 KB
- 脚本src/llm_client.py26.6 KB
- 脚本src/logging_config.py4.2 KB
- 脚本src/ml_data.py3.0 KB
- 脚本src/nn_model.py9.6 KB
- 脚本src/policy_analyzer.py10.8 KB
- 脚本src/population.py10.7 KB
- 脚本src/rl_agent.py18.6 KB
- 脚本src/rl_environment.py—
- 脚本src/rl_trainer.py10.5 KB
- 脚本src/simulation.py28.8 KB
- 脚本src/stats.py8.1 KB
- 脚本src/utils.py3.3 KB
- 参考文档STATUS.md—
- 脚本streamlit_app.py496 B
- 参考文档SUMMARY.md—
- 参考文档TECH_STACK.md19.1 KB
- 脚本test.sh—
- 脚本tests/__init__.py35 B
- 脚本tests/test_data_models.py2.1 KB
- 脚本tests/test_llm_client.py14.6 KB
- 脚本tests/test_nn_model.py1.1 KB
- 脚本tests/test_population.py5.4 KB
- 脚本tests/test_simulation.py17.9 KB
- 脚本tests/test_stats.py4.9 KB
- 脚本tests/test_utils.py3.6 KB
- 参考文档UNIFIED_APP_MIGRATION.md—
- 脚本verify_enhancements.py—
03 SKILL.md 正文
Trading
Calculate optimal position sizes, manage risk with stop losses and take profits, and execute orders across DEX and CEX venues.
Position Sizing (Fixed-Percentage Risk Model)
The core risk model: risk a fixed percentage of portfolio value per trade.
Formulas
Risk Amount = Portfolio Value * (Risk Per Trade % / 100)
Stop Loss Distance = |Entry Price - Stop Loss Price|
Position Size (units) = Risk Amount / Stop Loss Distance
Position Value = Position Size * Entry Price
Max Allowed Value = Portfolio Value * (Max Position % / 100)
If Position Value > Max Allowed Value, cap the position:
Position Value = Max Allowed Value
Position Size = Max Allowed Value / Entry Price
Example
Portfolio: $50,000. Risk per trade: 2%. Entry: $100. Stop loss: $95.
Risk Amount = $50,000 * 0.02 = $1,000
Stop Loss Distance = |$100 - $95| = $5
Position Size = $1,000 / $5 = 200 units
Position Value = 200 * $100 = $20,000
Max Allowed (10%) = $50,000 * 0.10 = $5,000
Since $20,000 > $5,000 → cap at $5,000 → 50 units
Kelly Criterion (Half-Kelly)
Optimal position sizing based on historical win rate and average win/loss.
kelly = (WinRate * AvgWin% - (1 - WinRate) * AvgLoss%) / AvgWin%
half_kelly = max(0, kelly / 2)
Position Value = Portfolio * half_kelly
Default estimates (when no historical data available):
- Win Rate: 55%
- Average Win: 3%
- Average Loss: 2%
Half-Kelly is used instead of full Kelly to reduce the risk of ruin. Full Kelly is mathematically optimal but assumes perfect knowledge of probabilities, which is unrealistic in practice.
Risk/Reward Ratio
Risk = |Entry Price - Stop Loss Price|
Reward = |Take Profit Price - Entry Price|
R:R = Reward / Risk
| R:R Rating | Ratio | Guidance |
|---|---|---|
| Excellent | >= 3:1 | High confidence trades |
| Good | >= 2:1 | Standard target |
| Acceptable | >= 1:1 | Only with high win rate |
| Poor | < 1:1 | Avoid unless special circumstances |
Order Types
| Order Type | Description |
|---|---|
market |
Execute immediately at current market price |
limit |
Execute only at specified price or better |
stop_loss |
Sell when price drops to stop level (risk management) |
take_profit |
Sell when price rises to target level (lock in gains) |
trailing_stop |
Stop loss that moves up with price (follows by fixed % or amount) |
Slippage Management
- Default slippage: 0.5%
- Slippage is the difference between expected and actual execution price
- For DEX swaps, set slippage tolerance per exchange:
- Jupiter (Solana): specified in basis points (0.5% = 50 bps)
- 1inch (EVM): specified as percentage (0.5 = 0.5%)
- Higher volatility tokens may need higher slippage tolerance (1-3%)
- Very low liquidity tokens may need 5%+ or should be avoided
Default Parameters
| Parameter | Default | Description |
|---|---|---|
| Default Slippage | 0.5% | Slippage tolerance for swaps |
| Max Position Size | 10% | Maximum % of portfolio in a single position |
| Risk Per Trade | 2% | Maximum % of portfolio risked per trade |
| RSI Oversold | 30 | RSI level considered oversold |
| RSI Overbought | 70 | RSI level considered overbought |
See references/risk-parameters.md for the full parameter table with valid ranges.
04 同仓库更多 Skills
lucid-PLUGIN_NAME
PLUGIN_DESCRIPTION
social-content
Generate short-form video content optimized for social media platforms
personalized-outreach
Generate 1:1 personalized video for sales prospecting and customer success
data-reports
Generate animated data report videos from KPIs, charts, and analytics
lucid-video
Agent-native video generation using Remotion — MCP server + OpenClaw plugin
lucid-veille
Content monitoring, AI digest generation, and multi-platform auto-publishing