| import axios from 'axios' |
|
|
| const api = axios.create({ |
| baseURL: '/api', |
| timeout: 10000, |
| }) |
|
|
| export const marketApi = { |
| getQuotes: (params) => api.get('/market/quotes', { params }), |
| getKlines: (symbol, limit = 200, interval = '1m') => api.get(`/market/klines/${encodeURIComponent(symbol)}?interval=${interval}&limit=${limit}`), |
| getContracts: (params) => api.get('/market/contracts', { params }), |
| getExchanges: () => api.get('/market/exchanges'), |
| getCategories: () => api.get('/market/categories'), |
| getContractDetail: (symbol) => api.get(`/market/contract/${encodeURIComponent(symbol)}`), |
| getMode: () => api.get('/market/mode'), |
| setMode: (mode) => api.post(`/market/mode?mode=${mode}`), |
| } |
|
|
| export const orderApi = { |
| placeOrder: (data) => api.post('/orders', data), |
| getOrders: (symbol) => api.get('/orders', { params: { symbol } }), |
| cancelOrder: (orderId) => api.delete(`/orders/${orderId}`), |
| } |
|
|
| export const positionApi = { |
| getPositions: () => api.get('/positions'), |
| } |
|
|
| export const accountApi = { |
| getAccount: () => api.get('/account'), |
| } |
|
|
| export const tradeApi = { |
| getTrades: (limit = 100) => api.get(`/trades?limit=${limit}`), |
| } |
|
|
| export const strategyApi = { |
| getAvailable: () => api.get('/strategies/available'), |
| getStrategies: () => api.get('/strategies'), |
| addStrategy: (config) => api.post('/strategies', config), |
| startStrategy: (id) => api.post(`/strategies/${id}/start`), |
| stopStrategy: (id) => api.post(`/strategies/${id}/stop`), |
| removeStrategy: (id) => api.delete(`/strategies/${id}`), |
| getSignals: (id) => api.get(`/strategies/${id}/signals`), |
| getPerformance: (id) => api.get(`/strategies/${id}/performance`), |
| } |
|
|
| export const riskApi = { |
| getMetrics: () => api.get('/risk'), |
| } |
|
|
| export const patternApi = { |
| getRegistry: () => api.get('/patterns/registry'), |
| detect: (symbol, interval = '1m', limit = 200, patterns = null) => { |
| let url = `/patterns/detect/${encodeURIComponent(symbol)}?interval=${interval}&limit=${limit}` |
| if (patterns) url += `&patterns=${patterns}` |
| return api.get(url) |
| }, |
| } |
|
|
| export const backtestApi = { |
| getTemplates: () => api.get('/backtest/templates'), |
| run: (payload) => api.post('/backtest/run', payload), |
| } |
|
|
| export const platformApi = { |
| listServices: () => api.get('/platform/services'), |
| getService: (id) => api.get(`/platform/services/${id}`), |
| startService: (id) => api.post(`/platform/services/${id}/start`), |
| stopService: (id) => api.post(`/platform/services/${id}/stop`), |
| startAll: () => api.post('/platform/services/start-all'), |
| } |
|
|
| export const researchApi = { |
| health: () => api.get('/research/health'), |
| listFactors: () => api.get('/research/factors'), |
| computeFactor: (name) => api.post(`/research/factors/${encodeURIComponent(name)}/compute`), |
| backtestFactor: (name, body) => api.post(`/research/factors/${encodeURIComponent(name)}/backtest`, body), |
| listOperators: () => api.get('/research/operators'), |
| buildExpression: (body) => api.post('/research/operators/build', body), |
| listStrategies: () => api.get('/research/strategies'), |
| } |
|
|
| export default api |
|
|