Fix btc_eth watching entry, preview sizing, and coin-to-U settlement.

Use dual indices for watch/preview; perp entry uses ETH mark; expiry/close convert coin PnL via option index; align legacy long→Call; omit combo U when index missing.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-14 21:52:20 +08:00
parent 450296e04b
commit a841c8f31b
8 changed files with 296 additions and 72 deletions
+15 -8
View File
@@ -2722,7 +2722,8 @@
option_primary: true,
market_order: 1,
direction: getDirection(),
entry: indexPx() || Number((state.market && state.market.mark) || 0),
// entry=永续参考价;跨币用 ETH mark,勿写 BTC 指数
entry: Number(perpIndexPx() || (state.market && state.market.mark) || 0),
contracts: sized.contracts,
sheets: sized.sheets,
contract_size: (state.market && state.market.contract_size) || 0.01,
@@ -2730,7 +2731,7 @@
strike: state.selected.strike,
ct_mult: state.selected.ct_mult || 0.01,
ask: state.selected.ask,
index_px: indexPx() || 0,
index_px: Number(optionIndexPx() || 0),
premium_budget: premBudget > 0 ? premBudget : Math.max(premEst / 0.95, premEst),
option_perp_ratio: numInput("hp-opt-perp-ratio", 2),
option_target_points: optPts,
@@ -3825,12 +3826,15 @@
plan_type: "perp_options",
option_primary: true,
watch_entry: 1,
underlying: state.underlying,
po_mode: state.poMode,
underlying: state.optionUnderly || state.underlying,
option_underlying: state.optionUnderly || state.underlying,
perp_underlying: state.perpUnderly || state.underlying,
direction: getDirection(),
exchange_symbol: state.market.exchange_symbol,
contract_size: state.market.contract_size || 0.01,
index_px: indexPx() || Number(state.market.mark || 0),
entry: indexPx() || Number(state.market.mark || 0),
index_px: Number(optionIndexPx() || 0),
entry: Number(perpIndexPx() || (state.market && state.market.mark) || 0),
premium_budget: prem,
option_perp_ratio: numInput("hp-opt-perp-ratio", 2),
option_target_points: optPts,
@@ -3909,7 +3913,10 @@
throw new Error("门禁未满足,不可开仓: " + gateTxt);
}
const exp = currentExp("hp-exp-select");
const entry = indexPx() || Number((state.market && state.market.mark) || 0);
const optIdx = Number(optionIndexPx() || 0);
const perpIdx = Number(
perpIndexPx() || (state.market && state.market.mark) || 0
);
const premEst =
Number(state.selected.ask || 0) *
sized.sheets *
@@ -3925,7 +3932,7 @@
option_underlying: state.optionUnderly || state.underlying,
perp_underlying: state.perpUnderly || state.underlying,
direction: getDirection(),
entry: Number((state.market && state.market.mark) || entry),
entry: perpIdx,
contracts: sized.contracts,
sheets: sized.sheets,
contract_size: (state.market && state.market.contract_size) || 0.01,
@@ -3934,7 +3941,7 @@
opt_type: state.selected.opt_type,
strike: state.selected.strike,
ask: state.selected.ask,
index_px: entry,
index_px: optIdx,
exchange_symbol: (state.market && state.market.exchange_symbol) || "",
leverage: defaultPerpLeverage(state.perpUnderly || state.underlying),
option_leverage: 0,