Features: - FastAPI backend with stocks, news, signals, watchlist, analytics endpoints - React frontend with TailwindCSS dark mode trading dashboard - Celery workers for news fetching, sentiment analysis, pattern detection - TimescaleDB schema for time-series stock data - Docker Compose setup for all services - OpenAI integration for sentiment analysis
80 lines
2.9 KiB
TypeScript
80 lines
2.9 KiB
TypeScript
import axios from 'axios'
|
|
|
|
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000'
|
|
|
|
export const api = axios.create({
|
|
baseURL: `${API_URL}/api/v1`,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
})
|
|
|
|
// Stocks
|
|
export const stocksApi = {
|
|
list: (params?: { sector?: string; search?: string; skip?: number; limit?: number }) =>
|
|
api.get('/stocks/', { params }),
|
|
get: (symbol: string) => api.get(`/stocks/${symbol}`),
|
|
create: (data: { symbol: string; name: string; sector?: string; industry?: string }) =>
|
|
api.post('/stocks/', data),
|
|
delete: (symbol: string) => api.delete(`/stocks/${symbol}`),
|
|
getSectors: () => api.get('/stocks/sectors'),
|
|
getIndustries: (sector?: string) => api.get('/stocks/industries', { params: { sector } }),
|
|
}
|
|
|
|
// News
|
|
export const newsApi = {
|
|
list: (params?: { source?: string; sentiment?: string; hours?: number; skip?: number; limit?: number }) =>
|
|
api.get('/news/', { params }),
|
|
getForStock: (symbol: string, params?: { hours?: number }) =>
|
|
api.get(`/news/stock/${symbol}`, { params }),
|
|
getPanicNews: (params?: { threshold?: number; hours?: number; limit?: number }) =>
|
|
api.get('/news/panic', { params }),
|
|
get: (id: string) => api.get(`/news/${id}`),
|
|
}
|
|
|
|
// Signals
|
|
export const signalsApi = {
|
|
list: (params?: { status?: string; min_confidence?: number; skip?: number; limit?: number }) =>
|
|
api.get('/signals/', { params }),
|
|
getTop: (limit?: number) => api.get('/signals/top', { params: { limit } }),
|
|
get: (id: string) => api.get(`/signals/${id}`),
|
|
trigger: (id: string) => api.post(`/signals/${id}/trigger`),
|
|
dismiss: (id: string) => api.post(`/signals/${id}/dismiss`),
|
|
}
|
|
|
|
// Watchlist
|
|
export const watchlistApi = {
|
|
list: (priority?: number) => api.get('/watchlist/', { params: { priority } }),
|
|
add: (data: {
|
|
symbol: string
|
|
panic_alert_threshold?: number
|
|
price_alert_low?: number
|
|
price_alert_high?: number
|
|
priority?: number
|
|
notes?: string
|
|
}) => api.post('/watchlist/', data),
|
|
update: (id: string, data: Partial<{
|
|
panic_alert_threshold: number
|
|
price_alert_low: number
|
|
price_alert_high: number
|
|
priority: number
|
|
notes: string
|
|
is_active: boolean
|
|
}>) => api.put(`/watchlist/${id}`, data),
|
|
remove: (id: string) => api.delete(`/watchlist/${id}`),
|
|
removeBySymbol: (symbol: string) => api.delete(`/watchlist/symbol/${symbol}`),
|
|
}
|
|
|
|
// Analytics
|
|
export const analyticsApi = {
|
|
getDashboard: () => api.get('/analytics/dashboard'),
|
|
getSentimentTrend: (days?: number) => api.get('/analytics/sentiment/trend', { params: { days } }),
|
|
getSectorPanic: () => api.get('/analytics/sector/panic'),
|
|
getTopPatterns: (limit?: number) => api.get('/analytics/patterns/top', { params: { limit } }),
|
|
getRecentPanicEvents: (days?: number, limit?: number) =>
|
|
api.get('/analytics/panic-events/recent', { params: { days, limit } }),
|
|
getPerformance: (days?: number) => api.get('/analytics/performance', { params: { days } }),
|
|
}
|
|
|
|
export default api
|