feat: 交易记录增加保证金占比与最新资金,上方展示资金曲线
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+8
-2
@@ -11,6 +11,7 @@ from zoneinfo import ZoneInfo
|
||||
from contract_specs import calc_position_metrics
|
||||
from ctp_symbol import ths_to_vnpy_symbol
|
||||
from fee_specs import calc_round_trip_fee
|
||||
from trade_log_lib import calc_equity_after
|
||||
from market_sessions import is_trading_session
|
||||
from symbols import ths_to_codes
|
||||
from vnpy_bridge import (
|
||||
@@ -220,6 +221,8 @@ def write_trade_log(
|
||||
sym, entry, close_price, lots, open_time, close_time, trading_mode=trading_mode,
|
||||
)
|
||||
pnl_net = round(pnl - fee, 2)
|
||||
margin_pct = metrics.get("position_pct")
|
||||
equity_after = calc_equity_after(capital, pnl_net)
|
||||
|
||||
try:
|
||||
from app import holding_to_minutes
|
||||
@@ -231,8 +234,9 @@ def write_trade_log(
|
||||
"""INSERT INTO trade_logs
|
||||
(symbol, symbol_name, market_code, sina_code, monitor_type, direction,
|
||||
entry_price, stop_loss, take_profit, close_price, lots, margin,
|
||||
holding_minutes, open_time, close_time, pnl, fee, pnl_net, result)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""",
|
||||
margin_pct, holding_minutes, open_time, close_time, pnl, fee, pnl_net,
|
||||
equity_after, result)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)""",
|
||||
(
|
||||
sym,
|
||||
symbol_name,
|
||||
@@ -246,12 +250,14 @@ def write_trade_log(
|
||||
close_price,
|
||||
lots,
|
||||
metrics.get("margin"),
|
||||
margin_pct,
|
||||
minutes,
|
||||
open_time,
|
||||
close_time,
|
||||
pnl,
|
||||
fee,
|
||||
pnl_net,
|
||||
equity_after,
|
||||
result if result in TRADE_RESULTS else "手动平仓",
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user