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();
}
export async function stopStrategy(): Promise<StrategyActionResponse> {
const res = await apiRequest("POST", "/strategy/stop");
export async function stopStrategy(mode?: string): Promise<StrategyActionResponse> {
const url = mode ? `/strategy/stop?mode=${encodeURIComponent(mode)}` : "/strategy/stop";
const res = await apiRequest("POST", url);
return res.json();
}
export async function resumeStrategy(): Promise<StrategyActionResponse> {
const res = await apiRequest("POST", "/strategy/resume");
export async function resumeStrategy(mode?: string): Promise<StrategyActionResponse> {
const url = mode ? `/strategy/resume?mode=${encodeURIComponent(mode)}` : "/strategy/resume";
const res = await apiRequest("POST", url);
return res.json();
}

View File

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

View File

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