scan.pl - scan the market looking for signals
./scan.pl [ options ] <market file> <date> <system file> [ <system file> ... ]
scan.pl will scan all stocks listed in <market file> looking for the signals indicated in each <system file> performing the analysis on the specified <date>. A system file must contain one or more description of Finance::GeniusTrader::Signals or description of Finance::GeniusTrader::Systems. You may list multiple system files on the command line. In the absence of a file standard input will be read instead.
NOTE -- if you omit a system file name scan.pl will happily wait forever attempting to read from stdin.
The list of securities (code and name) that meet the specified signals is output at the end and grouped by signal.
Output can be either text (default) or html.
<market file> format:
stock or index symbols one per line
<date>
the date to perform the analysis on. the date string can be in any format that Date::Manip (if installed) can parse or the defacto gt standard date format (YYYY-MM-DD HH:MM:SS) where time is optional
<system file> format:
One or more Finance::GeniusTrader::Signals or Finance::GeniusTrader::Systems descriptions each on a separate line. The descriptions have the form of a signal or system name, followed by its arguments.
Example: S:Generic:And {S:Generic:CrossOverUp {I:SMA 5} {I:SMA 20}} {S:Generic:Increase {I:ADX}}
Description files can be formatted using the symbol '\' as the line continuation symbol. This symbol must appear as the last character on the line before the trailing line terminator (in unix that's a '\n' character). No whitespace must appear between the \ and the newline.
Example: S:Generic:And \ {S:Generic:CrossOverUp {I:SMA 5} {I:SMA 20}} \ {S:Generic:Increase {I:ADX}}
Blank lines and lines that start with # are comments and ignored. Note if you comment out the first line of multi-line description, the entire is effectively commented out.
Example: # the following signal description is commented out #S:Generic:And {S:Generic:Above {I:Prices} {I:EMA 30}} \ {S:Generic:Above {I:Prices} {I:EMA 150}}
Determines the time interval over which the scan is run. In detail:
The start and end dates considered for the scan. The date needs to be in the format configured in ~/.gt/options and must match the timeframe selected.
The number of periods to use in the scan.
Runs the scan with the full history.
The periods considered are relative to the selected time frame (i.e., if timeframe is "day", these indicate a date; if timeframe is "week", these indicate a week; etc.). In GT format, use "YYYY-MM-DD" or "YYYY-MM-DD hh:mm:ss" for days (the latter giving intraday data), "YYYY-WW" for weeks, "YYYY/MM" for months, and "YYYY" for years.
The interval of periods examined is determined as follows:
The first period determined following this procedure is chosen. If additional options are given, these are ignored (e.g., if --start, --end, --full are given, --full is ignored).
The timeframe can be any of the available modules in GT/DateTime.
Determines the number of periods (back from the last period) that are loaded for a given market from the data base. Care should be taken to ensure that these are consistent with the performed analysis. If not enough data is loaded to satisfy dependencies, for example, correct results cannot be obtained. This option is effective only for certain data base modules and ignored otherwise.
Makes scan.pl and invoked methods talkative (default - false)
If you want to start two (or more) scans in parallel (useful for machines with several CPUs for example).
Output is generated in html (default - false)
If html output enabled then embed this url as href (default - http://finance.yahoo.com/l?s=<code>)
A configuration option (typically given in the options file) in the form of a key=value pair. For example, --option=DB::Text::format=0 sets the format used to parse markets via the DB::Text module to 0.
To scan for all stocks that are trading above both their 30 day and 150 day EMAs create a system file containing this Finance::GeniusTrader::Signals description (as a single line)
S:Generic:And {S:Generic:Above {I:Prices} {I:EMA 30}} {S:Generic:Above {I:Prices} {I:EMA 150}}
To scan for all stocks that are trading below both their 30 day and 150 day EMAs create a system file containing this Finance::GeniusTrader::Signals description (as a single line)
S:Generic:And {S:Generic:Below {I:Prices} {I:EMA 30}} {S:Generic:Below {I:Prices} {I:EMA 150}}
If the user has Date::Manip installed it allows the use of date strings that can be parsed by Date::Manip in addition the to defacto standard date-time format accepted by GT (YYYY-MM-DD HH:MM:SS) time part is optional Date::Manip is not required, without it users cannot use short-cuts to specify date strings. such short cuts include --start '6 months ago' --end 'today' Date string checking includes verifying the date string format is valid and the date is a valid date (and time if provided) Errors will be displayed and the script will terminate. The script also validates that the dates specified are consistent with respect to their purpose (--start is earlier than --end etc) Finally, appropriate timeframe conversion is performed so the user need not convert command line date strings from the day time to say week or month as it will be done automagically. Usage examples: with market_file (a file) containing the next 2 lines: JAVA AAPL with system_file (a file) containing the next 6 lines: # example system_file # # todays price close was above open S:Generic:Above { I:Prices CLOSE } { I:Prices OPEN } # end of system_file with Date::Manip installed % scan.pl --timeframe day --start '6 months ago' --end 'today' market_file \ 'today' system_file prints Signal: S:Generic:Above {I:Prices CLOSE} {I:Prices OPEN} AAPL - APPLE INC replace day with week and you will (should) get: Signal: S:Generic:Above {I:Prices CLOSE} {I:Prices OPEN} AAPL - APPLE INC JAVA - SUN MICROSYS INC without Date::Manip you will need to use: % scan.pl --timeframe day --start 2007-04-24 --end 2007-10-24 market_file \ 2007-10-24 system_file or % scan.pl --timeframe week --start 2007-04-24 --end 2007-10-24 market_file \ 2007-10-24 system_file and should get the same results respectively
If you are using cygwin on Windows to run GT, and you encounter a "Bad system call" error when running scan.pl, you need to enable cygserver. cygserver is a utility that provides cygwin applications with persistent services. See http://www.cygwin.com/cygwin-ug-net/using-cygserver.html for more detail. The first time you use cygserver, execute /usr/bin/cygserver-config to configure the service (there are many options but the above should suffice, see the manual for more). You can then invoke the service automatically through windows, or use net start cygserver to do so. You must also set the CYGWIN environment variable to 'server': CYGWIN=server export CYGWIN
To install Finance::GeniusTrader, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Finance::GeniusTrader
CPAN shell
perl -MCPAN -e shell install Finance::GeniusTrader
For more information on module installation, please visit the detailed CPAN module installation guide.