From 36365a3b30e6da72e9a3b4f6ca6a115fed08dec6 Mon Sep 17 00:00:00 2001 From: 0xYYBB | ZYY | Bobo <128128010+zhouyongyou@users.noreply.github.com> Date: Fri, 7 Nov 2025 09:19:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(prompts):=20reduce=20margin=20usage=20from?= =?UTF-8?q?=2095%=20to=2088%=20for=20Hyperliquid=20liquidation=20buffer=20?= =?UTF-8?q?(#666)=20##=20Problem=20Users=20with=20small=20accounts=20(<$20?= =?UTF-8?q?0)=20encounter=20Hyperliquid=20error:=20"Insufficient=20margin?= =?UTF-8?q?=20to=20place=20order.=20asset=3D1"=20Real=20case:=20$98.89=20a?= =?UTF-8?q?ccount=20failed=20to=20open=20position=20##=20Root=20Cause=205%?= =?UTF-8?q?=20reserve=20insufficient=20for:=20-=20Trading=20fees=20(~0.04%?= =?UTF-8?q?)=20-=20Slippage=20(0.01-0.1%)=20-=20Liquidation=20margin=20buf?= =?UTF-8?q?fer=20(Hyperliquid=20requirement)=20Additionally,=20undefined?= =?UTF-8?q?=20"Allocation=20%"=20parameter=20caused=20confusion.=20##=20So?= =?UTF-8?q?lution=201.=20Reduce=20margin=20usage=20rate=20from=2095%=20to?= =?UTF-8?q?=2088%=20(reserve=2012%)=202.=20Remove=20undefined=20"Allocatio?= =?UTF-8?q?n=20%"=20parameter=203.=20Add=20small=20account=20example=20($9?= =?UTF-8?q?8.89)=20for=20clarity=20##=20Example=20($98.89=20account)=20Bef?= =?UTF-8?q?ore:=20$93.95=20margin=20=E2=86=92=20$4.75=20remaining=20?= =?UTF-8?q?=E2=9D=8C=20After:=20=20$87.02=20margin=20=E2=86=92=20$11.87=20?= =?UTF-8?q?remaining=20=E2=9C=85=20##=20Modified=20Files=20-=20prompts/ada?= =?UTF-8?q?ptive.txt=20-=20prompts/default.txt=20-=20prompts/nof1.txt=20##?= =?UTF-8?q?=20Testing=20Verified=20with=20$98.89=20account=20on=20z-dev=20?= =?UTF-8?q?branch=20-=20successful=20order=20placement=20Fixes=20#549?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prompts/adaptive.txt | 15 ++++++++++----- prompts/default.txt | 10 +++++----- prompts/nof1.txt | 10 +++++----- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/prompts/adaptive.txt b/prompts/adaptive.txt index a61c271d..bd640852 100644 --- a/prompts/adaptive.txt +++ b/prompts/adaptive.txt @@ -345,15 +345,20 @@ **重要**:position_size_usd 是**名义价值**(包含杠杆),非保证金需求。 **计算步骤**: -1. **可用保证金** = Available Cash × 0.95 × Allocation %(预留5%给手续费) +1. **可用保证金** = Available Cash × 0.88(预留12%给手续费、滑点与清算保证金缓冲) 2. **名义价值** = 可用保证金 × Leverage 3. **position_size_usd** = 名义价值(这是 JSON 中应填写的值) 4. **Position Size (Coins)** = position_size_usd / Current Price -**示例**:Available Cash = $500, Leverage = 5x, Allocation = 100% -- 可用保证金 = $500 × 0.95 × 100% = $475 -- position_size_usd = $475 × 5 = **$2,375** ← JSON 中填写此值 -- 实际占用保证金 = $475,剩余 $25 用于手续费 +**示例**:Available Cash = $500, Leverage = 5x +- 可用保证金 = $500 × 0.88 = $440 +- position_size_usd = $440 × 5 = **$2,200** ← JSON 中填写此值 +- 实际占用保证金 = $440,剩余 $60 用于手续费、滑点与清算保护 + +**示例2(小账户)**:Available Cash = $98.89, Leverage = 5x +- 可用保证金 = $98.89 × 0.88 = $87.02 +- position_size_usd = $87.02 × 5 = **$435.10** ← JSON 中填写此值 +- 实际占用保证金 = $87.02,剩余 $11.87 用于手续费、滑点与清算保护 ## 杠杆选择指引 diff --git a/prompts/default.txt b/prompts/default.txt index 3094e473..ff01a508 100644 --- a/prompts/default.txt +++ b/prompts/default.txt @@ -111,15 +111,15 @@ **重要**:`position_size_usd` 是**名义价值**(包含杠杆),非保证金需求。 **计算步骤**: -1. **可用保证金** = Available Cash × 0.95 × 配置比例(预留5%手续费) +1. **可用保证金** = Available Cash × 0.88(预留12%给手续费、滑点与清算保证金缓冲) 2. **名义价值** = 可用保证金 × Leverage 3. **position_size_usd** = 名义价值(JSON中填写此值) 4. **实际币数** = position_size_usd / Current Price -**示例**:可用资金 $500,杠杆 5x,配置 100% -- 可用保证金 = $500 × 0.95 = $475 -- position_size_usd = $475 × 5 = **$2,375** ← JSON填此值 -- 实际占用保证金 = $475,剩余 $25 用于手续费 +**示例**:可用资金 $500,杠杆 5x +- 可用保证金 = $500 × 0.88 = $440 +- position_size_usd = $440 × 5 = **$2,200** ← JSON填此值 +- 实际占用保证金 = $440,剩余 $60 用于手续费、滑点与清算保护 --- diff --git a/prompts/nof1.txt b/prompts/nof1.txt index 6b7df707..508f7431 100644 --- a/prompts/nof1.txt +++ b/prompts/nof1.txt @@ -55,15 +55,15 @@ You have exactly SIX possible actions per decision cycle: ## Calculation Steps: -1. **Available Margin** = Available Cash × 0.95 × Allocation % (reserve 5% for fees) +1. **Available Margin** = Available Cash × 0.88 (reserve 12% for fees, slippage & liquidation margin buffer) 2. **Notional Value** = Available Margin × Leverage 3. **position_size_usd** = Notional Value (this is the value for JSON) 4. **Position Size (Coins)** = position_size_usd / Current Price -**Example**: Available Cash = $500, Leverage = 5x, Allocation = 100% -- Available Margin = $500 × 0.95 × 100% = $475 -- position_size_usd = $475 × 5 = **$2,375** ← Fill this value in JSON -- Actual margin used = $475, remaining $25 for fees +**Example**: Available Cash = $500, Leverage = 5x +- Available Margin = $500 × 0.88 = $440 +- position_size_usd = $440 × 5 = **$2,200** ← Fill this value in JSON +- Actual margin used = $440, remaining $60 for fees, slippage & liquidation protection ## Sizing Considerations