Format trade prices to 3 decimals and round on ingest.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+18
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user