fix: Respect user trading mode choice in optimized automation
Frontend changes: - Pass mode, tradingAmount, balancePercentage, dexProvider to optimized API - Send user's actual trading mode choice (LIVE/SIMULATION) Backend changes: - Accept mode and trading parameters from frontend request - Use passed mode instead of hardcoded 'SIMULATION' - Apply user's trading amount and balance percentage settings This fixes the issue where optimized automation always used SIMULATION regardless of user's LIVE trading selection.
This commit is contained in:
@@ -6,7 +6,19 @@ import { progressTracker } from '../../../lib/progress-tracker'
|
|||||||
export async function POST(request) {
|
export async function POST(request) {
|
||||||
try {
|
try {
|
||||||
const body = await request.json()
|
const body = await request.json()
|
||||||
const { symbol, timeframes, selectedTimeframes, layouts, analyze = true, automationMode = false } = body
|
export async function POST(request) {
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
symbol,
|
||||||
|
timeframes,
|
||||||
|
layouts = ['ai', 'diy'],
|
||||||
|
analyze = true,
|
||||||
|
automationMode = false,
|
||||||
|
mode = 'SIMULATION', // Default to simulation if not provided
|
||||||
|
tradingAmount = 100,
|
||||||
|
balancePercentage = 50,
|
||||||
|
dexProvider = 'DRIFT'
|
||||||
|
} = await request.json()
|
||||||
|
|
||||||
// Use selectedTimeframes if provided, fallback to timeframes, then default
|
// Use selectedTimeframes if provided, fallback to timeframes, then default
|
||||||
const targetTimeframes = selectedTimeframes || timeframes || ['1h', '4h']
|
const targetTimeframes = selectedTimeframes || timeframes || ['1h', '4h']
|
||||||
@@ -31,10 +43,10 @@ export async function POST(request) {
|
|||||||
symbol: symbol || 'SOLUSD',
|
symbol: symbol || 'SOLUSD',
|
||||||
timeframe: targetTimeframes[0] || '15', // Primary timeframe for database
|
timeframe: targetTimeframes[0] || '15', // Primary timeframe for database
|
||||||
selectedTimeframes: targetTimeframes,
|
selectedTimeframes: targetTimeframes,
|
||||||
mode: 'SIMULATION',
|
mode: mode, // Use the mode passed from frontend
|
||||||
dexProvider: 'DRIFT',
|
dexProvider: dexProvider,
|
||||||
tradingAmount: 100,
|
tradingAmount: tradingAmount,
|
||||||
balancePercentage: 50,
|
balancePercentage: balancePercentage,
|
||||||
maxLeverage: 3, // Required field for automation
|
maxLeverage: 3, // Required field for automation
|
||||||
riskPercentage: 2, // Required field for automation
|
riskPercentage: 2, // Required field for automation
|
||||||
maxDailyTrades: 5,
|
maxDailyTrades: 5,
|
||||||
|
|||||||
@@ -156,7 +156,11 @@ export default function AutomationPageV2() {
|
|||||||
timeframes: config.selectedTimeframes,
|
timeframes: config.selectedTimeframes,
|
||||||
layouts: ['ai', 'diy'],
|
layouts: ['ai', 'diy'],
|
||||||
analyze: true,
|
analyze: true,
|
||||||
automationMode: true // Flag to indicate this is automation, not just testing
|
automationMode: true, // Flag to indicate this is automation, not just testing
|
||||||
|
mode: config.mode, // Pass the user's trading mode choice
|
||||||
|
tradingAmount: config.tradingAmount,
|
||||||
|
balancePercentage: config.balancePercentage,
|
||||||
|
dexProvider: config.dexProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
|
|||||||
Reference in New Issue
Block a user