Crypto trading bot: engine, brokers, backtester, dashboard, deploy
FastAPI backend with a single-strategy async engine, paper and Binance brokers, pure-python indicators, a backtester that shares the engine's portfolio math, and a Vue dashboard with a live WebSocket feed. Adds the Gitea Actions CI/CD workflow that deploys to Traefik via docker_default.
This commit is contained in:
1 parent
98028248c2
commit
9c3bee87ac
73 files changed
+9759
-1
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const http = axios.create({ baseURL: '/api', timeout: 10000 })
|
||||
|
||||
export const getStatus = () => http.get('/status').then((r) => r.data)
|
||||
export const getStrategies = () => http.get('/strategies').then((r) => r.data)
|
||||
export const getPositions = () => http.get('/positions').then((r) => r.data)
|
||||
export const getOrders = () => http.get('/orders').then((r) => r.data)
|
||||
export const getEvents = () => http.get('/events').then((r) => r.data)
|
||||
export const getEquity = () => http.get('/equity').then((r) => r.data)
|
||||
|
||||
export const startBot = (payload) => http.post('/bot/start', payload).then((r) => r.data)
|
||||
export const stopBot = () => http.post('/bot/stop').then((r) => r.data)
|
||||
export const closePosition = (id, reason = 'manual') =>
|
||||
http.post(`/positions/${id}/close`, { reason }).then((r) => r.data)
|
||||
export const placeOrder = (payload) => http.post('/orders', payload).then((r) => r.data)
|
||||
export const runBacktest = (payload) =>
|
||||
http.post('/backtest', payload, { timeout: 60000 }).then((r) => r.data)
|
||||
|
||||
export function openSocket({ onMessage, onOpen, onClose }) {
|
||||
const proto = window.location.protocol === 'https:' ? 'wss' : 'ws'
|
||||
let socket
|
||||
let retryTimer
|
||||
let closed = false
|
||||
|
||||
const connect = () => {
|
||||
socket = new WebSocket(`${proto}://${window.location.host}/api/ws`)
|
||||
socket.onopen = () => onOpen?.()
|
||||
socket.onmessage = (event) => onMessage?.(JSON.parse(event.data))
|
||||
socket.onclose = () => {
|
||||
onClose?.()
|
||||
if (!closed) retryTimer = setTimeout(connect, 2000)
|
||||
}
|
||||
socket.onerror = () => socket.close()
|
||||
}
|
||||
connect()
|
||||
|
||||
return {
|
||||
close() {
|
||||
closed = true
|
||||
clearTimeout(retryTimer)
|
||||
socket?.close()
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user