Skip to content

% of profit calculation includes commission only on one part of the calculation #10

@antamy

Description

@antamy

When calculating % of profit, the code subtracts the commission from the total profit, but not from the max profit. It should deduct it from both, since your max profit obviously also is reduced by commissions you pay.

func (o *Option) CalculateTotalProfit() float64 {
	exitPrice := 0.0
	if o.ExitPrice != nil {
		exitPrice = *o.ExitPrice
	}
	profit := math.Floor((o.Premium - exitPrice) * float64(o.Contracts) * 100)
	return profit - o.Commission // Subtract commission for accurate net profit
}

func (o *Option) CalculatePercentOfProfit() float64 {
	if o.Premium == 0 {
		return 0
	}
	maxProfit := o.Premium * float64(o.Contracts) * 100
	actualProfit := o.CalculateTotalProfit()
	return (actualProfit / maxProfit) * 100
}

I think also that commissions in general need beefing up, since the data entry dialog requires you to manually total the commission for opening and closing the position. This could be a configurable item so it is not needed to be entered at all.

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