simple_portfolio
simple_portfolio copied to clipboard
delta calculation issue
I believe there is a problem with the delta calculation for aggregated positions. In particular, if quantity is >1, the delta should be multiplied by the number of contracts.
This diff should take care of it:
diff --git a/simple_portfolio/calculate.py b/simple_portfolio/calculate.py
index 765278b..90efc93 100644
--- a/simple_portfolio/calculate.py
+++ b/simple_portfolio/calculate.py
@@ -55,6 +55,7 @@ def doit():
ops["return_today"] = ops["market_value"] - ops["pv_prev"]
ops["return_total"] = ops["market_value"] - ops["pv_orig"]
+ ops["delta"] = ops["delta"] * abs(ops["quantity"]) * 100
agg_ops = ( ops[["symbol", "market_value", "return_today", "pv_prev",
"return_total", "pv_orig", "delta", "theta"]].
Apparently delta has the right sign already when exported, but quantity is either positive or negative (bought vs. sold), thus the abs().
@virgilm thanks for the pointer, and the diff. The rest of the greeks probably need to be updated as well.