File size: 1,954 Bytes
a0d206d 407c9bb a0d206d f79ab06 e2baec9 a0d206d 656ac31 a0d206d 656ac31 e2baec9 a0d206d 656ac31 a0d206d 656ac31 a0d206d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | /**
* Hugging Face ML API Client
* Python FastAPI Backend ile iletişim kurar
*/
import { API_BASE } from '@/lib/runtime-config';
import { fetchJson } from '@/lib/http';
class ApiClient {
/**
* Hisse senedi verilerini getir
*/
async getStockData(symbol: string, period = '1y', interval = '1d') {
const url = `${API_BASE}/api/stock-data?symbol=${symbol}&period=${period}&interval=${interval}`;
try {
return await fetchJson<Record<string, unknown>>(url, { method: 'GET' }, { timeoutMs: 45000, retries: 2 });
} catch (error) {
console.error('getStockData error:', error);
throw error;
}
}
/**
* ML tahminlerini getir
*/
async getMLPredictions(symbols: string[], daysAhead = 5, model = 'ensemble') {
const url = `${API_BASE}/api/ml-predictions`;
try {
return await fetchJson<Record<string, unknown>>(
url,
{ method: 'POST' },
{ timeoutMs: 30000, retries: 0, jsonBody: { symbols, days_ahead: daysAhead, model } }
);
} catch (error) {
console.error('getMLPredictions error:', error);
throw error;
}
}
/**
* Teknik analiz getir
*/
async getTechnicalAnalysis(symbol: string) {
const url = `${API_BASE}/api/technical-analysis?symbol=${symbol}`;
try {
return await fetchJson<Record<string, unknown>>(url, { method: 'GET' }, { timeoutMs: 45000, retries: 2 });
} catch (error) {
console.error('getTechnicalAnalysis error:', error);
throw error;
}
}
/**
* Piyasa özetini getir
*/
async getMarketOverview() {
const url = `${API_BASE}/api/market-overview`;
try {
return await fetchJson<Record<string, unknown>>(url, { method: 'GET' }, { timeoutMs: 45000, retries: 2 });
} catch (error) {
console.error('getMarketOverview error:', error);
throw error;
}
}
}
export const apiClient = new ApiClient();
export default apiClient;
|