Maspear / jbooktrader

Automatically exported from code.google.com/p/jbooktrader
0 stars 0 forks source link

Bug in Calculation of Commission Fees #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Bundled North American share price is $1 
2. Order Size 100 shares
-------------------------
What is the expected output? What do you see instead?

Fee should be $1, but output gives $0.50
-------------------------
What version of the product are you using? On what operating system?

Version 5.04, Windows 
-------------------------
Please provide any additional information below.

The problem occurs for cases where the "minimum" commission is greater than
the "maximumCommission" as the case above describes.  The default code is

    public double getCommission(int contracts, double price) {
        double commission = rate * contracts;
        commission = Math.max(commission, minimum);
        if (maximumPercent > 0) {
            double maximumCommission = contracts * price * maximumPercent;
            commission = Math.min(commission, maximumCommission);
        }

        return commission;
    }

To fix it, just swap some lines as follows

    public double getCommission(int contracts, double price) {
        double commission = rate * contracts;
        if (maximumPercent > 0) {
            double maximumCommission = contracts * price * maximumPercent;
            commission = Math.min(commission, maximumCommission);
        }
        commission = Math.max(commission, minimum); ////////**********
        return commission;
    }

Original issue reported on code.google.com by endosc...@gmail.com on 29 Aug 2008 at 7:13

GoogleCodeExporter commented 9 years ago
Thanks for reporting. This will be fixed in the next release.

Original comment by eugene.k...@gmail.com on 29 Aug 2008 at 2:26

GoogleCodeExporter commented 9 years ago
Fixed in release 5.05.

Original comment by eugene.k...@gmail.com on 30 Aug 2008 at 2:50