Add fixed-direction switch for perp/option open side.

When enabled, lock perp long→buy Put or short→buy Call with ITM/ATM only; off keeps ATM/ask rules.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-29 19:18:12 +08:00
parent 55109e82d3
commit 0ee1d8be5d
16 changed files with 427 additions and 46 deletions
+43 -3
View File
@@ -74,6 +74,8 @@ export default function SettingsPage() {
const [minOptLev, setMinOptLev] = useState(100);
const [atmOffOn, setAtmOffOn] = useState(false);
const [maxAtmOff, setMaxAtmOff] = useState(3);
const [fixedDirOn, setFixedDirOn] = useState(false);
const [fixedPerpSide, setFixedPerpSide] = useState<"long" | "short">("long");
const [closeDevPct, setCloseDevPct] = useState(30);
const [perpQty, setPerpQty] = useState(1);
const [optQty, setOptQty] = useState(2);
@@ -158,6 +160,8 @@ export default function SettingsPage() {
setMinOptLev(s.min_option_leverage ?? 100);
setAtmOffOn(s.atm_open_offset_enabled === true);
setMaxAtmOff(s.max_atm_open_offset ?? 3);
setFixedDirOn(s.fixed_direction_enabled === true);
setFixedPerpSide(s.fixed_perp_side === "short" ? "short" : "long");
setCloseDevPct(s.close_bid_mark_max_pct ?? 30);
setPerpQty(s.perp_qty_eth ?? 1);
setOptQty(s.option_qty_eth ?? 2);
@@ -302,6 +306,8 @@ export default function SettingsPage() {
min_option_leverage: minOptLev,
atm_open_offset_enabled: atmOffOn,
max_atm_open_offset: maxAtmOff,
fixed_direction_enabled: fixedDirOn,
fixed_perp_side: fixedPerpSide,
close_bid_mark_max_pct: closeDevPct,
perp_qty_eth: perpQty,
option_qty_eth: optQty,
@@ -610,11 +616,41 @@ export default function SettingsPage() {
onChange={(e) => setMinOptLev(Number(e.target.value))}
/>
</div>
<div className="field">
<label htmlFor="fixedDirOn"></label>
<select
id="fixedDirOn"
className="mono"
value={fixedDirOn ? "1" : "0"}
onChange={(e) => setFixedDirOn(e.target.value === "1")}
>
<option value="0"></option>
<option value="1"></option>
</select>
</div>
<div className="field">
<label htmlFor="fixedPerp"></label>
<select
id="fixedPerp"
className="mono"
disabled={!fixedDirOn}
value={fixedPerpSide}
onChange={(e) =>
setFixedPerpSide(
e.target.value === "short" ? "short" : "long",
)
}
>
<option value="long"> · Put/</option>
<option value="short"> · Call/</option>
</select>
</div>
<div className="field">
<label htmlFor="atmoffOn"> ATM </label>
<select
id="atmoffOn"
className="mono"
disabled={fixedDirOn}
value={atmOffOn ? "1" : "0"}
onChange={(e) => setAtmOffOn(e.target.value === "1")}
>
@@ -630,7 +666,7 @@ export default function SettingsPage() {
type="number"
step="0.5"
min="0"
disabled={!atmOffOn}
disabled={!atmOffOn || fixedDirOn}
value={maxAtmOff}
onChange={(e) => setMaxAtmOff(Number(e.target.value))}
/>
@@ -803,11 +839,15 @@ export default function SettingsPage() {
{stratSub === "select" ? (
<>
<li>
ATM |ATM
Put
Call ATM/
</li>
<li>
ATM |ATM
|
</li>
<li>
ATM
ATM
</li>
</>
) : null}