feat: add Portfolio Value, Option Value, and Contracts columns to daily results
- Add option_contracts field to BacktestDailyPoint (number of contracts held) - Update engine to calculate total option contracts from positions - Update job serialization to include underlying_value, option_market_value, net_portfolio_value, option_contracts - Update both render_result and render_job_result tables to show: - Low, High, Close (from previous commit) - Portfolio value (net_portfolio_value) - Option value (option_market_value) - Contracts (option_contracts) - LTV hedged - Margin call status
This commit is contained in:
@@ -659,6 +659,24 @@ def _render_backtests_page(workspace_id: str | None = None) -> None:
|
||||
{"name": "low", "label": "Low", "field": "low", "align": "right"},
|
||||
{"name": "high", "label": "High", "field": "high", "align": "right"},
|
||||
{"name": "close", "label": "Close", "field": "close", "align": "right"},
|
||||
{
|
||||
"name": "portfolio_value",
|
||||
"label": "Portfolio",
|
||||
"field": "portfolio_value",
|
||||
"align": "right",
|
||||
},
|
||||
{
|
||||
"name": "option_value",
|
||||
"label": "Option value",
|
||||
"field": "option_value",
|
||||
"align": "right",
|
||||
},
|
||||
{
|
||||
"name": "contracts",
|
||||
"label": "Contracts",
|
||||
"field": "contracts",
|
||||
"align": "right",
|
||||
},
|
||||
{
|
||||
"name": "ltv_hedged",
|
||||
"label": "LTV hedged",
|
||||
@@ -678,6 +696,9 @@ def _render_backtests_page(workspace_id: str | None = None) -> None:
|
||||
"low": f"${point.spot_low:,.2f}",
|
||||
"high": f"${point.spot_high:,.2f}",
|
||||
"close": f"${point.spot_close:,.2f}",
|
||||
"portfolio_value": f"${point.net_portfolio_value:,.0f}",
|
||||
"option_value": f"${point.option_market_value:,.0f}",
|
||||
"contracts": f"{point.option_contracts:,.0f}",
|
||||
"ltv_hedged": f"{point.ltv_hedged:.1%}",
|
||||
"margin_call": "Yes" if point.margin_call_hedged else "No",
|
||||
}
|
||||
@@ -991,6 +1012,24 @@ def _render_backtests_page(workspace_id: str | None = None) -> None:
|
||||
{"name": "low", "label": "Low", "field": "low", "align": "right"},
|
||||
{"name": "high", "label": "High", "field": "high", "align": "right"},
|
||||
{"name": "close", "label": "Close", "field": "close", "align": "right"},
|
||||
{
|
||||
"name": "portfolio_value",
|
||||
"label": "Portfolio",
|
||||
"field": "portfolio_value",
|
||||
"align": "right",
|
||||
},
|
||||
{
|
||||
"name": "option_value",
|
||||
"label": "Option value",
|
||||
"field": "option_value",
|
||||
"align": "right",
|
||||
},
|
||||
{
|
||||
"name": "contracts",
|
||||
"label": "Contracts",
|
||||
"field": "contracts",
|
||||
"align": "right",
|
||||
},
|
||||
{
|
||||
"name": "ltv_hedged",
|
||||
"label": "LTV hedged",
|
||||
@@ -1010,6 +1049,9 @@ def _render_backtests_page(workspace_id: str | None = None) -> None:
|
||||
"low": f"${dp.get('spot_low', dp.get('spot_close', 0)):,.2f}",
|
||||
"high": f"${dp.get('spot_high', dp.get('spot_close', 0)):,.2f}",
|
||||
"close": f"${dp.get('spot_close', 0):,.2f}",
|
||||
"portfolio_value": f"${dp.get('net_portfolio_value', 0):,.0f}",
|
||||
"option_value": f"${dp.get('option_market_value', 0):,.0f}",
|
||||
"contracts": f"{dp.get('option_contracts', 0):,.0f}",
|
||||
"ltv_hedged": f"{dp.get('ltv_hedged', 0):.1%}",
|
||||
"margin_call": "Yes" if dp.get("margin_call_hedged") else "No",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user