Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

delta calculation issue #11

Open
virgilm opened this issue Nov 21, 2018 · 1 comment
Open

delta calculation issue #11

virgilm opened this issue Nov 21, 2018 · 1 comment

Comments

@virgilm
Copy link

virgilm commented Nov 21, 2018

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().

@westonplatter
Copy link
Owner

@virgilm thanks for the pointer, and the diff. The rest of the greeks probably need to be updated as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants