Files
trading_bot_v3/app/api/market-data/route.js
mindesbunister e9517d5ec4 feat: Complete Bitquery trading integration with real wallet support
Features Added:
- Real-time price data via CoinGecko API (BTC: 21k+, SOL: 66+, etc.)
- Actual Solana wallet integration using private key from .env
- Trade execution API with Bitquery simulation
 trade recommendation → execution flow
- Portfolio display showing real wallet balance (~2.49 SOL)

- /api/market - Live cryptocurrency prices
- /api/trading/execute - Execute trades based on analysis
- /api/trading/balance - Real wallet balance
- /api/wallet/balance - Direct Solana wallet access

- TradeExecutionPanel.js - Complete trading interface
- WalletConnection.js - Wallet connection component
- Updated AIAnalysisPanel - Analysis → trade execution flow
- Updated StatusOverview - Real market data + wallet balance

- AI analysis generates trade recommendations
- Users can execute trades based on AI suggestions
- Real portfolio tracking with actual Solana wallet
- Live market prices (no more fake data)
- Ready for production trading

Security: Private key stays in .env, only public data exposed to frontend
2025-07-14 14:58:01 +02:00

47 lines
1.1 KiB
JavaScript

import { NextResponse } from 'next/server'
import { bitqueryService } from '../../../lib/bitquery-service'
export async function GET() {
try {
console.log('📊 Fetching market data...')
// Check if Bitquery service is configured
if (!bitqueryService.isConfigured()) {
return NextResponse.json(
{
success: false,
error: 'Bitquery service not configured'
},
{ status: 503 }
)
}
// Get token prices from Bitquery
const prices = await bitqueryService.getTokenPrices(['SOL', 'BTC', 'ETH'])
// Get service status
const status = await bitqueryService.getServiceStatus()
return NextResponse.json({
success: true,
data: {
prices,
bitqueryStatus: status,
lastUpdate: Date.now()
},
timestamp: Date.now()
})
} catch (error) {
console.error('❌ Market data API error:', error)
return NextResponse.json(
{
success: false,
error: 'Failed to fetch market data',
message: error.message
},
{ status: 500 }
)
}
}