2025-12-01 23:03:17 +08:00
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
|
|
import { useNavigate } from 'react-router-dom'
|
2025-12-05 23:52:49 +08:00
|
|
|
|
import { Card, Form, Button, Switch, message, Typography, Space, Radio, InputNumber, Modal, Table, Select, Divider, Input } from 'antd'
|
2025-12-05 05:18:20 +08:00
|
|
|
|
import { ArrowLeftOutlined, SaveOutlined, FileTextOutlined } from '@ant-design/icons'
|
2025-12-01 23:03:17 +08:00
|
|
|
|
import { apiService } from '../services/api'
|
|
|
|
|
|
import { useAccountStore } from '../store/accountStore'
|
2025-12-05 05:18:20 +08:00
|
|
|
|
import type { Leader, CopyTradingTemplate, CopyTradingCreateRequest } from '../types'
|
2025-12-01 23:22:18 +08:00
|
|
|
|
import { formatUSDC } from '../utils'
|
2025-12-05 05:18:20 +08:00
|
|
|
|
import { useTranslation } from 'react-i18next'
|
2025-12-01 23:03:17 +08:00
|
|
|
|
|
|
|
|
|
|
const { Title } = Typography
|
|
|
|
|
|
const { Option } = Select
|
|
|
|
|
|
|
|
|
|
|
|
const CopyTradingAdd: React.FC = () => {
|
2025-12-05 05:18:20 +08:00
|
|
|
|
const { t } = useTranslation()
|
2025-12-01 23:03:17 +08:00
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
const { accounts, fetchAccounts } = useAccountStore()
|
|
|
|
|
|
const [form] = Form.useForm()
|
|
|
|
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
|
|
const [leaders, setLeaders] = useState<Leader[]>([])
|
|
|
|
|
|
const [templates, setTemplates] = useState<CopyTradingTemplate[]>([])
|
2025-12-05 05:18:20 +08:00
|
|
|
|
const [templateModalVisible, setTemplateModalVisible] = useState(false)
|
|
|
|
|
|
const [copyMode, setCopyMode] = useState<'RATIO' | 'FIXED'>('RATIO')
|
2025-12-01 23:03:17 +08:00
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
fetchAccounts()
|
|
|
|
|
|
fetchLeaders()
|
|
|
|
|
|
fetchTemplates()
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
|
|
const fetchLeaders = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await apiService.leaders.list({})
|
|
|
|
|
|
if (response.data.code === 0 && response.data.data) {
|
|
|
|
|
|
setLeaders(response.data.data.list || [])
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error: any) {
|
2025-12-05 05:18:20 +08:00
|
|
|
|
message.error(error.message || t('copyTradingAdd.fetchLeaderFailed') || '获取 Leader 列表失败')
|
2025-12-01 23:03:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const fetchTemplates = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await apiService.templates.list()
|
|
|
|
|
|
if (response.data.code === 0 && response.data.data) {
|
|
|
|
|
|
setTemplates(response.data.data.list || [])
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error: any) {
|
2025-12-05 05:18:20 +08:00
|
|
|
|
message.error(error.message || t('copyTradingAdd.fetchTemplateFailed') || '获取模板列表失败')
|
2025-12-01 23:03:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-05 05:18:20 +08:00
|
|
|
|
const handleSelectTemplate = (template: CopyTradingTemplate) => {
|
|
|
|
|
|
// 填充模板数据到表单(只填充模板中存在的字段)
|
|
|
|
|
|
form.setFieldsValue({
|
|
|
|
|
|
copyMode: template.copyMode,
|
|
|
|
|
|
copyRatio: template.copyRatio ? parseFloat(template.copyRatio) * 100 : 100, // 转换为百分比显示
|
|
|
|
|
|
fixedAmount: template.fixedAmount ? parseFloat(template.fixedAmount) : undefined,
|
|
|
|
|
|
maxOrderSize: template.maxOrderSize ? parseFloat(template.maxOrderSize) : undefined,
|
|
|
|
|
|
minOrderSize: template.minOrderSize ? parseFloat(template.minOrderSize) : undefined,
|
|
|
|
|
|
maxDailyOrders: template.maxDailyOrders,
|
|
|
|
|
|
priceTolerance: template.priceTolerance ? parseFloat(template.priceTolerance) : undefined,
|
|
|
|
|
|
supportSell: template.supportSell,
|
|
|
|
|
|
minOrderDepth: template.minOrderDepth ? parseFloat(template.minOrderDepth) : undefined,
|
|
|
|
|
|
maxSpread: template.maxSpread ? parseFloat(template.maxSpread) : undefined,
|
2025-12-05 23:52:49 +08:00
|
|
|
|
minOrderbookDepth: template.minOrderbookDepth ? parseFloat(template.minOrderbookDepth) : undefined,
|
|
|
|
|
|
minPrice: template.minPrice ? parseFloat(template.minPrice) : undefined,
|
|
|
|
|
|
maxPrice: template.maxPrice ? parseFloat(template.maxPrice) : undefined
|
2025-12-05 05:18:20 +08:00
|
|
|
|
})
|
|
|
|
|
|
setCopyMode(template.copyMode)
|
|
|
|
|
|
setTemplateModalVisible(false)
|
|
|
|
|
|
message.success(t('copyTradingAdd.templateFilled') || '模板内容已填充,您可以修改')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleCopyModeChange = (mode: 'RATIO' | 'FIXED') => {
|
|
|
|
|
|
setCopyMode(mode)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-01 23:03:17 +08:00
|
|
|
|
const handleSubmit = async (values: any) => {
|
2025-12-05 05:18:20 +08:00
|
|
|
|
// 前端校验
|
|
|
|
|
|
if (values.copyMode === 'FIXED') {
|
|
|
|
|
|
if (!values.fixedAmount || Number(values.fixedAmount) < 1) {
|
|
|
|
|
|
message.error(t('copyTradingAdd.fixedAmountMin') || '固定金额必须 >= 1')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (values.copyMode === 'RATIO' && values.minOrderSize !== undefined && values.minOrderSize !== null && Number(values.minOrderSize) < 1) {
|
|
|
|
|
|
message.error(t('copyTradingAdd.minOrderSizeMin') || '最小金额必须 >= 1')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-01 23:03:17 +08:00
|
|
|
|
setLoading(true)
|
|
|
|
|
|
try {
|
2025-12-05 05:18:20 +08:00
|
|
|
|
const request: CopyTradingCreateRequest = {
|
2025-12-01 23:03:17 +08:00
|
|
|
|
accountId: values.accountId,
|
|
|
|
|
|
leaderId: values.leaderId,
|
2025-12-05 05:18:20 +08:00
|
|
|
|
enabled: true, // 默认启用
|
|
|
|
|
|
copyMode: values.copyMode || 'RATIO',
|
|
|
|
|
|
copyRatio: values.copyMode === 'RATIO' && values.copyRatio ? (values.copyRatio / 100).toString() : undefined,
|
|
|
|
|
|
fixedAmount: values.copyMode === 'FIXED' ? values.fixedAmount?.toString() : undefined,
|
|
|
|
|
|
maxOrderSize: values.maxOrderSize?.toString(),
|
|
|
|
|
|
minOrderSize: values.minOrderSize?.toString(),
|
|
|
|
|
|
maxDailyLoss: values.maxDailyLoss?.toString(),
|
|
|
|
|
|
maxDailyOrders: values.maxDailyOrders,
|
|
|
|
|
|
priceTolerance: values.priceTolerance?.toString(),
|
|
|
|
|
|
delaySeconds: values.delaySeconds,
|
|
|
|
|
|
pollIntervalSeconds: values.pollIntervalSeconds,
|
|
|
|
|
|
useWebSocket: values.useWebSocket,
|
|
|
|
|
|
websocketReconnectInterval: values.websocketReconnectInterval,
|
|
|
|
|
|
websocketMaxRetries: values.websocketMaxRetries,
|
|
|
|
|
|
supportSell: values.supportSell !== false,
|
|
|
|
|
|
minOrderDepth: values.minOrderDepth?.toString(),
|
|
|
|
|
|
maxSpread: values.maxSpread?.toString(),
|
2025-12-05 23:52:49 +08:00
|
|
|
|
minOrderbookDepth: values.minOrderbookDepth?.toString(),
|
|
|
|
|
|
minPrice: values.minPrice?.toString(),
|
|
|
|
|
|
maxPrice: values.maxPrice?.toString()
|
2025-12-05 05:18:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const response = await apiService.copyTrading.create(request)
|
2025-12-01 23:03:17 +08:00
|
|
|
|
|
|
|
|
|
|
if (response.data.code === 0) {
|
2025-12-05 05:18:20 +08:00
|
|
|
|
message.success(t('copyTradingAdd.createSuccess') || '创建跟单配置成功')
|
2025-12-01 23:03:17 +08:00
|
|
|
|
navigate('/copy-trading')
|
|
|
|
|
|
} else {
|
2025-12-05 05:18:20 +08:00
|
|
|
|
message.error(response.data.msg || t('copyTradingAdd.createFailed') || '创建跟单配置失败')
|
2025-12-01 23:03:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (error: any) {
|
2025-12-05 05:18:20 +08:00
|
|
|
|
message.error(error.message || t('copyTradingAdd.createFailed') || '创建跟单配置失败')
|
2025-12-01 23:03:17 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
setLoading(false)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div style={{ marginBottom: 16 }}>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
icon={<ArrowLeftOutlined />}
|
|
|
|
|
|
onClick={() => navigate('/copy-trading')}
|
|
|
|
|
|
>
|
2025-12-05 05:18:20 +08:00
|
|
|
|
{t('common.back') || '返回'}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<Card>
|
2025-12-05 05:18:20 +08:00
|
|
|
|
<Title level={4}>{t('copyTradingAdd.title') || '新增跟单配置'}</Title>
|
2025-12-01 23:03:17 +08:00
|
|
|
|
|
|
|
|
|
|
<Form
|
|
|
|
|
|
form={form}
|
|
|
|
|
|
layout="vertical"
|
|
|
|
|
|
onFinish={handleSubmit}
|
|
|
|
|
|
initialValues={{
|
2025-12-05 05:18:20 +08:00
|
|
|
|
copyMode: 'RATIO',
|
|
|
|
|
|
copyRatio: 100,
|
|
|
|
|
|
maxOrderSize: 1000,
|
|
|
|
|
|
minOrderSize: 1,
|
|
|
|
|
|
maxDailyLoss: 10000,
|
|
|
|
|
|
maxDailyOrders: 100,
|
|
|
|
|
|
priceTolerance: 5,
|
|
|
|
|
|
delaySeconds: 0,
|
|
|
|
|
|
pollIntervalSeconds: 5,
|
|
|
|
|
|
useWebSocket: true,
|
|
|
|
|
|
websocketReconnectInterval: 5000,
|
|
|
|
|
|
websocketMaxRetries: 10,
|
|
|
|
|
|
supportSell: true
|
2025-12-01 23:03:17 +08:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
2025-12-05 05:18:20 +08:00
|
|
|
|
{/* 基础信息 */}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
<Form.Item
|
2025-12-05 05:18:20 +08:00
|
|
|
|
label={t('copyTradingAdd.selectWallet') || '选择钱包'}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
name="accountId"
|
2025-12-05 05:18:20 +08:00
|
|
|
|
rules={[{ required: true, message: t('copyTradingAdd.walletRequired') || '请选择钱包' }]}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
>
|
2025-12-05 05:18:20 +08:00
|
|
|
|
<Select placeholder={t('copyTradingAdd.selectWalletPlaceholder') || '请选择钱包'}>
|
2025-12-01 23:03:17 +08:00
|
|
|
|
{accounts.map(account => (
|
|
|
|
|
|
<Option key={account.id} value={account.id}>
|
|
|
|
|
|
{account.accountName || `账户 ${account.id}`} ({account.walletAddress.slice(0, 6)}...{account.walletAddress.slice(-4)})
|
|
|
|
|
|
</Option>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
2025-12-05 05:18:20 +08:00
|
|
|
|
label={t('copyTradingAdd.selectLeader') || '选择 Leader'}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
name="leaderId"
|
2025-12-05 05:18:20 +08:00
|
|
|
|
rules={[{ required: true, message: t('copyTradingAdd.leaderRequired') || '请选择 Leader' }]}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
>
|
2025-12-05 05:18:20 +08:00
|
|
|
|
<Select placeholder={t('copyTradingAdd.selectLeaderPlaceholder') || '请选择 Leader'}>
|
2025-12-01 23:03:17 +08:00
|
|
|
|
{leaders.map(leader => (
|
|
|
|
|
|
<Option key={leader.id} value={leader.id}>
|
|
|
|
|
|
{leader.leaderName || `Leader ${leader.id}`} ({leader.leaderAddress.slice(0, 6)}...{leader.leaderAddress.slice(-4)})
|
|
|
|
|
|
</Option>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
2025-12-05 05:18:20 +08:00
|
|
|
|
{/* 模板填充按钮 */}
|
|
|
|
|
|
<Form.Item>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="dashed"
|
|
|
|
|
|
icon={<FileTextOutlined />}
|
|
|
|
|
|
onClick={() => setTemplateModalVisible(true)}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('copyTradingAdd.selectTemplateFromModal') || '从模板填充配置'}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
{/* 跟单金额模式 */}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
<Form.Item
|
2025-12-05 05:18:20 +08:00
|
|
|
|
label={t('copyTradingAdd.copyMode') || '跟单金额模式'}
|
|
|
|
|
|
name="copyMode"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.copyModeTooltip') || '选择跟单金额的计算方式。比例模式:跟单金额随 Leader 订单大小按比例变化;固定金额模式:无论 Leader 订单大小如何,跟单金额都固定不变。'}
|
|
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Radio.Group onChange={(e) => handleCopyModeChange(e.target.value)}>
|
|
|
|
|
|
<Radio value="RATIO">{t('copyTradingAdd.ratioMode') || '比例模式'}</Radio>
|
|
|
|
|
|
<Radio value="FIXED">{t('copyTradingAdd.fixedAmountMode') || '固定金额模式'}</Radio>
|
|
|
|
|
|
</Radio.Group>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
{copyMode === 'RATIO' && (
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.copyRatio') || '跟单比例'}
|
|
|
|
|
|
name="copyRatio"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.copyRatioTooltip') || '跟单比例表示跟单金额相对于 Leader 订单金额的百分比。例如:100% 表示 1:1 跟单,50% 表示半仓跟单,200% 表示双倍跟单'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={10}
|
|
|
|
|
|
max={1000}
|
|
|
|
|
|
step={1}
|
|
|
|
|
|
precision={0}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
addonAfter="%"
|
|
|
|
|
|
placeholder={t('copyTradingAdd.copyRatioPlaceholder') || '例如:100 表示 100%(1:1 跟单),默认 100%'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{copyMode === 'FIXED' && (
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.fixedAmount') || '固定跟单金额 (USDC)'}
|
|
|
|
|
|
name="fixedAmount"
|
|
|
|
|
|
rules={[
|
|
|
|
|
|
{ required: true, message: t('copyTradingAdd.fixedAmountRequired') || '请输入固定跟单金额' },
|
|
|
|
|
|
{
|
|
|
|
|
|
validator: (_, value) => {
|
|
|
|
|
|
if (value !== undefined && value !== null && value !== '') {
|
|
|
|
|
|
const amount = Number(value)
|
|
|
|
|
|
if (isNaN(amount)) {
|
|
|
|
|
|
return Promise.reject(new Error(t('copyTradingAdd.invalidNumber') || '请输入有效的数字'))
|
|
|
|
|
|
}
|
|
|
|
|
|
if (amount < 1) {
|
|
|
|
|
|
return Promise.reject(new Error(t('copyTradingAdd.fixedAmountMin') || '固定金额必须 >= 1'))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return Promise.resolve()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
]}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={1}
|
|
|
|
|
|
step={0.0001}
|
|
|
|
|
|
precision={4}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.fixedAmountPlaceholder') || '固定金额,不随 Leader 订单大小变化,必须 >= 1'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{copyMode === 'RATIO' && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.maxOrderSize') || '单笔订单最大金额 (USDC)'}
|
|
|
|
|
|
name="maxOrderSize"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.maxOrderSizeTooltip') || '比例模式下,限制单笔跟单订单的最大金额上限'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={0.0001}
|
|
|
|
|
|
step={0.0001}
|
|
|
|
|
|
precision={4}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.maxOrderSizePlaceholder') || '仅在比例模式下生效(可选)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.minOrderSize') || '单笔订单最小金额 (USDC)'}
|
|
|
|
|
|
name="minOrderSize"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.minOrderSizeTooltip') || '比例模式下,限制单笔跟单订单的最小金额下限,必须 >= 1'}
|
|
|
|
|
|
rules={[
|
|
|
|
|
|
{
|
|
|
|
|
|
validator: (_, value) => {
|
|
|
|
|
|
if (value === undefined || value === null || value === '') {
|
|
|
|
|
|
return Promise.resolve()
|
|
|
|
|
|
}
|
|
|
|
|
|
if (typeof value === 'number' && value < 1) {
|
|
|
|
|
|
return Promise.reject(new Error(t('copyTradingAdd.minOrderSizeMin') || '最小金额必须 >= 1'))
|
|
|
|
|
|
}
|
|
|
|
|
|
return Promise.resolve()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
]}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={1}
|
|
|
|
|
|
step={0.0001}
|
|
|
|
|
|
precision={4}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.minOrderSizePlaceholder') || '仅在比例模式下生效,必须 >= 1(可选)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.maxDailyLoss') || '每日最大亏损限制 (USDC)'}
|
|
|
|
|
|
name="maxDailyLoss"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.maxDailyLossTooltip') || '限制每日最大亏损金额,用于风险控制'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={0}
|
|
|
|
|
|
step={0.0001}
|
|
|
|
|
|
precision={4}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.maxDailyLossPlaceholder') || '默认 10000 USDC(可选)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.maxDailyOrders') || '每日最大跟单订单数'}
|
|
|
|
|
|
name="maxDailyOrders"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.maxDailyOrdersTooltip') || '限制每日最多跟单的订单数量'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={1}
|
|
|
|
|
|
step={1}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.maxDailyOrdersPlaceholder') || '默认 100(可选)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.priceTolerance') || '价格容忍度 (%)'}
|
|
|
|
|
|
name="priceTolerance"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.priceToleranceTooltip') || '允许跟单价格在 Leader 价格基础上的调整范围'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={0}
|
|
|
|
|
|
max={100}
|
|
|
|
|
|
step={0.1}
|
|
|
|
|
|
precision={2}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.priceTolerancePlaceholder') || '默认 5%(可选)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.delaySeconds') || '跟单延迟 (秒)'}
|
|
|
|
|
|
name="delaySeconds"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.delaySecondsTooltip') || '跟单延迟时间,0 表示立即跟单'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={0}
|
|
|
|
|
|
step={1}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.delaySecondsPlaceholder') || '默认 0(立即跟单)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.minOrderDepth') || '最小订单深度 (USDC)'}
|
|
|
|
|
|
name="minOrderDepth"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.minOrderDepthTooltip') || '最小订单深度(USDC金额),NULL表示不启用此过滤。确保市场有足够的流动性'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={0}
|
|
|
|
|
|
step={0.0001}
|
|
|
|
|
|
precision={4}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.minOrderDepthPlaceholder') || '例如:100(可选,不填写表示不启用)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.maxSpread') || '最大价差(绝对价格)'}
|
|
|
|
|
|
name="maxSpread"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.maxSpreadTooltip') || '最大价差(绝对价格),NULL表示不启用此过滤。避免在价差过大的市场跟单'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={0}
|
|
|
|
|
|
step={0.0001}
|
|
|
|
|
|
precision={4}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.maxSpreadPlaceholder') || '例如:0.05(5美分,可选,不填写表示不启用)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.minOrderbookDepth') || '最小订单簿深度 (USDC)'}
|
|
|
|
|
|
name="minOrderbookDepth"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.minOrderbookDepthTooltip') || '最小订单簿深度(USDC金额),NULL表示不启用此过滤。检查前 N 档的深度'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={0}
|
|
|
|
|
|
step={0.0001}
|
|
|
|
|
|
precision={4}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.minOrderbookDepthPlaceholder') || '例如:50(可选,不填写表示不启用)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
2025-12-05 23:52:49 +08:00
|
|
|
|
<Divider>{t('copyTradingAdd.priceRangeFilter') || '价格区间过滤'}</Divider>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.priceRange') || '价格区间'}
|
|
|
|
|
|
name="priceRange"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.priceRangeTooltip') || '配置价格区间,仅在指定价格区间内的订单才会下单。例如:0.11-0.89 表示区间在0.11和0.89之间;-0.89 表示0.89以下都可以;0.11- 表示0.11以上都可以'}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Input.Group compact style={{ display: 'flex' }}>
|
|
|
|
|
|
<Form.Item name="minPrice" noStyle>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={0.01}
|
|
|
|
|
|
max={0.99}
|
|
|
|
|
|
step={0.0001}
|
|
|
|
|
|
precision={4}
|
|
|
|
|
|
style={{ width: '50%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.minPricePlaceholder') || '最低价(可选)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
<span style={{ display: 'inline-block', width: '20px', textAlign: 'center', lineHeight: '32px' }}>-</span>
|
|
|
|
|
|
<Form.Item name="maxPrice" noStyle>
|
|
|
|
|
|
<InputNumber
|
|
|
|
|
|
min={0.01}
|
|
|
|
|
|
max={0.99}
|
|
|
|
|
|
step={0.0001}
|
|
|
|
|
|
precision={4}
|
|
|
|
|
|
style={{ width: '50%' }}
|
|
|
|
|
|
placeholder={t('copyTradingAdd.maxPricePlaceholder') || '最高价(可选)'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Input.Group>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
2025-12-05 05:18:20 +08:00
|
|
|
|
{/* 跟单卖出 - 表单最底部 */}
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={t('copyTradingAdd.supportSell') || '跟单卖出'}
|
|
|
|
|
|
name="supportSell"
|
|
|
|
|
|
tooltip={t('copyTradingAdd.supportSellTooltip') || '是否跟单 Leader 的卖出订单'}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
valuePropName="checked"
|
|
|
|
|
|
>
|
2025-12-05 05:18:20 +08:00
|
|
|
|
<Switch />
|
2025-12-01 23:03:17 +08:00
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item>
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
htmlType="submit"
|
|
|
|
|
|
icon={<SaveOutlined />}
|
|
|
|
|
|
loading={loading}
|
|
|
|
|
|
>
|
2025-12-05 05:18:20 +08:00
|
|
|
|
{t('copyTradingAdd.create') || '创建跟单配置'}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
<Button onClick={() => navigate('/copy-trading')}>
|
2025-12-05 05:18:20 +08:00
|
|
|
|
{t('common.cancel') || '取消'}
|
2025-12-01 23:03:17 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
</Card>
|
2025-12-05 05:18:20 +08:00
|
|
|
|
|
|
|
|
|
|
{/* 模板选择 Modal */}
|
|
|
|
|
|
<Modal
|
|
|
|
|
|
title={t('copyTradingAdd.selectTemplate') || '选择模板'}
|
|
|
|
|
|
open={templateModalVisible}
|
|
|
|
|
|
onCancel={() => setTemplateModalVisible(false)}
|
|
|
|
|
|
footer={null}
|
|
|
|
|
|
width={800}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Table
|
|
|
|
|
|
dataSource={templates}
|
|
|
|
|
|
rowKey="id"
|
|
|
|
|
|
pagination={{ pageSize: 10 }}
|
|
|
|
|
|
onRow={(record) => ({
|
|
|
|
|
|
onClick: () => handleSelectTemplate(record),
|
|
|
|
|
|
style: { cursor: 'pointer' }
|
|
|
|
|
|
})}
|
|
|
|
|
|
columns={[
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('copyTradingAdd.templateName') || '模板名称',
|
|
|
|
|
|
dataIndex: 'templateName',
|
|
|
|
|
|
key: 'templateName'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('copyTradingAdd.copyMode') || '跟单模式',
|
|
|
|
|
|
key: 'copyMode',
|
|
|
|
|
|
render: (_: any, record: CopyTradingTemplate) => (
|
|
|
|
|
|
<span>
|
|
|
|
|
|
{record.copyMode === 'RATIO'
|
|
|
|
|
|
? `${t('copyTradingAdd.ratioMode') || '比例'} ${record.copyRatio}x`
|
|
|
|
|
|
: `${t('copyTradingAdd.fixedAmountMode') || '固定'} ${formatUSDC(record.fixedAmount || '0')} USDC`
|
|
|
|
|
|
}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: t('copyTradingAdd.supportSell') || '跟单卖出',
|
|
|
|
|
|
dataIndex: 'supportSell',
|
|
|
|
|
|
key: 'supportSell',
|
|
|
|
|
|
render: (supportSell: boolean) => supportSell ? (t('common.yes') || '是') : (t('common.no') || '否')
|
|
|
|
|
|
}
|
|
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Modal>
|
2025-12-01 23:03:17 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default CopyTradingAdd
|