mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-14 16:26:57 +08:00
feat: autopilot book to 4 positions x 5x notional at 20x leverage
Was 2 positions x ~equity×1.2 — too few holdings and no room for shorts (the 2 slots filled with the strongest signals, which were long-leaning, so the balanced candidate pool never got expressed as short trades). Now: max 4 positions, each sized at equity×5 notional, 20x leverage. Four positions × 5x = 20x total account notional = full margin at 20x — the operator's requested ceiling. This gives room for ~2 long + 2 short and bigger single positions; the existing direction-balanced candidate selection plus long/short coverage fills both sides when strong bearish signals exist. Applied across all three config sources (default template, quick-create preset, studio unified) with matching test assertions and 20x prompt copy.
This commit is contained in:
@@ -262,13 +262,14 @@ func (s *Server) createDefaultStrategies(userID string, lang string) error {
|
|||||||
c.CoinSource.VergexLimit = 10
|
c.CoinSource.VergexLimit = 10
|
||||||
c.CoinSource.VergexMarketType = "all"
|
c.CoinSource.VergexMarketType = "all"
|
||||||
c.CoinSource.VergexChain = "hyperliquid"
|
c.CoinSource.VergexChain = "hyperliquid"
|
||||||
c.RiskControl.MaxPositions = 2
|
c.RiskControl.MaxPositions = 4
|
||||||
c.RiskControl.BTCETHMaxLeverage = 10
|
c.RiskControl.BTCETHMaxLeverage = 20
|
||||||
c.RiskControl.AltcoinMaxLeverage = 10
|
c.RiskControl.AltcoinMaxLeverage = 20
|
||||||
// 4× equity notional per position: at 10x leverage two full positions
|
// 5× equity notional per position: 4 positions = 20x total account
|
||||||
// use ~80% of margin — concentrated but solvent.
|
// notional (full margin at 20x). Bigger single positions with room for
|
||||||
c.RiskControl.BTCETHMaxPositionValueRatio = 4.0
|
// a balanced long/short book.
|
||||||
c.RiskControl.AltcoinMaxPositionValueRatio = 4.0
|
c.RiskControl.BTCETHMaxPositionValueRatio = 5.0
|
||||||
|
c.RiskControl.AltcoinMaxPositionValueRatio = 5.0
|
||||||
c.RiskControl.MaxMarginUsage = 1.0
|
c.RiskControl.MaxMarginUsage = 1.0
|
||||||
c.RiskControl.MinConfidence = 78
|
c.RiskControl.MinConfidence = 78
|
||||||
c.RiskControl.MinRiskRewardRatio = 3.0
|
c.RiskControl.MinRiskRewardRatio = 3.0
|
||||||
|
|||||||
@@ -54,16 +54,16 @@ func TestCreateDefaultStrategiesUsesOneReadyToRunClaw402Preset(t *testing.T) {
|
|||||||
if trendCfg.CoinSource.SourceType != "vergex_signal" || trendCfg.CoinSource.VergexLimit != 10 || trendCfg.CoinSource.VergexMarketType != "all" {
|
if trendCfg.CoinSource.SourceType != "vergex_signal" || trendCfg.CoinSource.VergexLimit != 10 || trendCfg.CoinSource.VergexMarketType != "all" {
|
||||||
t.Fatalf("default strategy should use the Claw402/Vergex all-market signal ranking, got %+v", trendCfg.CoinSource)
|
t.Fatalf("default strategy should use the Claw402/Vergex all-market signal ranking, got %+v", trendCfg.CoinSource)
|
||||||
}
|
}
|
||||||
if trendCfg.CoinSource.UseAI500 || trendCfg.RiskControl.MaxPositions > 2 {
|
if trendCfg.CoinSource.UseAI500 || trendCfg.RiskControl.MaxPositions != 4 {
|
||||||
t.Fatalf("default strategy should be Claw402/Vergex native with at most two positions, got coin=%+v risk=%+v", trendCfg.CoinSource, trendCfg.RiskControl)
|
t.Fatalf("default strategy should be Claw402/Vergex native with a 4-position balanced book, got coin=%+v risk=%+v", trendCfg.CoinSource, trendCfg.RiskControl)
|
||||||
}
|
}
|
||||||
if trendCfg.RiskControl.BTCETHMaxLeverage != 10 || trendCfg.RiskControl.AltcoinMaxLeverage != 10 {
|
if trendCfg.RiskControl.BTCETHMaxLeverage != 20 || trendCfg.RiskControl.AltcoinMaxLeverage != 20 {
|
||||||
t.Fatalf("default strategy should use 10x leverage for all Claw402 opens, got risk=%+v", trendCfg.RiskControl)
|
t.Fatalf("default strategy should use 20x leverage for all Claw402 opens, got risk=%+v", trendCfg.RiskControl)
|
||||||
}
|
}
|
||||||
if trendCfg.RiskControl.BTCETHMaxPositionValueRatio != 4 ||
|
if trendCfg.RiskControl.BTCETHMaxPositionValueRatio != 5 ||
|
||||||
trendCfg.RiskControl.AltcoinMaxPositionValueRatio != 4 ||
|
trendCfg.RiskControl.AltcoinMaxPositionValueRatio != 5 ||
|
||||||
trendCfg.RiskControl.MaxMarginUsage != 1.0 {
|
trendCfg.RiskControl.MaxMarginUsage != 1.0 {
|
||||||
t.Fatalf("default strategy should size Claw402 opens at 4x equity notional (two positions ≈ 80%% margin at 10x), got risk=%+v", trendCfg.RiskControl)
|
t.Fatalf("default strategy should size Claw402 opens at 5x equity notional (4 positions = 20x total at 20x), got risk=%+v", trendCfg.RiskControl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ func TestBuildSystemPromptUsesVergexClaw402Prompt(t *testing.T) {
|
|||||||
if !strings.Contains(prompt, "Direction must be data-driven") {
|
if !strings.Contains(prompt, "Direction must be data-driven") {
|
||||||
t.Fatalf("prompt should explain that direction is data-driven, not long-only:\n%s", prompt)
|
t.Fatalf("prompt should explain that direction is data-driven, not long-only:\n%s", prompt)
|
||||||
}
|
}
|
||||||
if !strings.Contains(prompt, "every open position must use exactly 10x") {
|
if !strings.Contains(prompt, "every open position must use exactly 20x") {
|
||||||
t.Fatalf("prompt should force 10x leverage for Claw402 opens:\n%s", prompt)
|
t.Fatalf("prompt should force 20x leverage for Claw402 opens:\n%s", prompt)
|
||||||
}
|
}
|
||||||
if !strings.Contains(prompt, "use the full max notional per position") {
|
if !strings.Contains(prompt, "use the full max notional per position") {
|
||||||
t.Fatalf("prompt should force full-size Claw402 opens:\n%s", prompt)
|
t.Fatalf("prompt should force full-size Claw402 opens:\n%s", prompt)
|
||||||
|
|||||||
@@ -1014,11 +1014,11 @@ func GetDefaultStrategyConfig(lang string) StrategyConfig {
|
|||||||
PriceRankingLimit: 10,
|
PriceRankingLimit: 10,
|
||||||
},
|
},
|
||||||
RiskControl: RiskControlConfig{
|
RiskControl: RiskControlConfig{
|
||||||
MaxPositions: 2, // Concentrated book: two full-size positions (CODE ENFORCED)
|
MaxPositions: 4, // Room for ~2 long + 2 short (CODE ENFORCED)
|
||||||
BTCETHMaxLeverage: 10, // BTC/ETH exchange leverage (AI guided)
|
BTCETHMaxLeverage: 20, // BTC/ETH exchange leverage (AI guided)
|
||||||
AltcoinMaxLeverage: 10, // TradeFi exchange leverage (AI guided)
|
AltcoinMaxLeverage: 20, // TradeFi exchange leverage (AI guided)
|
||||||
BTCETHMaxPositionValueRatio: 4.0, // Per-position notional = equity × 4; at 10x two positions ≈ 80% margin
|
BTCETHMaxPositionValueRatio: 5.0, // Per-position notional = equity × 5; 4 positions = 20x total (full margin at 20x)
|
||||||
AltcoinMaxPositionValueRatio: 4.0, // Per-position notional = equity × 4; at 10x two positions ≈ 80% margin
|
AltcoinMaxPositionValueRatio: 5.0, // Per-position notional = equity × 5; 4 positions = 20x total (full margin at 20x)
|
||||||
MaxMarginUsage: 1.0, // Claw402 Autopilot intentionally uses full margin when opening
|
MaxMarginUsage: 1.0, // Claw402 Autopilot intentionally uses full margin when opening
|
||||||
MinPositionSize: 12, // Min 12 USDT per position (CODE ENFORCED)
|
MinPositionSize: 12, // Min 12 USDT per position (CODE ENFORCED)
|
||||||
MinRiskRewardRatio: 3.0, // Min 3:1 profit/loss ratio (AI guided)
|
MinRiskRewardRatio: 3.0, // Min 3:1 profit/loss ratio (AI guided)
|
||||||
|
|||||||
@@ -1388,13 +1388,14 @@ export function StrategyStudioPage() {
|
|||||||
}),
|
}),
|
||||||
risk_control: defaultRisk({
|
risk_control: defaultRisk({
|
||||||
...base.ai_config?.risk_control,
|
...base.ai_config?.risk_control,
|
||||||
max_positions: 2,
|
max_positions: 4,
|
||||||
btc_eth_max_leverage: 10,
|
btc_eth_max_leverage: 20,
|
||||||
altcoin_max_leverage: 10,
|
altcoin_max_leverage: 20,
|
||||||
// 4× equity notional per position — at 10x leverage two full
|
// 5× equity notional per position — 4 positions = 20x total account
|
||||||
// positions use ~80% of margin (concentrated but solvent)
|
// notional (full margin at 20x). Bigger single positions, room for
|
||||||
btc_eth_max_position_value_ratio: 4,
|
// a balanced long/short book.
|
||||||
altcoin_max_position_value_ratio: 4,
|
btc_eth_max_position_value_ratio: 5,
|
||||||
|
altcoin_max_position_value_ratio: 5,
|
||||||
max_margin_usage: 1.0,
|
max_margin_usage: 1.0,
|
||||||
min_confidence: 78,
|
min_confidence: 78,
|
||||||
min_risk_reward_ratio: 3,
|
min_risk_reward_ratio: 3,
|
||||||
|
|||||||
Reference in New Issue
Block a user