chiark / gitweb /
Fix profit margin
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 24 Aug 2009 13:58:54 +0000 (14:58 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 24 Aug 2009 13:58:54 +0000 (14:58 +0100)
yarrg/web/routetrade

index 91ff421..56a1c38 100644 (file)
@@ -259,6 +259,11 @@ foreach my $f (@flows) {
        $f->{MaxProfit}= $f->{MaxQty} * $f->{'unitprofit'};
        $f->{MaxCapital}= $f->{MaxQty} * $f->{'org_price'};
 
+       $f->{MarginSortKey}= sprintf "%d",
+               $f->{'dst_price'} * 10000 / $f->{'org_price'};
+       $f->{Margin}= sprintf "%3.1f%%",
+               $f->{'dst_price'} * 100.0 / $f->{'org_price'} - 100.0;
+
        $f->{ExpectedUnitProfit}=
                $f->{'dst_price'} * (1.0 - $loss_per_league) ** $f->{'dist'}
                - $f->{'org_price'};