Fix 期期 sheets bias: split total 2n from same-sheets, not n.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -364,9 +364,11 @@
|
||||
if (!(ratio > 0) || !(ratio < 1)) ratio = 0.7;
|
||||
const splitBy = state.ooBiasSplitBy === "sheets" ? "sheets" : "budget";
|
||||
const pair = costA + costB;
|
||||
let nSame = pair > 0 ? Math.floor(budget / pair + 1e-12) : 0;
|
||||
nSame = capByDepth(nSame, state.legA && state.legA.ask_sz);
|
||||
nSame = capByDepth(nSame, state.legB && state.legB.ask_sz);
|
||||
const nPair = pair > 0 ? Math.floor(budget / pair + 1e-12) : 0;
|
||||
const nSame = Math.min(
|
||||
capByDepth(nPair, state.legA && state.legA.ask_sz),
|
||||
capByDepth(nPair, state.legB && state.legB.ask_sz)
|
||||
);
|
||||
|
||||
let nA = 0;
|
||||
let nB = 0;
|
||||
@@ -381,12 +383,14 @@
|
||||
let nCall = 0;
|
||||
let nPut = 0;
|
||||
if (splitBy === "sheets") {
|
||||
if (nSame < 2) {
|
||||
return { sheetsA: 0, sheetsB: 0, premium: 0, ok: false, msg: "同张数规模不足 2,无法按比例拆分" };
|
||||
// 总张数 = 同张数两侧合计(每腿 n → 共 2n),再按比例拆
|
||||
const total = nSame * 2;
|
||||
if (total < 2) {
|
||||
return { sheetsA: 0, sheetsB: 0, premium: 0, ok: false, msg: "同张数总规模不足 2,无法按比例拆分" };
|
||||
}
|
||||
let majorN = Math.round(nSame * ratio);
|
||||
majorN = Math.max(1, Math.min(majorN, nSame - 1));
|
||||
const minorN = nSame - majorN;
|
||||
let majorN = Math.round(total * ratio);
|
||||
majorN = Math.max(1, Math.min(majorN, total - 1));
|
||||
const minorN = total - majorN;
|
||||
nCall = majorIsCall ? majorN : minorN;
|
||||
nPut = majorIsCall ? minorN : majorN;
|
||||
} else {
|
||||
|
||||
Vendored
+1
-1
@@ -149,7 +149,7 @@ _HEDGE_PLAN_SECTION: dict[str, Any] = {
|
||||
(
|
||||
"HEDGE_PLAN_OO_BIAS_SPLIT_BY",
|
||||
"期期做多做空拆分口径",
|
||||
"默认预算金额;budget=按权利金预算按比例分两腿;sheets=先算同张数 n 再按比例拆张数",
|
||||
"默认预算金额;budget=按权利金预算按比例分两腿;sheets=先算同张数总张数(2n)再按比例拆",
|
||||
),
|
||||
(
|
||||
"HEDGE_PLAN_OO_BIAS_RATIO",
|
||||
|
||||
@@ -243,9 +243,12 @@ def suggest_oo_sheets(
|
||||
return _fail("缺少有效卖一价,无法建议张数")
|
||||
|
||||
pair = cost_a + cost_b
|
||||
n_same = int(math.floor(budget / pair + 1e-12)) if pair > 0 else 0
|
||||
n_same = _cap_sheets_by_ask_depth(n_same, ask_sz_a)
|
||||
n_same = _cap_sheets_by_ask_depth(n_same, ask_sz_b)
|
||||
n_pair = int(math.floor(budget / pair + 1e-12)) if pair > 0 else 0
|
||||
# 与同张数一致:先按预算得 n,再各自深度封顶后取 min
|
||||
n_same = min(
|
||||
_cap_sheets_by_ask_depth(n_pair, ask_sz_a),
|
||||
_cap_sheets_by_ask_depth(n_pair, ask_sz_b),
|
||||
)
|
||||
|
||||
if m == "same_sheets":
|
||||
n_a = n_same
|
||||
@@ -262,11 +265,13 @@ def suggest_oo_sheets(
|
||||
return _fail(err)
|
||||
major_is_call = m == "long_bias"
|
||||
if split_by == "sheets":
|
||||
if n_same < 2:
|
||||
return _fail("同张数规模不足 2,无法按比例拆分")
|
||||
major_n = int(round(n_same * ratio))
|
||||
major_n = max(1, min(major_n, n_same - 1))
|
||||
minor_n = n_same - major_n
|
||||
# 总张数 = 同张数两侧合计(每腿 n → 共 2n),再按比例拆到 Call/Put
|
||||
total = int(n_same) * 2
|
||||
if total < 2:
|
||||
return _fail("同张数总规模不足 2,无法按比例拆分")
|
||||
major_n = int(round(total * ratio))
|
||||
major_n = max(1, min(major_n, total - 1))
|
||||
minor_n = total - major_n
|
||||
n_call = major_n if major_is_call else minor_n
|
||||
n_put = minor_n if major_is_call else major_n
|
||||
else:
|
||||
|
||||
@@ -301,4 +301,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/static/hedge_plan.js?v=23"></script>
|
||||
<script src="/static/hedge_plan.js?v=24"></script>
|
||||
|
||||
Reference in New Issue
Block a user