feat: Introduce dynamic position sizing based on market conditions and enhance trading report with grouped positions and ROI.

This commit is contained in:
2569718930@qq.com
2026-02-06 20:11:01 +08:00
parent 81b3736ea1
commit df2117afe8
4 changed files with 125 additions and 20 deletions
+3 -1
View File
@@ -43,7 +43,7 @@ class PaperTrader:
indent=2,
)
def open_position(self, market_id: str, city: str, option: str, price: int, side: str, amount_usd: float = 5.0):
def open_position(self, market_id: str, city: str, option: str, price: int, side: str, amount_usd: float = 5.0, target_date: str = None, predicted_temp: float = None):
"""
开仓进入模拟仓位
"""
@@ -76,6 +76,8 @@ class PaperTrader:
"pnl_usd": 0.0,
"pnl_pct": 0.0,
"status": "OPEN",
"target_date": target_date,
"predicted_temp": predicted_temp,
"opened_at": (datetime.utcnow() + timedelta(hours=8)).strftime("%Y-%m-%d %H:%M:%S")
}
+7 -1
View File
@@ -132,7 +132,13 @@ class TelegramNotifier:
items_text = ""
for a in alerts:
type_icon = "" if a["type"] == "price" else "🐋"
buy_tag = " [🛒 模拟仓已买入]" if a.get("bought") else ""
# 买入标签:显示金额
if a.get("bought"):
amount = a.get("amount", 5.0)
confidence = a.get("confidence", "")
buy_tag = f" [🛒 ${amount} {confidence}]"
else:
buy_tag = ""
items_text += f"{type_icon} <b>{a['market']}</b>: {a['msg']}{buy_tag}\n"
text = (