Add full custom timeframe selection support
CUSTOM TIMEFRAME FEATURES:
- Superior screenshot API now accepts 'timeframes' array parameter
- Automatically detects custom vs preset timeframe selections
- Maintains superior parallel capture for ANY manual selection
- Full backwards compatibility with existing preset system
API USAGE:
POST /api/superior-screenshot
{
"timeframes": ["5m", "1h", "1D"], // Your exact selection
"symbol": "SOLUSD",
"layouts": ["ai", "diy"]
}
TESTING TOOLS:
- test-custom-timeframes.js: Logic demonstration
- test-custom-api-practical.js: Real API testing scenarios
ANSWER: YES - Any manual timeframe selection is fully respected!
Whether 1 timeframe or 10, preset or custom - all use parallel capture.
This commit is contained in:
@@ -12,7 +12,8 @@ export async function POST(request) {
|
||||
symbol: body.symbol || 'SOLUSD',
|
||||
preset: body.preset || 'scalp',
|
||||
layouts: body.layouts || ['ai', 'diy'],
|
||||
analyze: body.analyze === true
|
||||
analyze: body.analyze === true,
|
||||
customTimeframes: body.timeframes // Support for custom timeframe arrays
|
||||
}
|
||||
|
||||
console.log('📋 Superior Config:', config)
|
||||
@@ -45,8 +46,21 @@ export async function POST(request) {
|
||||
]
|
||||
}
|
||||
|
||||
// Get timeframes for the selected preset
|
||||
const selectedTimeframes = TRADING_PRESETS[config.preset] || TRADING_PRESETS['scalp']
|
||||
// Get timeframes for the selected preset or use custom timeframes
|
||||
let selectedTimeframes
|
||||
|
||||
if (config.customTimeframes && Array.isArray(config.customTimeframes)) {
|
||||
// Custom timeframes provided - convert to our format
|
||||
selectedTimeframes = config.customTimeframes.map(tf => ({
|
||||
name: tf,
|
||||
tv: tf
|
||||
}))
|
||||
console.log(`🎯 Using CUSTOM timeframes: [${config.customTimeframes.join(', ')}]`)
|
||||
} else {
|
||||
// Use preset timeframes
|
||||
selectedTimeframes = TRADING_PRESETS[config.preset] || TRADING_PRESETS['scalp']
|
||||
console.log(`🎯 Using ${config.preset.toUpperCase()} preset: [${selectedTimeframes.map(tf => tf.name).join(', ')}]`)
|
||||
}
|
||||
|
||||
// For single timeframe compatibility
|
||||
if (body.timeframe) {
|
||||
@@ -156,7 +170,8 @@ export async function POST(request) {
|
||||
success: true,
|
||||
mode: 'parallel',
|
||||
symbol: config.symbol,
|
||||
preset: config.preset,
|
||||
preset: config.customTimeframes ? 'custom' : config.preset,
|
||||
customTimeframes: config.customTimeframes || null,
|
||||
duration: duration,
|
||||
totalScreenshots: totalScreenshots,
|
||||
successfulTimeframes: successful.length,
|
||||
@@ -186,15 +201,24 @@ export async function GET() {
|
||||
'scalp': '3 timeframes (5m, 15m, 30m) - Scalping strategy',
|
||||
'day-trading': '2 timeframes (1h, 2h) - Day trading strategy',
|
||||
'swing-trading': '2 timeframes (4h, 1D) - Swing trading strategy',
|
||||
'extended': '9 timeframes (1m-1D) - Comprehensive analysis'
|
||||
'extended': '9 timeframes (1m-1D) - Comprehensive analysis',
|
||||
'custom': 'Any timeframes you specify in the timeframes array'
|
||||
},
|
||||
parameters: {
|
||||
symbol: 'Trading symbol (default: SOLUSD)',
|
||||
preset: 'Trading preset (scalp/day-trading/swing-trading/extended)',
|
||||
timeframes: 'Array of custom timeframes (overrides preset) - e.g. ["5m", "1h", "1D"]',
|
||||
layouts: 'Screenshot layouts (default: ["ai", "diy"])',
|
||||
analyze: 'Whether to run AI analysis (default: false)'
|
||||
},
|
||||
features: [
|
||||
'Parallel multi-timeframe capture',
|
||||
'Intelligent preset detection',
|
||||
'Custom timeframe arrays fully supported',
|
||||
'Single timeframe compatibility',
|
||||
'Proven efficiency (100% success rate)',
|
||||
'API-managed browser sessions',
|
||||
'No hardcoded 7-timeframe limitation'
|
||||
'Respects ANY manual timeframe selection'
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user