修改斐波平仓后交易记录识别
This commit is contained in:
@@ -40,6 +40,7 @@ from fib_key_monitor_lib import (
|
|||||||
fib_invalidate_by_mark,
|
fib_invalidate_by_mark,
|
||||||
fib_ratio_from_type,
|
fib_ratio_from_type,
|
||||||
is_fib_key_monitor_type,
|
is_fib_key_monitor_type,
|
||||||
|
key_signal_type_for_trade_record,
|
||||||
stored_key_signal_type,
|
stored_key_signal_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -2026,9 +2027,7 @@ def insert_trade_record(
|
|||||||
close_ts = closed_at or app_now_str()
|
close_ts = closed_at or app_now_str()
|
||||||
open_ts_ms = _to_ms_with_fallback(opened_at_ms, open_ts)
|
open_ts_ms = _to_ms_with_fallback(opened_at_ms, open_ts)
|
||||||
close_ts_ms = _to_ms_with_fallback(closed_at_ms, close_ts)
|
close_ts_ms = _to_ms_with_fallback(closed_at_ms, close_ts)
|
||||||
kst = (key_signal_type or "").strip()
|
kst = key_signal_type_for_trade_record(key_signal_type, KEY_MONITOR_AUTO_TYPES)
|
||||||
if kst not in KEY_MONITOR_AUTO_TYPES:
|
|
||||||
kst = None
|
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"INSERT INTO trade_records (symbol,monitor_type,key_signal_type,direction,trigger_price,stop_loss,initial_stop_loss,take_profit,margin_capital,leverage,pnl_amount,hold_seconds,trade_style,risk_amount,planned_rr,actual_rr,hold_minutes,opened_at,opened_at_ms,closed_at,closed_at_ms,result,miss_reason,exchange_trade_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
"INSERT INTO trade_records (symbol,monitor_type,key_signal_type,direction,trigger_price,stop_loss,initial_stop_loss,take_profit,margin_capital,leverage,pnl_amount,hold_seconds,trade_style,risk_amount,planned_rr,actual_rr,hold_minutes,opened_at,opened_at_ms,closed_at,closed_at_ms,result,miss_reason,exchange_trade_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ from fib_key_monitor_lib import (
|
|||||||
fib_invalidate_by_mark,
|
fib_invalidate_by_mark,
|
||||||
fib_ratio_from_type,
|
fib_ratio_from_type,
|
||||||
is_fib_key_monitor_type,
|
is_fib_key_monitor_type,
|
||||||
|
key_signal_type_for_trade_record,
|
||||||
stored_key_signal_type,
|
stored_key_signal_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -2004,9 +2005,7 @@ def insert_trade_record(
|
|||||||
close_ts = closed_at or app_now_str()
|
close_ts = closed_at or app_now_str()
|
||||||
open_ts_ms = _to_ms_with_fallback(opened_at_ms, open_ts)
|
open_ts_ms = _to_ms_with_fallback(opened_at_ms, open_ts)
|
||||||
close_ts_ms = _to_ms_with_fallback(closed_at_ms, close_ts)
|
close_ts_ms = _to_ms_with_fallback(closed_at_ms, close_ts)
|
||||||
kst = (key_signal_type or "").strip()
|
kst = key_signal_type_for_trade_record(key_signal_type, KEY_MONITOR_AUTO_TYPES)
|
||||||
if kst not in KEY_MONITOR_AUTO_TYPES:
|
|
||||||
kst = None
|
|
||||||
conn.execute(
|
conn.execute(
|
||||||
"INSERT INTO trade_records (symbol,monitor_type,key_signal_type,direction,trigger_price,stop_loss,initial_stop_loss,take_profit,margin_capital,leverage,pnl_amount,hold_seconds,trade_style,risk_amount,planned_rr,actual_rr,hold_minutes,opened_at,opened_at_ms,closed_at,closed_at_ms,result,miss_reason,exchange_trade_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
"INSERT INTO trade_records (symbol,monitor_type,key_signal_type,direction,trigger_price,stop_loss,initial_stop_loss,take_profit,margin_capital,leverage,pnl_amount,hold_seconds,trade_style,risk_amount,planned_rr,actual_rr,hold_minutes,opened_at,opened_at_ms,closed_at,closed_at_ms,result,miss_reason,exchange_trade_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||||
(
|
(
|
||||||
@@ -6740,7 +6739,8 @@ def del_order(id):
|
|||||||
insert_trade_record(
|
insert_trade_record(
|
||||||
conn,
|
conn,
|
||||||
symbol=row["symbol"],
|
symbol=row["symbol"],
|
||||||
monitor_type="下单监控",
|
monitor_type=order_row_monitor_type(row),
|
||||||
|
key_signal_type=order_row_key_signal_type(row),
|
||||||
direction=row["direction"],
|
direction=row["direction"],
|
||||||
trigger_price=row["trigger_price"],
|
trigger_price=row["trigger_price"],
|
||||||
stop_loss=row["stop_loss"],
|
stop_loss=row["stop_loss"],
|
||||||
|
|||||||
@@ -48,6 +48,16 @@ def stored_key_signal_type(monitor_type):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def key_signal_type_for_trade_record(key_signal_type, box_auto_types):
|
||||||
|
"""平仓写入 trade_records 时保留箱体/收敛/斐波来源。"""
|
||||||
|
kst = (key_signal_type or "").strip()
|
||||||
|
if kst in FIB_KEY_MONITOR_TYPES:
|
||||||
|
return kst
|
||||||
|
if box_auto_types and kst in box_auto_types:
|
||||||
|
return kst
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def fib_invalidate_by_mark(direction, mark_price, upper, lower):
|
def fib_invalidate_by_mark(direction, mark_price, upper, lower):
|
||||||
"""先触达止盈侧(标记价)则失效。多:mark>=H;空:mark<=L。"""
|
"""先触达止盈侧(标记价)则失效。多:mark>=H;空:mark<=L。"""
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user