Fix positions 500 when recommend row lacks turnover field.
Use Jinja defined check in trade template and always set turnover key (or null) when enriching recommend rows. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -141,9 +141,12 @@ def _attach_turnover(row: dict) -> None:
|
||||
price = float(row.get("prev_close") or row.get("price") or 0)
|
||||
mult = float(row.get("mult") or 0)
|
||||
except (TypeError, ValueError):
|
||||
row["turnover"] = None
|
||||
return
|
||||
if vol > 0 and price > 0 and mult > 0:
|
||||
row["turnover"] = round(vol * price * mult, 2)
|
||||
else:
|
||||
row["turnover"] = None
|
||||
|
||||
|
||||
def _letters_from_ths(ths_code: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user