feat: Introduce dynamic position sizing based on market conditions and enhance trading report with grouped positions and ROI.
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = (
|
||||
|
||||
Reference in New Issue
Block a user