Implement pure Drift Protocol automation system
- Remove Jupiter DEX completely from automation system - Implement exclusive Drift Protocol integration with up to 100x leverage - Update executeLiveTrade method to use only Drift API endpoints - Change default DEX provider from Jupiter to Drift - Create minimal professional UI without promotional banners - Add comprehensive leverage options (1x-100x) with risk indicators - Update automation service to route all trades through /api/automation/trade - Fix type definitions to support Drift-only configuration - Add multiple trading pairs support (SOL, BTC, ETH, APT, AVAX, DOGE) - Implement clean configuration interface with essential controls - Remove excessive marketing text and promotional elements - Maintain full automation functionality while simplifying UX
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
const { PrismaClient } = require('@prisma/client')
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
async function fixTradeData() {
|
||||
console.log('🔧 Fixing trade P&L data...')
|
||||
|
||||
try {
|
||||
const trades = await prisma.trade.findMany({
|
||||
orderBy: { createdAt: 'desc' }
|
||||
})
|
||||
|
||||
console.log(`📊 Found ${trades.length} trades to fix`)
|
||||
|
||||
for (const trade of trades) {
|
||||
// Generate realistic exit prices and profits
|
||||
const entryPrice = trade.price
|
||||
|
||||
// Create realistic price movements (70% wins, 30% losses)
|
||||
const isWin = Math.random() < 0.7
|
||||
const priceMovement = isWin ?
|
||||
(Math.random() * 3 + 0.5) : // 0.5% to 3.5% gain
|
||||
-(Math.random() * 2 + 0.3) // 0.3% to 2.3% loss
|
||||
|
||||
const exitPrice = trade.side === 'BUY' ?
|
||||
entryPrice * (1 + priceMovement / 100) :
|
||||
entryPrice * (1 - priceMovement / 100)
|
||||
|
||||
// Calculate profit in USD
|
||||
const profit = trade.side === 'BUY' ?
|
||||
(exitPrice - entryPrice) * trade.amount :
|
||||
(entryPrice - exitPrice) * trade.amount
|
||||
|
||||
// Add realistic exit times (15-60 minutes after entry)
|
||||
const entryTime = new Date(trade.createdAt)
|
||||
const exitTime = new Date(entryTime.getTime() + (Math.random() * 45 + 15) * 60 * 1000)
|
||||
|
||||
await prisma.trade.update({
|
||||
where: { id: trade.id },
|
||||
data: {
|
||||
exitPrice: exitPrice,
|
||||
profit: profit,
|
||||
closedAt: exitTime,
|
||||
status: 'COMPLETED'
|
||||
}
|
||||
})
|
||||
|
||||
console.log(`✅ Updated trade ${trade.id}: ${trade.side} $${profit.toFixed(2)} (${isWin ? 'WIN' : 'LOSS'})`)
|
||||
}
|
||||
|
||||
console.log('🎉 All trades updated successfully!')
|
||||
|
||||
// Show summary
|
||||
const updatedTrades = await prisma.trade.findMany()
|
||||
const totalProfit = updatedTrades.reduce((sum, t) => sum + (t.profit || 0), 0)
|
||||
const wins = updatedTrades.filter(t => (t.profit || 0) > 0).length
|
||||
const winRate = (wins / updatedTrades.length * 100).toFixed(1)
|
||||
|
||||
console.log(`📈 Summary: ${wins}/${updatedTrades.length} wins (${winRate}% win rate), Total P&L: $${totalProfit.toFixed(2)}`)
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Error:', error)
|
||||
} finally {
|
||||
await prisma.$disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
fixTradeData()
|
||||
|
||||
Reference in New Issue
Block a user