feat: pass mode when stopping/resuming strategy

stopStrategy and resumeStrategy now accept an optional mode string
and append ?mode= to the API call. PaperPortfolio passes PAPER,
PortfolioSection passes LIVE, so each page only stops its own run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Thigazhezhilan J 2026-06-03 22:11:36 +05:30
parent e19440b438
commit caa3fc8838
3 changed files with 8 additions and 6 deletions

View File

@ -48,13 +48,15 @@ export async function startStrategy(data: StrategyStartRequest): Promise<Strateg
return res.json(); return res.json();
} }
export async function stopStrategy(): Promise<StrategyActionResponse> { export async function stopStrategy(mode?: string): Promise<StrategyActionResponse> {
const res = await apiRequest("POST", "/strategy/stop"); const url = mode ? `/strategy/stop?mode=${encodeURIComponent(mode)}` : "/strategy/stop";
const res = await apiRequest("POST", url);
return res.json(); return res.json();
} }
export async function resumeStrategy(): Promise<StrategyActionResponse> { export async function resumeStrategy(mode?: string): Promise<StrategyActionResponse> {
const res = await apiRequest("POST", "/strategy/resume"); const url = mode ? `/strategy/resume?mode=${encodeURIComponent(mode)}` : "/strategy/resume";
const res = await apiRequest("POST", url);
return res.json(); return res.json();
} }

View File

@ -1193,7 +1193,7 @@ export default function PortfolioSection() {
const handleStop = async () => { const handleStop = async () => {
setIsStopping(true); setIsStopping(true);
try { try {
const result = await stopStrategy(); const result = await stopStrategy("LIVE");
if (result?.status === "stopped") { if (result?.status === "stopped") {
clearFreshStartPreference(); clearFreshStartPreference();
if (result?.warning) { if (result?.warning) {

View File

@ -548,7 +548,7 @@ function PaperTradingPortfolio() {
const handleStop = async () => { const handleStop = async () => {
setIsStopping(true); setIsStopping(true);
try { try {
await stopStrategy(); await stopStrategy("PAPER");
setFreshStartRequested(false); setFreshStartRequested(false);
toast({ toast({
title: "Paper strategy stopped", title: "Paper strategy stopped",