Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix problem where matrix didn't update when bought/sold stocks

  • Loading branch information...
commit 72e3b24edc6500f71d94f58f214ec46f410c0a65 1 parent 1094771
@ajablonski authored
Showing with 8 additions and 5 deletions.
  1. +8 −5 portfolio.pl
View
13 portfolio.pl
@@ -88,7 +88,6 @@
my @covarMatrixLines;
my $covarMatrixCookieOut;
-my $test;
my $covarMatrixCookieIn = cookie($covarMatrixCookieName);
my ($oldStart, $oldEnd, $oldDoCorrCoeff, $oldPortID, $oldMatrix);
@@ -100,16 +99,15 @@
$covarMatrixCookieOut = cookie(-name=>$covarMatrixCookieName,
-value=>$covarMatrixCookieIn);
@covarMatrixLines = split("//", $oldMatrix);
- $test =1;
} else {
if ($doCorrCoeff == 1) {
@covarMatrixLines = split("\n", `./get_covar.pl --from='$start' --to='$end' --corrcoeff $stockArgList`);
} else {
@covarMatrixLines = split("\n", `./get_covar.pl --from='$start' --to='$end' $stockArgList`);
}
- $test = join("::", $start, $end, $doCorrCoeff, $portID, join("//", @covarMatrixLines));
+ my $data = join("::", $start, $end, $doCorrCoeff, $portID, join("//", @covarMatrixLines));
$covarMatrixCookieOut = cookie(-name=>$covarMatrixCookieName,
- -value=>$test);
+ -value=>$data);
}
push(@cookies, $covarMatrixCookieOut);
@@ -150,6 +148,8 @@
########################
if (defined($action) and defined($run) and $run) {
+
+ my $resetCovar = 0;
if ($action eq 'deposit') {
my $amount = param('amount');
eval {
@@ -170,6 +170,7 @@
eval {
BuySellStock($dbuser, $dbpasswd, $shares, $stock, $price, $portID);
};
+ $resetCovar = 1;
$error = $@;
} elsif ($action eq 'addData') {
my $high = param('high');
@@ -187,7 +188,9 @@
};
$error = $@;
}
- print redirect("portfolio.pl?portID=$portID");
+ my @outCookies = refreshCookies();
+ push(@outCookies, cookie(-name=>$covarMatrixCookieName, -expires=>'-1h', -value=>'0')) if $resetCovar;
+ print redirect(-uri=>"portfolio.pl?portID=$portID", -cookie=>\@outCookies);
}
########################
Please sign in to comment.
Something went wrong with that request. Please try again.