Format trade prices to 3 decimals and round on ingest.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-21 10:30:21 +08:00
parent c436b76e64
commit a6062fbacc
4 changed files with 49 additions and 11 deletions
+18 -4
View File
@@ -662,10 +662,10 @@ def register_routes(app: Flask) -> None:
ticket = str(data.get("ticket") or "").strip()
symbol = (data.get("symbol") or "XAUUSD").upper()
side = (data.get("side") or "").lower()
volume = float(data.get("volume") or 0)
open_price = float(data.get("open_price") or 0)
volume = round(float(data.get("volume") or 0), 4)
open_price = round(float(data.get("open_price") or 0), 3)
close_price = (
float(data.get("close_price") or 0)
round(float(data.get("close_price") or 0), 3)
if data.get("close_price") is not None
else None
)
@@ -674,9 +674,23 @@ def register_routes(app: Flask) -> None:
if data.get("profit") is None:
profit = None
else:
profit = float(data.get("profit") or 0)
profit = round(float(data.get("profit") or 0), 2)
sl = data.get("sl")
tp = data.get("tp")
if sl is not None and sl != "":
try:
sl = round(float(sl), 3)
except (TypeError, ValueError):
sl = None
else:
sl = None
if tp is not None and tp != "":
try:
tp = round(float(tp), 3)
except (TypeError, ValueError):
tp = None
else:
tp = None
entry_style = (data.get("entry_style") or "").strip()
review_note = (data.get("review_note") or "").strip()
snap_json = json.dumps(snapshot, ensure_ascii=False)