A colleague of mine helped me develop the tool on http://www.coolinvestor.com/stockscan2.html
It works and runs correlations on data - and if the datafeed is yahoo it uses data from yahoo; and if datafeed is database it uses data from an internally constructed database.
However, the problem is that although it works the GUI has been constructed so that it is directed to two different perl scripts (with a bit of javascript i think - see GUI extract below) depending on what user chooses. One with this block:
Expand|Select|Wrap|Line Numbers
- $comp_url = "http://finance.yahoo.com/q/cp?s=%5E".$sector;
- my $v = get ($comp_url);
- my @components = get_comps($v);
- #print join(',',@components),"<BR>";
- ...and one with this block:
- $comp_url = "http://www.coolinvestor.com/grab_cpn2.php?s=".$sector;
- my $v = get ($comp_url);
- @components = split(",", $v);
I am not a programmer myself although I understand (sort of ) what to do. But I can't get anything to work - probably because my handling of variables is very bad!
Any help to make the blocks execute properly according to the users choice rather than having two scripts would be appreciated.
Jonmy
------------------------------------------------------------------------------------------------------------
Here is the fuller context from the script that uses the database - the yahoo bit is simply hashed out here.
Expand|Select|Wrap|Line Numbers
- $sector = "XBD"; # default sector
- $threshold = 0.7; #default threshold
- $duration = 6; #default duration
- $periods = 0; #default duration
- @dur_array = (0,0,0,0,0,0);
- # Determine which sector the user wants
- @fields = split(/&/,$combo_value);
- foreach $f (@fields) {
- if ($f =~ m/(.*)=(.*)/) {
- if ($1 eq "sector") { $sector = $2;}
- if ($1 eq "threshold") { $threshold = $2;}
- if ($1 eq "duration")
- {
- $periods++;
- if ($2 eq "1") { $dur_array[0] = 1;}
- elsif ($2 eq "2") { $dur_array[1] = 1;}
- elsif ($2 eq "4") { $dur_array[2] = 1;}
- elsif ($2 eq "12") { $dur_array[3] = 1;}
- elsif ($2 eq "24") { $dur_array[4] = 1;}
- elsif ($2 eq "48") { $dur_array[5] = 1;}
- else { print "previous case not true";}
- }
- }
- }
- # now find out the components in the sector (from component text file)
- $comp_url = "http://www.coolinvestor.com/grab_cpn2.php?s=".$sector;
- my $v = get ($comp_url);
- @components = split(",", $v);
- #$comp_url = "http://finance.yahoo.com/q/cp?s=%5E".$sector;
- #my $v = get ($comp_url);
- #my @components = get_comps($v);
- #print join(',',@components),"<BR>";
- print "<center><h1>Correlations between components of $sector</h1></center>\n";
- $siz = $#components+1;
- print "<br>\n";
- print "<center><h5>There are ",$siz," components in this sector. This gives ",($siz*($siz-1))/2," possible pairwise correlations.</h5></center>\n";
- print "<br></br>\n";
- print "<center> <h3>Scan results for stock pairs with correlations at or stronger than the threshold of ", $threshold, "</h3></center>";
- print "<br>\n";
HTML GUI page
---------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
- <HEAD>
- <TITLE>Sector Correlation Scan</TITLE>
- <META http-equiv=Content-Type content="text/html; charset=windows-1252">
- <META content="MSHTML 5.50.4134.600" name=GENERATOR>
- <script type="text/javascript">
- <!--
- function submitForm()
- {
- datafeed = document.scanform.datafeed.value;
- if(datafeed == "database")
- {
- document.scanform.action = "http://www.coolinvestor.com/cgi-bin/corrscan/stockscan2.pl";
- document.scanform.submit();
- }
- if(datafeed == "Yahoo")
- {
- document.scanform.action = "http://www.coolinvestor.com/cgi-bin/corrscan/stockscan.pl";
- document.scanform.submit();
- }
- }
- window.onload = function()
- {
- document.scanform.onsubmit = submitForm;
- }
- //-->
- </script>
- </HEAD>
- <BODY>
- <FORM method=post name=scanform>
- <TABLE style="HEIGHT: 197px" cellSpacing=2 cellPadding=2 align=center
- bgColor=#0a1666 border=2>
- <TBODY>