bbgo_origin/frontend/api/bbgo.js

115 lines
3.0 KiB
JavaScript
Raw Normal View History

2021-01-25 09:40:37 +00:00
import axios from "axios";
const baseURL = process.env.NODE_ENV === "development" ? "http://localhost:8080" : ""
2021-02-04 12:21:16 +00:00
export function ping(cb) {
return axios.get(baseURL + '/api/ping').then(response => {
cb(response.data)
});
}
2022-04-14 02:19:22 +00:00
export function queryOutboundIP(cb) {
return axios.get(baseURL + '/api/outbound-ip').then(response => {
cb(response.data.outboundIP)
});
}
2021-02-21 10:08:22 +00:00
export function querySyncStatus(cb) {
return axios.get(baseURL + '/api/environment/syncing').then(response => {
cb(response.data.syncing)
});
}
2021-02-17 06:57:29 +00:00
export function testDatabaseConnection(params, cb) {
return axios.post(baseURL + '/api/setup/test-db', params).then(response => {
2021-02-02 09:26:35 +00:00
cb(response.data)
});
}
2021-02-17 06:57:29 +00:00
export function configureDatabase(params, cb) {
return axios.post(baseURL + '/api/setup/configure-db', params).then(response => {
2021-02-02 09:26:35 +00:00
cb(response.data)
});
}
export function saveConfig(cb) {
return axios.post(baseURL + '/api/setup/save').then(response => {
cb(response.data)
});
}
2021-02-04 12:21:16 +00:00
export function setupRestart(cb) {
return axios.post(baseURL + '/api/setup/restart').then(response => {
cb(response.data)
});
}
2021-02-02 09:26:35 +00:00
export function addSession(session, cb) {
return axios.post(baseURL + '/api/sessions', session).then(response => {
2021-02-18 07:36:33 +00:00
cb(response.data || [])
2021-02-02 09:26:35 +00:00
});
}
2021-02-02 18:26:41 +00:00
export function attachStrategyOn(session, strategyID, strategy, cb) {
return axios.post(baseURL + `/api/setup/strategy/single/${strategyID}/session/${session}`, strategy).then(response => {
cb(response.data)
});
}
2021-02-02 09:26:35 +00:00
export function testSessionConnection(session, cb) {
return axios.post(baseURL + '/api/sessions/test', session).then(response => {
cb(response.data)
});
}
export function queryStrategies(cb) {
return axios.get(baseURL + '/api/strategies/single').then(response => {
2021-02-18 07:36:33 +00:00
cb(response.data.strategies || [])
});
}
2021-01-25 10:29:31 +00:00
export function querySessions(cb) {
return axios.get(baseURL + '/api/sessions', {})
2021-01-25 10:29:31 +00:00
.then(response => {
2021-02-04 10:22:47 +00:00
cb(response.data.sessions || [])
2021-01-25 10:29:31 +00:00
});
}
export function querySessionSymbols(sessionName, cb) {
2022-04-14 02:19:22 +00:00
return axios.get(baseURL + `/api/sessions/${sessionName}/symbols`, {})
.then(response => {
2021-02-18 07:36:33 +00:00
cb(response.data.symbols || [])
});
}
2021-01-29 10:48:39 +00:00
export function queryTrades(params, cb) {
axios.get(baseURL + '/api/trades', {params: params})
2021-01-29 10:48:39 +00:00
.then(response => {
2021-02-18 07:36:33 +00:00
cb(response.data.trades || [])
2021-01-29 10:48:39 +00:00
});
}
2021-01-29 10:34:03 +00:00
export function queryClosedOrders(params, cb) {
axios.get(baseURL + '/api/orders/closed', {params: params})
2021-01-29 08:50:06 +00:00
.then(response => {
2021-02-18 07:36:33 +00:00
cb(response.data.orders || [])
2021-01-29 08:50:06 +00:00
});
}
2021-01-25 09:40:37 +00:00
export function queryAssets(cb) {
axios.get(baseURL + '/api/assets', {})
.then(response => {
2021-02-18 07:36:33 +00:00
cb(response.data.assets || [])
2021-01-25 09:40:37 +00:00
});
}
2021-01-26 10:10:08 +00:00
export function queryTradingVolume(params, cb) {
axios.get(baseURL + '/api/trading-volume', {params: params})
2021-01-26 10:10:08 +00:00
.then(response => {
2021-02-18 07:36:33 +00:00
cb(response.data.tradingVolumes || [])
2021-01-26 10:10:08 +00:00
});
}