feat: 添加最大仓位限制配置功能

后端变更:
- 添加最大仓位金额(maxPositionValue)和最大仓位数量(maxPositionCount)配置字段
- 实现按市场检查仓位限制的过滤逻辑
- 添加数据库迁移脚本 V11__add_max_position_config.sql

前端变更:
- 重构账户导入和Leader添加为可复用组件(AccountImportForm, LeaderAddForm)
- 在CopyTradingAdd页面集成账户导入和Leader添加Modal
- 在CopyTradingAdd/CopyTradingEdit页面添加最大仓位限制配置项
- 补充所有多语言文件中的缺失键,确保zh-CN/zh-TW/en三种语言文件一致

功能说明:
- 支持设置单个市场的最大仓位金额限制(USDC)
- 支持设置单个市场的最大仓位数量限制
- 两个限制可以同时启用,下单前会检查当前市场仓位是否超过限制
This commit is contained in:
WrBug
2025-12-23 00:56:04 +08:00
parent 20acc72ed6
commit c20e0138df
18 changed files with 1077 additions and 429 deletions
+31 -2
View File
@@ -65,7 +65,8 @@
"updateSuccess": "Account updated successfully",
"updateFailed": "Failed to update account",
"getDetailFailed": "Failed to get account details",
"accountIdRequired": "Account ID cannot be empty"
"accountIdRequired": "Account ID cannot be empty",
"proxyAddress": "Proxy Wallet Address"
},
"message": {
"success": "Operation successful",
@@ -426,6 +427,7 @@
},
"leaderAdd": {
"title": "Add Leader",
"back": "Back",
"leaderAddress": "Leader Wallet Address",
"leaderAddressRequired": "Please enter Leader wallet address",
"leaderAddressInvalid": "Invalid wallet address format (must be a 42-character address starting with 0x)",
@@ -667,6 +669,13 @@
"priceRangeTooltip": "Only copy orders where Leader's trade price is within the specified range. Leave empty to disable. Examples: Fill 0.11 and 0.89 means only copy orders with price between 0.11 and 0.89; Fill only max price 0.89 means only copy orders with price below 0.89; Fill only min price 0.11 means only copy orders with price above 0.11.",
"minPricePlaceholder": "Min Price (leave empty for no limit)",
"maxPricePlaceholder": "Max Price (leave empty for no limit)",
"positionLimitFilter": "Max Position Limit",
"maxPositionValue": "Max Position Value (USDC)",
"maxPositionValueTooltip": "Limit the maximum position value for a single market. If the current position value + copy order amount exceeds this limit, the order will not be placed. Leave empty to disable",
"maxPositionValuePlaceholder": "For example: 100 (optional, leave empty to disable)",
"maxPositionCount": "Max Position Count",
"maxPositionCountTooltip": "Limit the maximum position count for a single market. If the current position count reaches or exceeds this limit, the order will not be placed. Leave empty to disable",
"maxPositionCountPlaceholder": "For example: 10 (optional, leave empty to disable)",
"supportSell": "Support Sell",
"supportSellTooltip": "Whether to copy Leader's sell orders. Enabled: copy both Leader's buy and sell orders; Disabled: only copy Leader's buy orders, ignore sell orders.",
"invalidNumber": "Please enter a valid number"
@@ -732,6 +741,13 @@
"priceRangeTooltip": "Only copy orders where Leader's trade price is within the specified range. Leave empty to disable. Examples: Fill 0.11 and 0.89 means only copy orders with price between 0.11 and 0.89; Fill only max price 0.89 means only copy orders with price below 0.89; Fill only min price 0.11 means only copy orders with price above 0.11.",
"minPricePlaceholder": "Min Price (leave empty for no limit)",
"maxPricePlaceholder": "Max Price (leave empty for no limit)",
"positionLimitFilter": "Max Position Limit",
"maxPositionValue": "Max Position Value (USDC)",
"maxPositionValueTooltip": "Limit the maximum position value for a single market. If the current position value + copy order amount exceeds this limit, the order will not be placed. Leave empty to disable",
"maxPositionValuePlaceholder": "For example: 100 (optional, leave empty to disable)",
"maxPositionCount": "Max Position Count",
"maxPositionCountTooltip": "Limit the maximum position count for a single market. If the current position count reaches or exceeds this limit, the order will not be placed. Leave empty to disable",
"maxPositionCountPlaceholder": "For example: 10 (optional, leave empty to disable)",
"configName": "Configuration Name",
"configNameRequired": "Please enter configuration name",
"configNamePlaceholder": "e.g., Copy Trading Config 1",
@@ -752,7 +768,11 @@
"invalidNumber": "Please enter a valid number",
"fetchLeaderFailed": "Failed to get Leader list",
"fetchTemplateFailed": "Failed to get template list",
"templateName": "Template Name"
"templateName": "Template Name",
"noAccounts": "No accounts",
"importAccount": "Import Account",
"noLeaders": "No Leaders",
"addLeader": "Add Leader"
},
"copyTradingEdit": {
"title": "Edit Copy Trading Config",
@@ -807,6 +827,13 @@
"priceRangeTooltip": "Only copy orders where Leader's trade price is within the specified range. Leave empty to disable. Examples: Fill 0.11 and 0.89 means only copy orders with price between 0.11 and 0.89; Fill only max price 0.89 means only copy orders with price below 0.89; Fill only min price 0.11 means only copy orders with price above 0.11.",
"minPricePlaceholder": "Min Price (leave empty for no limit)",
"maxPricePlaceholder": "Max Price (leave empty for no limit)",
"positionLimitFilter": "Max Position Limit",
"maxPositionValue": "Max Position Value (USDC)",
"maxPositionValueTooltip": "Limit the maximum position value for a single market. If the current position value + copy order amount exceeds this limit, the order will not be placed. Leave empty to disable",
"maxPositionValuePlaceholder": "For example: 100 (optional, leave empty to disable)",
"maxPositionCount": "Max Position Count",
"maxPositionCountTooltip": "Limit the maximum position count for a single market. If the current position count reaches or exceeds this limit, the order will not be placed. Leave empty to disable",
"maxPositionCountPlaceholder": "For example: 10 (optional, leave empty to disable)",
"configName": "Configuration Name",
"configNameRequired": "Please enter configuration name",
"configNamePlaceholder": "e.g., Copy Trading Config 1",
@@ -849,6 +876,8 @@
"orderbookError": "Orderbook Fetch Failed",
"orderbookEmpty": "Orderbook Empty",
"priceRange": "Price Range Mismatch",
"maxPositionValue": "Exceeds Max Position Value",
"maxPositionCount": "Exceeds Max Position Count",
"unknown": "Unknown Reason"
},
"noData": "No filtered orders"
+99 -6
View File
@@ -27,7 +27,10 @@
"total": "共",
"items": "条",
"prev": "上一页",
"next": "下一页"
"next": "下一页",
"success": "成功",
"failed": "失败",
"close": "关闭"
},
"login": {
"title": "登录",
@@ -45,7 +48,13 @@
"success": "操作成功",
"error": "操作失败",
"loading": "加载中...",
"noData": "暂无数据"
"noData": "暂无数据",
"loginSuccess": "登录成功",
"loginFailed": "登录失败",
"createUserSuccess": "创建用户成功",
"createUserFailed": "创建用户失败",
"updatePasswordSuccess": "更新密码成功",
"updatePasswordFailed": "更新密码失败"
},
"order": {
"create": "创建订单",
@@ -53,7 +62,47 @@
"cancel": "取消订单",
"event": "订单事件",
"buy": "买入",
"sell": "卖出"
"sell": "卖出",
"market": "市场",
"status": "状态",
"filled": "已成交",
"remaining": "剩余"
},
"account": {
"title": "账户管理",
"list": "账户列表",
"detail": "账户详情",
"import": "导入账户",
"update": "更新账户",
"delete": "删除账户",
"accountId": "账户ID",
"accountName": "账户名称",
"accountNamePlaceholder": "账户名称(可选)",
"accountIdRequired": "账户ID不能为空",
"walletAddress": "钱包地址",
"proxyAddress": "代理钱包地址",
"apiCredentials": "API 凭证",
"apiKey": "API Key",
"apiSecret": "API Secret",
"apiPassphrase": "API Passphrase",
"balance": "余额",
"activeOrders": "活跃订单",
"completedOrders": "已完成订单",
"positionCount": "持仓数量",
"totalOrders": "总订单数",
"totalPnl": "总盈亏",
"statistics": "交易统计",
"fullConfig": "完整配置",
"partialConfig": "部分配置",
"notConfigured": "未配置",
"configured": "已配置",
"editTip": "编辑提示",
"editTipDesc": "API 凭证字段留空表示不修改。如需更新 API 凭证,请输入新值;如需保持原值不变,请留空。",
"leaveEmptyToNotModify": "留空表示不修改",
"getDetailFailed": "获取账户详情失败",
"updateSuccess": "更新账户成功",
"updateFailed": "更新账户失败",
"refreshBalance": "刷新余额"
},
"accountList": {
"title": "账户管理",
@@ -156,10 +205,24 @@
"title": "Leader 管理",
"leaderName": "Leader 名称",
"leaderAddress": "钱包地址",
"walletAddress": "钱包地址",
"category": "分类",
"all": "全部",
"copyTradingCount": "跟单关系数",
"createdAt": "创建时间",
"action": "操作",
"add": "添加",
"addLeader": "添加 Leader",
"edit": "编辑",
"editLeader": "编辑 Leader",
"deleteLeader": "删除 Leader"
"delete": "删除",
"deleteLeader": "删除 Leader",
"listFailed": "获取 Leader 列表失败",
"deleteSuccess": "删除 Leader 成功",
"deleteFailed": "删除 Leader 失败",
"deleteConfirm": "确定要删除这个 Leader 吗?",
"deleteConfirmDesc": "删除后无法恢复,请谨慎操作!",
"deleteConfirmOk": "确定删除"
},
"menu": {
"accounts": "账户管理",
@@ -218,7 +281,9 @@
"saveSuccess": "保存配置成功",
"saveFailed": "保存配置失败",
"getFailed": "获取代理配置失败",
"latency": "延迟"
"latency": "延迟",
"hostInvalid": "请输入有效的主机地址",
"portInvalid": "端口必须在 1-65535 之间"
},
"languageSettings": {
"title": "语言设置",
@@ -362,6 +427,7 @@
},
"leaderAdd": {
"title": "添加 Leader",
"back": "返回",
"leaderAddress": "Leader 钱包地址",
"leaderAddressRequired": "请输入 Leader 钱包地址",
"leaderAddressInvalid": "钱包地址格式不正确(必须是 0x 开头的 42 位地址)",
@@ -603,6 +669,13 @@
"priceRangeTooltip": "仅跟单 Leader 交易价格在指定区间内的订单。不填写表示不限制。示例:填写 0.11 和 0.89 表示仅跟单价格在 0.11 到 0.89 之间的订单;只填写最高价 0.89 表示仅跟单价格在 0.89 以下的订单;只填写最低价 0.11 表示仅跟单价格在 0.11 以上的订单。",
"minPricePlaceholder": "最低价(留空不限制)",
"maxPricePlaceholder": "最高价(留空不限制)",
"positionLimitFilter": "最大仓位限制",
"maxPositionValue": "最大仓位金额 (USDC)",
"maxPositionValueTooltip": "限制单个市场的最大仓位金额。如果该市场的当前仓位金额 + 跟单金额超过此限制,则不会下单。不填写则不启用此限制",
"maxPositionValuePlaceholder": "例如:100(可选,不填写表示不启用)",
"maxPositionCount": "最大仓位数量",
"maxPositionCountTooltip": "限制单个市场的最大仓位数量。如果该市场的当前仓位数量达到或超过此限制,则不会下单。不填写则不启用此限制",
"maxPositionCountPlaceholder": "例如:10(可选,不填写表示不启用)",
"supportSell": "跟单卖出",
"supportSellTooltip": "是否跟单 Leader 的卖出订单。开启:跟单 Leader 的买入和卖出订单;关闭:只跟单 Leader 的买入订单,忽略卖出订单。",
"invalidNumber": "请输入有效的数字"
@@ -680,6 +753,13 @@
"priceRangeTooltip": "仅跟单 Leader 交易价格在指定区间内的订单。不填写表示不限制。示例:填写 0.11 和 0.89 表示仅跟单价格在 0.11 到 0.89 之间的订单;只填写最高价 0.89 表示仅跟单价格在 0.89 以下的订单;只填写最低价 0.11 表示仅跟单价格在 0.11 以上的订单。",
"minPricePlaceholder": "最低价(留空不限制)",
"maxPricePlaceholder": "最高价(留空不限制)",
"positionLimitFilter": "最大仓位限制",
"maxPositionValue": "最大仓位金额 (USDC)",
"maxPositionValueTooltip": "限制单个市场的最大仓位金额。如果该市场的当前仓位金额 + 跟单金额超过此限制,则不会下单。不填写则不启用此限制",
"maxPositionValuePlaceholder": "例如:100(可选,不填写表示不启用)",
"maxPositionCount": "最大仓位数量",
"maxPositionCountTooltip": "限制单个市场的最大仓位数量。如果该市场的当前仓位数量达到或超过此限制,则不会下单。不填写则不启用此限制",
"maxPositionCountPlaceholder": "例如:10(可选,不填写表示不启用)",
"supportSell": "跟单卖出",
"supportSellTooltip": "是否跟单 Leader 的卖出订单",
"create": "创建跟单配置",
@@ -688,7 +768,11 @@
"invalidNumber": "请输入有效的数字",
"fetchLeaderFailed": "获取 Leader 列表失败",
"fetchTemplateFailed": "获取模板列表失败",
"templateName": "模板名称"
"templateName": "模板名称",
"noAccounts": "暂无账户",
"importAccount": "导入账户",
"noLeaders": "暂无 Leader",
"addLeader": "添加 Leader"
},
"copyTradingEdit": {
"title": "编辑跟单配置",
@@ -755,6 +839,13 @@
"priceRangeTooltip": "仅跟单 Leader 交易价格在指定区间内的订单。不填写表示不限制。示例:填写 0.11 和 0.89 表示仅跟单价格在 0.11 到 0.89 之间的订单;只填写最高价 0.89 表示仅跟单价格在 0.89 以下的订单;只填写最低价 0.11 表示仅跟单价格在 0.11 以上的订单。",
"minPricePlaceholder": "最低价(留空不限制)",
"maxPricePlaceholder": "最高价(留空不限制)",
"positionLimitFilter": "最大仓位限制",
"maxPositionValue": "最大仓位金额 (USDC)",
"maxPositionValueTooltip": "限制单个市场的最大仓位金额。如果该市场的当前仓位金额 + 跟单金额超过此限制,则不会下单。不填写则不启用此限制",
"maxPositionValuePlaceholder": "例如:100(可选,不填写表示不启用)",
"maxPositionCount": "最大仓位数量",
"maxPositionCountTooltip": "限制单个市场的最大仓位数量。如果该市场的当前仓位数量达到或超过此限制,则不会下单。不填写则不启用此限制",
"maxPositionCountPlaceholder": "例如:10(可选,不填写表示不启用)",
"supportSell": "跟单卖出",
"supportSellTooltip": "是否跟单 Leader 的卖出订单",
"save": "保存",
@@ -785,6 +876,8 @@
"orderbookError": "订单簿获取失败",
"orderbookEmpty": "订单簿为空",
"priceRange": "价格区间不符",
"maxPositionValue": "超过最大仓位金额",
"maxPositionCount": "超过最大仓位数量",
"unknown": "未知原因"
},
"noData": "暂无已过滤订单"
+31 -2
View File
@@ -65,7 +65,8 @@
"updateSuccess": "更新賬戶成功",
"updateFailed": "更新賬戶失敗",
"getDetailFailed": "獲取賬戶詳情失敗",
"accountIdRequired": "賬戶ID不能為空"
"accountIdRequired": "賬戶ID不能為空",
"proxyAddress": "代理錢包地址"
},
"message": {
"success": "操作成功",
@@ -426,6 +427,7 @@
},
"leaderAdd": {
"title": "添加 Leader",
"back": "返回",
"leaderAddress": "Leader 錢包地址",
"leaderAddressRequired": "請輸入 Leader 錢包地址",
"leaderAddressInvalid": "錢包地址格式不正確(必須是 0x 開頭的 42 位地址)",
@@ -667,6 +669,13 @@
"priceRangeTooltip": "僅跟單 Leader 交易價格在指定區間內的訂單。不填寫表示不限制。示例:填寫 0.11 和 0.89 表示僅跟單價格在 0.11 到 0.89 之間的訂單;只填寫最高價 0.89 表示僅跟單價格在 0.89 以下的訂單;只填寫最低價 0.11 表示僅跟單價格在 0.11 以上的訂單。",
"minPricePlaceholder": "最低價(留空不限制)",
"maxPricePlaceholder": "最高價(留空不限制)",
"positionLimitFilter": "最大倉位限制",
"maxPositionValue": "最大倉位金額 (USDC)",
"maxPositionValueTooltip": "限制單個市場的最大倉位金額。如果該市場的當前倉位金額 + 跟單金額超過此限制,則不會下單。不填寫則不啟用此限制",
"maxPositionValuePlaceholder": "例如:100(可選,不填寫表示不啟用)",
"maxPositionCount": "最大倉位數量",
"maxPositionCountTooltip": "限制單個市場的最大倉位數量。如果該市場的當前倉位數量達到或超過此限制,則不會下單。不填寫則不啟用此限制",
"maxPositionCountPlaceholder": "例如:10(可選,不填寫表示不啟用)",
"supportSell": "跟單賣出",
"supportSellTooltip": "是否跟單 Leader 的賣出訂單。開啟:跟單 Leader 的買入和賣出訂單;關閉:只跟單 Leader 的買入訂單,忽略賣出訂單。",
"invalidNumber": "請輸入有效的數字"
@@ -732,6 +741,13 @@
"priceRangeTooltip": "僅跟單 Leader 交易價格在指定區間內的訂單。不填寫表示不限制。示例:填寫 0.11 和 0.89 表示僅跟單價格在 0.11 到 0.89 之間的訂單;只填寫最高價 0.89 表示僅跟單價格在 0.89 以下的訂單;只填寫最低價 0.11 表示僅跟單價格在 0.11 以上的訂單。",
"minPricePlaceholder": "最低價(留空不限制)",
"maxPricePlaceholder": "最高價(留空不限制)",
"positionLimitFilter": "最大倉位限制",
"maxPositionValue": "最大倉位金額 (USDC)",
"maxPositionValueTooltip": "限制單個市場的最大倉位金額。如果該市場的當前倉位金額 + 跟單金額超過此限制,則不會下單。不填寫則不啟用此限制",
"maxPositionValuePlaceholder": "例如:100(可選,不填寫表示不啟用)",
"maxPositionCount": "最大倉位數量",
"maxPositionCountTooltip": "限制單個市場的最大倉位數量。如果該市場的當前倉位數量達到或超過此限制,則不會下單。不填寫則不啟用此限制",
"maxPositionCountPlaceholder": "例如:10(可選,不填寫表示不啟用)",
"configName": "配置名",
"configNameRequired": "請輸入配置名",
"configNamePlaceholder": "例如:跟單配置1",
@@ -752,7 +768,11 @@
"invalidNumber": "請輸入有效的數字",
"fetchLeaderFailed": "獲取 Leader 列表失敗",
"fetchTemplateFailed": "獲取模板列表失敗",
"templateName": "模板名稱"
"templateName": "模板名稱",
"noAccounts": "暫無賬戶",
"importAccount": "導入賬戶",
"noLeaders": "暫無 Leader",
"addLeader": "添加 Leader"
},
"copyTradingEdit": {
"title": "編輯跟單配置",
@@ -807,6 +827,13 @@
"priceRangeTooltip": "僅跟單 Leader 交易價格在指定區間內的訂單。不填寫表示不限制。示例:填寫 0.11 和 0.89 表示僅跟單價格在 0.11 到 0.89 之間的訂單;只填寫最高價 0.89 表示僅跟單價格在 0.89 以下的訂單;只填寫最低價 0.11 表示僅跟單價格在 0.11 以上的訂單。",
"minPricePlaceholder": "最低價(留空不限制)",
"maxPricePlaceholder": "最高價(留空不限制)",
"positionLimitFilter": "最大倉位限制",
"maxPositionValue": "最大倉位金額 (USDC)",
"maxPositionValueTooltip": "限制單個市場的最大倉位金額。如果該市場的當前倉位金額 + 跟單金額超過此限制,則不會下單。不填寫則不啟用此限制",
"maxPositionValuePlaceholder": "例如:100(可選,不填寫表示不啟用)",
"maxPositionCount": "最大倉位數量",
"maxPositionCountTooltip": "限制單個市場的最大倉位數量。如果該市場的當前倉位數量達到或超過此限制,則不會下單。不填寫則不啟用此限制",
"maxPositionCountPlaceholder": "例如:10(可選,不填寫表示不啟用)",
"configName": "配置名",
"configNameRequired": "請輸入配置名",
"configNamePlaceholder": "例如:跟單配置1",
@@ -849,6 +876,8 @@
"orderbookError": "訂單簿獲取失敗",
"orderbookEmpty": "訂單簿為空",
"priceRange": "價格區間不符",
"maxPositionValue": "超過最大倉位金額",
"maxPositionCount": "超過最大倉位數量",
"unknown": "未知原因"
},
"noData": "暫無已過濾訂單"