Add Random direction option — picks Buy or Sell once per batch

All accounts in the same batch trade the same resolved direction.
Each new batch (after positions are flat) picks a fresh random direction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Senofy
2026-03-10 03:35:50 -05:00
co-authored by Claude Sonnet 4.6
parent 8848f90b11
commit a13096ea86
3 changed files with 23 additions and 13 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ import { POINT_VALUES } from '@/lib/trading-logic';
export async function POST(req: NextRequest) {
try {
const body = await req.json() as { action: 'Buy' | 'Sell'; symbol: string };
const body = await req.json() as { action: 'Buy' | 'Sell' | 'Random'; symbol: string };
const { action, symbol } = body;
if (!action || !symbol) {
+8 -2
View File
@@ -247,7 +247,7 @@ function FirmRows({ state, firm, deleteMode, selected, onToggle, hideDead, priva
interface SchedulerStatus {
running: boolean;
action: 'Buy' | 'Sell';
action: 'Buy' | 'Sell' | 'Random';
symbol: string;
lastRun: string | null;
}
@@ -267,7 +267,7 @@ export default function Home() {
const [scheduler, setScheduler] = useState<SchedulerStatus>({ running: false, action: 'Buy', symbol: 'NQ', lastRun: null });
const [enabledSymbols, setEnabledSymbols] = useState<string[]>([]);
const [tradeSymbol, setTradeSymbol] = useState('');
const [tradeAction, setTradeAction] = useState<'Buy' | 'Sell'>('Buy');
const [tradeAction, setTradeAction] = useState<'Buy' | 'Sell' | 'Random'>('Buy');
const [tradeLoading, setTradeLoading] = useState(false);
const handleSort = (col: SortKey) => {
@@ -487,6 +487,12 @@ export default function Home() {
>
Sell
</button>
<button
onClick={() => setTradeAction('Random')}
className={`px-3 py-1.5 transition-colors border-l border-slate-200 ${tradeAction === 'Random' ? 'bg-purple-500 text-white' : 'text-slate-500 hover:bg-slate-50'}`}
>
Random
</button>
</div>
</div>
<button