Fix consistency bug, rename Random to Auto, add stop-after-all, direction pills, copy-trade
Bug fixes: - Fix computeDailyTarget when consistency is 0% or 100%: treat as no constraint, letting min-day reservation or full remaining profit drive the target - Rename 'Random' to 'Auto' across entire codebase (types, API, UI, scheduler) Features: - Add "Stop after all eligible" checkbox: auto-stops scheduler when all configured accounts are dead, inactive, already traded, or challenge complete - Show position direction in status pill: "Long" (green) / "Short" (red) instead of generic "In Trade" (blue) - Add "Copy to Max" button: copies current trade direction to remaining eligible accounts up to max_concurrent_accounts limit Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
8d9a9a5ea9
commit
df793bfd70
@@ -0,0 +1,12 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { copyTrade } from '@/lib/auto-trade';
|
||||
|
||||
export async function POST() {
|
||||
try {
|
||||
const results = await copyTrade();
|
||||
return NextResponse.json(results);
|
||||
} catch (err: any) {
|
||||
console.error('[POST /api/copy-trade]', err);
|
||||
return NextResponse.json({ error: err?.message ?? 'Copy trade failed' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,9 @@ export async function GET() {
|
||||
amount: cash.amount,
|
||||
realizedPnL: cash.realizedPnL,
|
||||
daysTraded,
|
||||
hasPosition: !!client.positions[acc.id],
|
||||
positionDirection: client.positions[acc.id]
|
||||
? (client.positions[acc.id].netPos > 0 ? 'long' as const : 'short' as const)
|
||||
: null,
|
||||
autoLiqThreshold,
|
||||
totalProfit,
|
||||
targetHit,
|
||||
|
||||
@@ -4,14 +4,14 @@ import { POINT_VALUES } from '@/lib/trading-logic';
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
const body = await req.json() as { action: 'Buy' | 'Sell' | 'Random'; symbol: string };
|
||||
const { action, symbol } = body;
|
||||
const body = await req.json() as { action: 'Buy' | 'Sell' | 'Auto'; symbol: string; stopAfterAll?: boolean };
|
||||
const { action, symbol, stopAfterAll } = body;
|
||||
|
||||
if (!action || !symbol) {
|
||||
return NextResponse.json({ error: 'Missing required fields: action, symbol' }, { status: 400 });
|
||||
}
|
||||
|
||||
if (symbol !== 'Random' && !POINT_VALUES[symbol]) {
|
||||
if (symbol !== 'Auto' && !POINT_VALUES[symbol]) {
|
||||
return NextResponse.json({ error: `Unknown symbol: ${symbol}` }, { status: 400 });
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export async function POST(req: NextRequest) {
|
||||
const results = await runTrade(action, symbol);
|
||||
|
||||
// (Re)start the scheduler with this action + symbol
|
||||
startScheduler(action, symbol);
|
||||
startScheduler(action, symbol, stopAfterAll ?? false);
|
||||
|
||||
return NextResponse.json(results);
|
||||
} catch (err: any) {
|
||||
|
||||
Reference in New Issue
Block a user