Add Alpha Shield strategy selector to live and paper portfolio pages
Users can now choose between Golden Nifty and Alpha Shield before starting the strategy engine. Selector syncs from saved config on load. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0a024b7ed3
commit
0efff43eac
@ -514,6 +514,7 @@ export default function PortfolioSection() {
|
||||
const [sipAmount, setSipAmount] = useState(5000);
|
||||
const [frequencyValue, setFrequencyValue] = useState(30);
|
||||
const [frequencyUnit, setFrequencyUnit] = useState<"days" | "minutes">("days");
|
||||
const [selectedStrategy, setSelectedStrategy] = useState<"golden_nifty" | "alpha_shield">("golden_nifty");
|
||||
const [strategyStatus, setStrategyStatus] = useState("STOPPED");
|
||||
const [strategyDetails, setStrategyDetails] = useState<StrategyStatusResponse | null>(null);
|
||||
const [isStarting, setIsStarting] = useState(false);
|
||||
@ -542,6 +543,10 @@ export default function PortfolioSection() {
|
||||
if (!freshStartRequested && savedFrequencyUnit) {
|
||||
setFrequencyUnit(savedFrequencyUnit);
|
||||
}
|
||||
const savedStrategy = status?.config?.strategy;
|
||||
if (!freshStartRequested && (savedStrategy === "golden_nifty" || savedStrategy === "alpha_shield")) {
|
||||
setSelectedStrategy(savedStrategy);
|
||||
}
|
||||
} catch (error) {
|
||||
setStrategyDetails(null);
|
||||
setStrategyStatus("STOPPED");
|
||||
@ -1062,7 +1067,7 @@ export default function PortfolioSection() {
|
||||
setIsStarting(true);
|
||||
try {
|
||||
const result = await startStrategy({
|
||||
strategy_name: "Golden Nifty",
|
||||
strategy_name: selectedStrategy,
|
||||
sip_amount: sipAmount,
|
||||
sip_frequency: {
|
||||
value: frequencyValue,
|
||||
@ -1087,7 +1092,7 @@ export default function PortfolioSection() {
|
||||
clearFreshStartPreference();
|
||||
toast({
|
||||
title: "Live strategy started",
|
||||
description: `Golden Nifty is now armed for live ${brokerLabel} execution.`,
|
||||
description: `${selectedStrategy === "alpha_shield" ? "Alpha Shield" : "Golden Nifty"} is now armed for live ${brokerLabel} execution.`,
|
||||
});
|
||||
} else {
|
||||
toast({
|
||||
@ -1544,7 +1549,7 @@ export default function PortfolioSection() {
|
||||
<div className="space-y-1">
|
||||
<p className="text-sm font-semibold">Strategy control</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Start or stop the Golden Nifty SIP engine from the dashboard.
|
||||
Start or stop the {selectedStrategy === "alpha_shield" ? "Alpha Shield" : "Golden Nifty"} SIP engine from the dashboard.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
@ -1566,6 +1571,22 @@ export default function PortfolioSection() {
|
||||
<div className={`text-xs ${eligibilityClass}`}>{eligibilityStatus}</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Strategy</Label>
|
||||
<Select
|
||||
value={selectedStrategy}
|
||||
disabled={!canEditStrategyConfig}
|
||||
onValueChange={(value) => setSelectedStrategy(value as "golden_nifty" | "alpha_shield")}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select strategy" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="golden_nifty">Golden Nifty (NIFTYBEES + GOLDBEES)</SelectItem>
|
||||
<SelectItem value="alpha_shield">Alpha Shield (JUNIORBEES + GOLDBEES)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="strategy-sip">SIP Amount</Label>
|
||||
|
||||
@ -182,6 +182,7 @@ function PaperTradingPortfolio() {
|
||||
const [initialCash, setInitialCash] = useState<number | "">("");
|
||||
const [frequencyValue, setFrequencyValue] = useState(10);
|
||||
const [frequencyUnit, setFrequencyUnit] = useState<"minutes" | "days">("minutes");
|
||||
const [selectedStrategy, setSelectedStrategy] = useState<"golden_nifty" | "alpha_shield">("golden_nifty");
|
||||
const [strategyStatus, setStrategyStatus] = useState("STOPPED");
|
||||
const [strategyDetails, setStrategyDetails] = useState<StrategyStatusResponse | null>(null);
|
||||
const [isStarting, setIsStarting] = useState(false);
|
||||
@ -276,6 +277,10 @@ function PaperTradingPortfolio() {
|
||||
if (!freshStartRequested && savedFrequencyUnit) {
|
||||
setFrequencyUnit(savedFrequencyUnit);
|
||||
}
|
||||
const savedStrategy = status?.config?.strategy;
|
||||
if (!freshStartRequested && (savedStrategy === "golden_nifty" || savedStrategy === "alpha_shield")) {
|
||||
setSelectedStrategy(savedStrategy);
|
||||
}
|
||||
} catch {
|
||||
setStrategyDetails(null);
|
||||
setStrategyStatus("STOPPED");
|
||||
@ -447,7 +452,7 @@ function PaperTradingPortfolio() {
|
||||
setIsStarting(true);
|
||||
try {
|
||||
const result = await startStrategy({
|
||||
strategy_name: "Golden Nifty",
|
||||
strategy_name: selectedStrategy,
|
||||
initial_cash: initialCash,
|
||||
sip_amount: sipAmount,
|
||||
sip_frequency: {
|
||||
@ -774,7 +779,7 @@ function PaperTradingPortfolio() {
|
||||
<div className="space-y-1">
|
||||
<p className="text-sm font-semibold">Strategy control</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Start or stop the Golden Nifty SIP engine from the dashboard.
|
||||
Start or stop the {selectedStrategy === "alpha_shield" ? "Alpha Shield" : "Golden Nifty"} SIP engine from the dashboard.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
@ -801,6 +806,22 @@ function PaperTradingPortfolio() {
|
||||
<div className={`text-xs ${eligibilityClass}`}>{eligibilityStatus}</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>Strategy</Label>
|
||||
<Select
|
||||
value={selectedStrategy}
|
||||
disabled={strategyLocked}
|
||||
onValueChange={(value) => setSelectedStrategy(value as "golden_nifty" | "alpha_shield")}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select strategy" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="golden_nifty">Golden Nifty (NIFTYBEES + GOLDBEES)</SelectItem>
|
||||
<SelectItem value="alpha_shield">Alpha Shield (JUNIORBEES + GOLDBEES)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="paper-initial-cash">Initial Cash (Paper)</Label>
|
||||
<Input
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user