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

delta calculation issue #11

@virgilm

Description

@virgilm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions