X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Froutetrade;h=8d425375fe76bbc4544bacfa9bf7172eb937caf0;hb=ff547369a01a5aa73e4a9d665c5567624795ab17;hp=6bc7277d341a69049358dbb40176700657674187;hpb=f41b94c1ec31bbff084b7429c1aec495aca2ab1e;p=ypp-sc-tools.web-live.git diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 6bc7277..8d42537 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -32,6 +32,27 @@ This Mason component is the core trade planner for a specific route. +========== TODO ========== +16:36 alpha,byrne,papaya,turtle,jorvik,luthien is my example + +16:39 Also, maybe colour to highlight the suggested trades? + +16:40 columns should be sortable with the small arrows as before + +16:46 Also trading plan not functional but I guess you know that :-) + +use POST for update. Hrrm. + +LATER OR NOT AT ALL + +adjustable potential cost of losses (rather than fixed 1e-BIG per league) + +max volume/mass + +16:38 I don't know how hard this is, but can you show only the suggested + trades to start ith and have a button to show all? +========== TODO ========== + <%args> $dbh @@ -41,6 +62,8 @@ $qa <%perl> +my $loss_per_league= 1e-7; + my @flow_conds; my @query_params; @@ -116,6 +139,7 @@ my $stmt= " commods.commodid commodid, commods.unitmass unitmass, commods.unitvolume unitvolume, + dist dist, buy.price - sell.price unitprofit FROM commods JOIN buy on commods.commodid = buy.commodid @@ -126,6 +150,7 @@ my $stmt= " JOIN stalls as sell_stalls on sell.stallid = sell_stalls.stallid JOIN stalls as buy_stalls on buy.stallid = buy_stalls.stallid " : "")." + JOIN dists on aiid = sell.islandid AND biid = buy.islandid WHERE ( ".join(" OR ", @flow_conds)." @@ -163,7 +188,7 @@ if ($qa->{ShowStalls}) { } $addcols->({ Text => 1 }, qw(commodname)); $addcols->({}, - qw( org_qty org_price dst_qty dst_price + qw( org_price org_qty dst_price dst_qty Margin unitprofit MaxQty MaxCapital MaxProfit )); @@ -197,6 +222,10 @@ $addcols->({}, $f->{"org_stallid"}= $f->{"dst_stallid"}= 'all' if !$qa->{ShowStalls}; + $f->{ExpectedUnitProfit}= + $f->{'dst_price'} * (1.0 - $loss_per_league) ** $f->{'dist'} + - $f->{'src_price'}; + my @uid= $f->{commodid}; foreach my $od (qw(org dst)) { push @uid, @@ -260,7 +289,8 @@ die "$cmpu $uue ?" if length $cmpu > 20; die "$f->{UidLong} = $f->{UidShort} = $recons_long ?"; } - if ($qa->{"R$f->{UidShort}"} && !$qa->{"T$f->{UidShort}"}) { + if (defined $qa->{"R$f->{UidShort}"} && + !defined $qa->{"T$f->{UidShort}"}) { $f->{Suppress}= 1; } @@ -296,7 +326,9 @@ Maximize totalprofit: ".(join " + - ", map { "$_->{unitprofit} $_->{Var}" } @flows)." + ", map { + sprintf "%.20f %s", $_->{ExpectedUnitProfit}, $_->{Var} + } @flows)." Subject To "; @@ -415,7 +447,7 @@ $addcols->({ Total => 0 }, qw( Profit Max % if ($optimise) { -Suggested +Planned % } @@ -423,10 +455,10 @@ $addcols->({ Total => 0 }, qw( Island <% $cdstall %> Island <% $cdstall %> Commodity -Qty Price Qty Price +Qty Margin Unit Qty