Files
trading_bot_v3/app/api/trading/route.ts
mindesbunister de45349baa Restore working dashboard and TradingView analysis
- Fixed layout conflicts by removing minimal layout.tsx in favor of complete layout.js
- Restored original AI Analysis page with full TradingView integration
- Connected enhanced screenshot API to real TradingView automation service
- Fixed screenshot gallery to handle both string and object formats
- Added image serving API route for screenshot display
- Resolved hydration mismatch issues with suppressHydrationWarning
- All navigation pages working (Analysis, Trading, Automation, Settings)
- TradingView automation successfully capturing screenshots from AI and DIY layouts
- Docker Compose v2 compatibility ensured

Working features:
- Homepage with hero section and status cards
- Navigation menu with Trading Bot branding
- Real TradingView screenshot capture
- AI-powered chart analysis
- Multi-layout support (AI + DIY module)
- Screenshot gallery with image serving
- API endpoints for balance, status, screenshots, trading
2025-07-14 14:21:19 +02:00

55 lines
1.6 KiB
TypeScript

import { NextResponse } from 'next/server'
export async function POST(request: Request) {
try {
const body = await request.json()
const { symbol, side, amount, type = 'market' } = body
// Validate input
if (!symbol || !side || !amount) {
return NextResponse.json({
error: 'Missing required fields: symbol, side, amount'
}, { status: 400 })
}
// Mock trading execution
const mockTrade = {
id: `trade_${Date.now()}`,
symbol,
side, // 'buy' or 'sell'
amount: parseFloat(amount),
type,
price: side === 'buy' ? 144.11 : 144.09, // Mock prices
status: 'executed',
timestamp: new Date().toISOString(),
fee: parseFloat(amount) * 0.001 // 0.1% fee
}
console.log('Simulated trade executed:', mockTrade)
return NextResponse.json({
success: true,
trade: mockTrade,
message: `Successfully ${side} ${amount} ${symbol}`
})
} catch (error) {
return NextResponse.json({
error: 'Failed to execute trade',
message: error instanceof Error ? error.message : 'Unknown error'
}, { status: 500 })
}
}
export async function GET() {
return NextResponse.json({
message: 'Trading endpoint is active. Use POST to execute trades.',
supportedMethods: ['POST'],
requiredFields: ['symbol', 'side', 'amount'],
optionalFields: ['type'],
positions: [
{ symbol: 'SOL', size: 1.5, entryPrice: 140.50, markPrice: 144.11, unrealizedPnl: 5.415 },
{ symbol: 'ETH', size: 0.1, entryPrice: 2350, markPrice: 2400, unrealizedPnl: 5.0 }
]
})
}