#!/usr/bin/perl # # $Id: disp-quotes.cgi,v 1.1 2002/11/17 01:26:45 sulrich Exp $ # my %settings = ( # directory where you'll find the templates TEMPLATE_DIR => "/var/www/htdocs/dack.com/war/portfolio", # TEMPLATE_DIR => "c:\\dwnload\\dack", # the output for the getQuote.pl process that you're running from cron QUOTE_FILE => "/var/www/htdocs/dack.com/cgi-bin/stocks/quotes.txt", # QUOTE_FILE => "c:\\dwnload\\dack\\quotes.txt", # the original price of the stocks as of 11/22/2002 or whenever you want. QUOTE_ORIG_FILE => "/var/www/htdocs/dack.com/cgi-bin/stocks/start-quotes.txt", # QUOTE_ORIG_FILE => "c:\\dwnload\\dack\\tmpquotes.txt", # the color for the text when the stock price goes up POS_COLOR => "green", # the color for the text when the stock price goes down NEG_COLOR => "red", ); # path to the template which defines the layout for a single quote my $stock_line = &getTemplate("$settings{TEMPLATE_DIR}/stock-list.html"); #my $stock_line = &getTemplate("$settings{TEMPLATE_DIR}\\stock-list.html"); # path to the template which defines the layout for body of the quote # collection my $stock_body = &getTemplate("$settings{TEMPLATE_DIR}/stock-body.html"); #my $stock_body = &getTemplate("$settings{TEMPLATE_DIR}\\stock-body.html"); # no user serviceable parts below this line #--------------------------------------------------------------------- use Text::ParseWords; $b_vars{stock_list} = ""; $b_origvars{stock_list} = ""; %origvars = (); %sumvars = (); open(ORIGQUOTES, "$settings{QUOTE_ORIG_FILE}") || die "error opening: $settings{'QUOTE_ORIG_FILE'}"; while( ) { ( $origvars{symbol}, $origvars{last}, $origvars{date}, $origvars{time}, $origvars{delta}, $origvars{open}, $origvars{high}, $origvars{low}, # day low $origvars{vol}, # volumn )= quotewords(",", 0, $_); $origvars{delta} = sprintf("%.2f", $origvars{delta}); $origvars{last} = sprintf("%.2f", $origvars{last}); if($origvars{symbol} !~ /\^/) { if($origvars{symbol} =~ /BA/) { $mult = 2.94; } elsif ($origvars{symbol} =~ /NOC/) { $mult = 1.03/2; } elsif ($origvars{symbol} =~ /ATK/) { $mult = 1.69; } elsif ($origvars{symbol} =~ /RTN/) { $mult = 3.43; } elsif ($origvars{symbol} =~ /LMT/) { $mult = 1.92; } $b_vars{olddelta} += $origvars{delta} * $mult; $b_vars{old} += $origvars{last} * $mult; } else { if($origvars{symbol} =~ /\^DJI/) { $b_vars{djioriglast} = $origvars{last}; } elsif ($origvars{symbol} =~ /\^IXIC/) { $b_vars{nasdaqoriglast} = $origvars{last}; } elsif ($origvars{symbol} =~ /\^GSPC/) { $b_vars{snporiglast} = $origvars{last}; } } if ($origvars{delta} =~ /-/) { $origvars{'color'} = $settings{NEG_COLOR}; $origvars{$origvars{symbol}}{'color'} = $settings{NEG_COLOR}; } else { $origvars{'color'} = $settings{POS_COLOR}; $origvars{$origvars{symbol}}{'color'} = $settings{POS_COLOR}; } # make sure that we have a correctly formed in here if (($origvars{date} =~ /^\d/) && ($origvars{time} =~ /^\d/)) { $b_origvars{date} = $origvars{date}; $b_origvars{time} = $origvars{time}; } } close(ORIGQUOTES); open(QUOTES, "$settings{QUOTE_FILE}") || die "error opening: $settings{'QUOTE_FILE'}"; while( ) { my %vars = (); ( $vars{symbol}, $vars{last}, $vars{date}, $vars{time}, $vars{delta}, $vars{open}, $vars{high}, $vars{low}, # day low $vars{vol}, # volumn )= quotewords(",", 0, $_); if($vars{symbol} !~ /\^/) { if($vars{symbol} =~ /BA/) { $mult = 2.94; } elsif ($vars{symbol} =~ /NOC/) { $mult = 1.03/2; } elsif ($vars{symbol} =~ /ATK/) { $mult = 1.69; } elsif ($vars{symbol} =~ /RTN/) { $mult = 3.43; } elsif ($vars{symbol} =~ /LMT/) { $mult = 1.92; } $b_vars{newdelta} += $vars{delta} * $mult; $b_vars{new} += $vars{last} * $mult; } else { if($vars{symbol} =~ /\^DJI/) { $b_vars{djilast} = sprintf("%.2f", $vars{last}); $b_vars{djipwp} = ($vars{last} - $b_vars{djioriglast})/$b_vars{djioriglast} * 100; if($b_vars{djipwp} =~ /-/) { $b_vars{djipwp} = sprintf("- %.2f\%", abs($b_vars{djipwp})); } else { $b_vars{djipwp} = sprintf("+ %.2f\%", $b_vars{djipwp}); } if($vars{delta} =~ /-/) { $b_vars{djipercent} = sprintf("- %.2f\%",abs($vars{delta} / ($vars{last} - $vars{delta}) * 100)); $b_vars{djidelta} = sprintf("- %.2f", abs($vars{delta})); } else { $b_vars{djipercent} = sprintf("+ %.2f\%",$vars{delta} / ($vars{last} - $vars{delta}) * 100); $b_vars{djidelta} = sprintf("+ %.2f", $vars{delta}); } } elsif ($vars{symbol} =~ /\^IXIC/) { $b_vars{nasdaqlast} = sprintf("%.2f", $vars{last}); $b_vars{nasdaqpwp} = ($vars{last} - $b_vars{nasdaqoriglast})/$b_vars{nasdaqoriglast} * 100; if($b_vars{nasdaqpwp} =~ /-/) { $b_vars{nasdaqpwp} = sprintf("- %.2f\%", abs($b_vars{nasdaqpwp})); } else { $b_vars{nasdaqpwp} = sprintf("+ %.2f\%", $b_vars{nasdaqpwp}); } if ($vars{delta} =~ /-/) { $b_vars{nasdaqpercent} = sprintf("- %.2f\%",abs($vars{delta} / ($vars{last} - $vars{delta}) * 100)); $b_vars{nasdaqdelta} = sprintf("- %.2f", abs($vars{delta})); } else { $b_vars{nasdaqpercent} = sprintf("+ %.2f\%",$vars{delta} / ($vars{last} - $vars{delta}) * 100); $b_vars{nasdaqdelta} = sprintf("+ %.2f", $vars{delta}); } } elsif ($vars{symbol} =~ /\^GSPC/) { $b_vars{snplast} = sprintf("%.2f", $vars{last}); $b_vars{snppwp} = ($vars{last} - $b_vars{snporiglast})/$b_vars{snporiglast} * 100; if($b_vars{snppwp} =~ /-/) { $b_vars{snppwp} = sprintf("- %.2f\%", abs($b_vars{snppwp})); } else { $b_vars{snppwp} = sprintf("+ %.2f\%", $b_vars{snppwp}); } if ($vars{delta} =~ /-/) { $b_vars{snppercent} = sprintf("- %.2f\%",abs($vars{delta} / ($vars{last} - $vars{delta}) * 100)); $b_vars{snpdelta} = sprintf("- %.2f", abs($vars{delta})); $b_vars{snpdelta} = sprintf("- %.2f", abs($vars{delta})); } else { $b_vars{snppercent} = sprintf("+ %.2f\%",$vars{delta} / ($vars{last} - $vars{delta}) * 100); $b_vars{snpdelta} = sprintf("+ %.2f", $vars{delta}); } } } if ($vars{delta} =~ /-/) { $vars{'color'} = $settings{NEG_COLOR}; } else { $vars{'color'} = $settings{POS_COLOR}; } $b_vars{stock_list} .= &filterVars($stock_line, %vars); # make sure that we have a correctly formed in here if (($vars{date} =~ /^\d/) && ($vars{time} =~ /^\d/)) { $b_vars{date} = $vars{date}; $b_vars{time} = $vars{time}; } } close(QUOTES); if ($b_vars{newdelta} =~ /-/) { $b_vars{newpercent} = sprintf("- %.2f\%",abs($b_vars{newdelta} / $b_vars{new} * 100)); $b_vars{newdelta} = sprintf("- %.2f", abs($b_vars{newdelta})); } else { $b_vars{newpercent} = sprintf("+ %.2f\%",$b_vars{newdelta} / $b_vars{new} * 100); $b_vars{newdelta} = sprintf("+ %.2f", $b_vars{newdelta}); } $b_vars{pwpdelta} = ($b_vars{new} - $b_vars{old})/$b_vars{old} * 100; if($b_vars{pwpdelta} =~ /-/) { $b_vars{pwpdelta} = sprintf("- %.2f\%",abs($b_vars{pwpdelta})); } else { $b_vars{pwpdelta} = sprintf("+ %.2f\%",$b_vars{pwpdelta}); } $b_vars{new} = sprintf("%.2f", $b_vars{new}); $stock_body = &filterVars($stock_body, %b_vars); print "Content-Type: text/html



"; print $stock_body; #----------------------------------------------------------- # filterVars(Buffer, HashwRepVars) # # sub filterVars { my ($FilterStream, %SearchVars) = @_; $FilterStream =~ s/\/ my $Value = $SearchVars{$1}; if(!defined $Value) { #$Value = "\"; # leave it as is print STDERR "\

"; } $Value; /ge; return $FilterStream; } #----------------------------------------------------------- # getTemplate(Template) # # sub getTemplate { my $TemplateFile = $_[0]; my $Template = ""; open(TEMPLATE, $TemplateFile) || die ("Error Opening $TemplateFile"); while( ) { $Template .= $_; } close(TEMPLATE); return $Template; }

About the PWP:

The Perpetual War Portfolio is an evenly weighted basket of five stocks poised to succeed in the age of perpetual war. The stocks were selected on the basis of popular product lines, strong political connections and lobbying efforts, and paid-for access to key Congressional decision-makers.



News: The PWP was shown some love in a recent issue of the New York Post.