a
This commit is contained in:
parent
8d3991c74c
commit
7847d3100b
|
|
@ -137,7 +137,7 @@ export const api = {
|
||||||
|
|
||||||
// 账号管理
|
// 账号管理
|
||||||
getAccounts: async () => {
|
getAccounts: async () => {
|
||||||
const response = await fetch(buildUrl('/api/accounts'), { headers: withAccountHeaders() });
|
const response = await fetch(buildUrl('/api/account'), { headers: withAccountHeaders() });
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const error = await response.json().catch(() => ({ detail: '获取账号列表失败' }));
|
const error = await response.json().catch(() => ({ detail: '获取账号列表失败' }));
|
||||||
throw new Error(error.detail || '获取账号列表失败');
|
throw new Error(error.detail || '获取账号列表失败');
|
||||||
|
|
@ -145,7 +145,7 @@ export const api = {
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
createAccount: async (data) => {
|
createAccount: async (data) => {
|
||||||
const response = await fetch(buildUrl('/api/accounts'), {
|
const response = await fetch(buildUrl('/api/account'), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify(data || {}),
|
body: JSON.stringify(data || {}),
|
||||||
|
|
@ -157,7 +157,7 @@ export const api = {
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
updateAccount: async (accountId, data) => {
|
updateAccount: async (accountId, data) => {
|
||||||
const response = await fetch(buildUrl(`/api/accounts/${accountId}`), {
|
const response = await fetch(buildUrl(`/api/account/${accountId}`), {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify(data || {}),
|
body: JSON.stringify(data || {}),
|
||||||
|
|
@ -169,7 +169,7 @@ export const api = {
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
updateAccountCredentials: async (accountId, data) => {
|
updateAccountCredentials: async (accountId, data) => {
|
||||||
const response = await fetch(buildUrl(`/api/accounts/${accountId}/credentials`), {
|
const response = await fetch(buildUrl(`/api/account/${accountId}/credentials`), {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
body: JSON.stringify(data || {}),
|
body: JSON.stringify(data || {}),
|
||||||
|
|
@ -183,7 +183,7 @@ export const api = {
|
||||||
|
|
||||||
// 交易进程(按账号;需要 owner 或 admin)
|
// 交易进程(按账号;需要 owner 或 admin)
|
||||||
getAccountTradingStatus: async (accountId) => {
|
getAccountTradingStatus: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/status`), { headers: withAccountHeaders() })
|
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/status`), { headers: withAccountHeaders() })
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const error = await response.json().catch(() => ({ detail: '获取交易进程状态失败' }))
|
const error = await response.json().catch(() => ({ detail: '获取交易进程状态失败' }))
|
||||||
throw new Error(error.detail || '获取交易进程状态失败')
|
throw new Error(error.detail || '获取交易进程状态失败')
|
||||||
|
|
@ -191,7 +191,7 @@ export const api = {
|
||||||
return response.json()
|
return response.json()
|
||||||
},
|
},
|
||||||
startAccountTrading: async (accountId) => {
|
startAccountTrading: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/start`), {
|
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/start`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
})
|
})
|
||||||
|
|
@ -202,7 +202,7 @@ export const api = {
|
||||||
return response.json()
|
return response.json()
|
||||||
},
|
},
|
||||||
stopAccountTrading: async (accountId) => {
|
stopAccountTrading: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/stop`), {
|
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/stop`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
})
|
})
|
||||||
|
|
@ -213,7 +213,7 @@ export const api = {
|
||||||
return response.json()
|
return response.json()
|
||||||
},
|
},
|
||||||
restartAccountTrading: async (accountId) => {
|
restartAccountTrading: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/restart`), {
|
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/restart`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
})
|
})
|
||||||
|
|
@ -224,7 +224,7 @@ export const api = {
|
||||||
return response.json()
|
return response.json()
|
||||||
},
|
},
|
||||||
ensureAccountTradingProgram: async (accountId) => {
|
ensureAccountTradingProgram: async (accountId) => {
|
||||||
const response = await fetch(buildUrl(`/api/accounts/${accountId}/trading/ensure-program`), {
|
const response = await fetch(buildUrl(`/api/account/${accountId}/trading/ensure-program`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
})
|
})
|
||||||
|
|
@ -410,7 +410,7 @@ export const api = {
|
||||||
|
|
||||||
// 补挂止盈止损(交易所保护单)
|
// 补挂止盈止损(交易所保护单)
|
||||||
ensurePositionSLTP: async (symbol) => {
|
ensurePositionSLTP: async (symbol) => {
|
||||||
const response = await fetch(buildUrl(`/api/accounts/positions/${symbol}/sltp/ensure`), {
|
const response = await fetch(buildUrl(`/api/account/positions/${symbol}/sltp/ensure`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
});
|
});
|
||||||
|
|
@ -422,7 +422,7 @@ export const api = {
|
||||||
},
|
},
|
||||||
|
|
||||||
ensureAllPositionsSLTP: async (limit = 50) => {
|
ensureAllPositionsSLTP: async (limit = 50) => {
|
||||||
const response = await fetch(buildUrl(`/api/accounts/positions/sltp/ensure-all?limit=${encodeURIComponent(limit)}`), {
|
const response = await fetch(buildUrl(`/api/account/positions/sltp/ensure-all?limit=${encodeURIComponent(limit)}`), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
headers: withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
});
|
});
|
||||||
|
|
@ -435,7 +435,7 @@ export const api = {
|
||||||
|
|
||||||
// 同步持仓状态
|
// 同步持仓状态
|
||||||
syncPositions: async () => {
|
syncPositions: async () => {
|
||||||
const response = await fetch(buildUrl('/api/accounts/positions/sync'), {
|
const response = await fetch(buildUrl('/api/account/positions/sync'), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
...withAccountHeaders({ 'Content-Type': 'application/json' }),
|
...withAccountHeaders({ 'Content-Type': 'application/json' }),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user