修复币本位统计:开仓成本按预算/开仓指数计,不再用平仓价重估。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -426,6 +426,7 @@ def open_coin_option_buy_full(
|
||||
|
||||
# 开仓手续费(折权利金单位);优先成交回包,否则查单
|
||||
open_fee = 0.0
|
||||
idx_open = None
|
||||
try:
|
||||
from lib.options.options_pnl_settle_lib import (
|
||||
extract_order_fee,
|
||||
@@ -438,7 +439,7 @@ def open_coin_option_buy_full(
|
||||
ex,
|
||||
inst_id=inst_id,
|
||||
underlying=underlying,
|
||||
hint=(q.get("index_px") if isinstance(q, dict) else None),
|
||||
hint=(q.get("index_px") if isinstance(q, dict) else None) or idx,
|
||||
)
|
||||
fee_hint, fee_ccy_hint = extract_order_fee(order if isinstance(order, dict) else None)
|
||||
if fee_hint <= 0 and isinstance(fill, dict):
|
||||
@@ -500,6 +501,7 @@ def open_coin_option_buy_full(
|
||||
budget_usdt=buy_usdt,
|
||||
premium_ccy=premium_ccy,
|
||||
open_fee=open_fee,
|
||||
open_index_px=idx_open,
|
||||
profit_exit_enabled=profit_exit_enabled,
|
||||
profit_exit_mult=profit_exit_mult,
|
||||
)
|
||||
@@ -573,15 +575,22 @@ def _insert_coin_trade(conn: Any, **kwargs: Any) -> int:
|
||||
if open_fee < 0:
|
||||
open_fee = abs(open_fee)
|
||||
fee_ccy = str(kwargs.get("premium_ccy") or "ETH")
|
||||
open_index_px = kwargs.get("open_index_px")
|
||||
try:
|
||||
open_index_px = float(open_index_px) if open_index_px is not None else None
|
||||
if open_index_px is not None and open_index_px <= 0:
|
||||
open_index_px = None
|
||||
except (TypeError, ValueError):
|
||||
open_index_px = None
|
||||
cur = conn.execute(
|
||||
"""
|
||||
INSERT INTO options_trades(
|
||||
inst_id, underlying, opt_type, strike, exp_time, sheets, eth_amount,
|
||||
open_quote, premium_paid, status, signal_note, exchange_ord_id,
|
||||
margin_mode, premium_ccy, bridge_id, budget_usdt,
|
||||
open_fee, fee_ccy,
|
||||
open_fee, fee_ccy, open_index_px,
|
||||
profit_exit_enabled, profit_exit_mult, profit_exit_state, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'open', ?, ?, 'coin', ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'open', ?, ?, 'coin', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
kwargs["inst_id"],
|
||||
@@ -600,6 +609,7 @@ def _insert_coin_trade(conn: Any, **kwargs: Any) -> int:
|
||||
kwargs.get("budget_usdt"),
|
||||
open_fee,
|
||||
fee_ccy,
|
||||
open_index_px,
|
||||
pe,
|
||||
pe_mult,
|
||||
pe_state,
|
||||
|
||||
Reference in New Issue
Block a user