chiark / gitweb /
Show expected profit in voyage trading plan
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 4 Oct 2009 21:46:08 +0000 (22:46 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 4 Oct 2009 23:22:05 +0000 (00:22 +0100)
yarrg/web/routetrade

index d7679f8762a872cb00f548dcc19af92b2f36a763..f9ebfeaf3f60fa783ce8c796090906d38c4eefc0 100644 (file)
@@ -57,6 +57,7 @@ my $now= time;
 my @flow_conds;
 my @query_params;
 my %dists;
+my $expected_total_profit;
 
 my $sd_condition= sub {
        my ($bs, $ix) = @_;
@@ -526,6 +527,9 @@ if ($qa->{'debug'}) {
                        $found_section= 1;
                        next;
                }
+               if (m/^Objective:\s+totalprofit = (\d+\.\d*) /) {
+                       $expected_total_profit= $1;
+               }
                next unless $found_section==1;
                if (!length $continuation) {
                        next if !$continuation &&  m/^[- ]+$/;
@@ -876,6 +880,9 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw(
  %></strong>
 </table>
 <& query_age:dataages, id2age => \%da_ages &>
+Expected average profit:
+ approx. <strong><% sprintf "%d", $expected_total_profit %></strong> poe
+ (considering expected losses, but ignoring rum consumed)
 %
 % } # ========== TRADING PLAN ==========