| 1 | package Finance::QuoteDB::Geniustrader; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Exporter (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use vars qw/@EXPORT @EXPORT_OK @EXPORT_TAGS/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use Log::Log4perl qw(:easy); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | =head1 NAME | ||||||||||
| 12 | |||||||||||
| 13 | Finance::QuoteDB::Geniustrader - Interfaces to external program Geniustrader | ||||||||||
| 14 | |||||||||||
| 15 | =cut | ||||||||||
| 16 | |||||||||||
| 17 | 1 | @EXPORT = (); | |||||||||
| 18 | 1 | @EXPORT_OK = qw // ; | |||||||||
| 19 | 1 | @EXPORT_TAGS = ( all => [@EXPORT_OK] ); | |||||||||
| 20 | |||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||
| 22 | |||||||||||
| 23 | Please take a look at script/fqdb which is the command-line frontend | ||||||||||
| 24 | to Finance::QuoteDB. | ||||||||||
| 25 | |||||||||||
| 26 | =head1 METHODS | ||||||||||
| 27 | |||||||||||
| 28 | =head2 writeConfig | ||||||||||
| 29 | |||||||||||
| 30 | writeConfig ( $fqdb-obj, $file ) | ||||||||||
| 31 | |||||||||||
| 32 | This function will create a Geniustrader config file for the $fqdb object. | ||||||||||
| 33 | |||||||||||
| 34 | =cut | ||||||||||
| 35 | |||||||||||
| 36 | sub writeConfig { | ||||||||||
| 37 | 0 | ▶ | my ($fqdb,$file) = @_ ; | ||||||||
|
Subroutine
writeConfig: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||
| 38 | 0 | my $fh ; | |||||||||
| 39 | 0 | my $dsn = $fqdb->{dsn}; | |||||||||
| 40 | 0 | INFO ("--- $dsn") ; | |||||||||
| 41 | 0 | ▶ | if ( open($fh,"+>","$file") ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 0 | my $db = ""; | |||||||||
| 43 | 0 | my $dbname = ""; | |||||||||
| 44 | 0 | my $dbhost = "" ; | |||||||||
| 45 | 0 | my $dbport = ""; | |||||||||
| 46 | 0 | ▶ | if ($dsn=~/dbi:(\w+):(\S+)(;.*)?$/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | $db = $1 ; | |||||||||
| 48 | 0 | $dbname = $2 ; | |||||||||
| 49 | } | ||||||||||
| 50 | 0 | ▶ | if ($dsn=~/;host=(\w+)(;.*)?$/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | $dbhost = $1 ; | |||||||||
| 52 | } | ||||||||||
| 53 | 0 | ▶ | if ($dsn=~/;port=(\w+)(;.*)?$/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | $dbport = $1 ; | |||||||||
| 55 | } | ||||||||||
| 56 | 0 | print $fh "# Database specific stuff\n"; | |||||||||
| 57 | 0 | print $fh "DB::module genericdbi\n" ; | |||||||||
| 58 | 0 | ▶ | print $fh "DB::genericdbi::db $db\n" if $db ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | ▶ | print $fh "DB::genericdbi::dbname $dbname\n" if $dbname ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 0 | ▶ | print $fh "DB::genericdbi::dbhost $dbhost\n" if $dbhost ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | ▶ | print $fh "DB::genericdbi::dbport $dbport\n" if $dbport ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 0 | ▶ | print $fh "DB::genericdbi::dbuser ".$fqdb->{dsnuser}."\n" if $fqdb->{dsnuser} ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | ▶ | print $fh "DB::genericdbi::dbpasswd ".$fqdb->{dsnpasswd}."\n" if $fqdb->{dsnpasswd} ; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | print $fh "DB::genericdbi::prices_sql SELECT day_open, day_high, day_low, day_close, volume, date ". | |||||||||
| 65 | "FROM quote WHERE symbolID = '\$code' ORDER BY date DESC\n" ; | ||||||||||
| 66 | 0 | print $fh "DB::genericdbi::name_sql SELECT name FROM symbol WHERE symbolID = '\$code'\n" ; | |||||||||
| 67 | 0 | print $fh "\n"; | |||||||||
| 68 | 0 | print $fh "# Stuff needed by geniustrader which you should set correctly\n"; | |||||||||
| 69 | 0 | print $fh "Graphics::Driver GD\n"; | |||||||||
| 70 | 0 | print $fh "Analysis::ReferenceTimeFrame year\n"; | |||||||||
| 71 | 0 | print $fh "Brokers::module SelfTrade\n"; | |||||||||
| 72 | 0 | print $fh "Path::Font::Arial ~/.gt/Arial.ttf\n"; | |||||||||
| 73 | 0 | print $fh "Path::Font::Courier ~/.gt/Geneva.ttf\n"; | |||||||||
| 74 | 0 | print $fh "Path::Font::Times ~/.gt/Times.ttf\n"; | |||||||||
| 75 | 0 | close $fh ; | |||||||||
| 76 | 0 | print "Configuration file $file written.\n"; | |||||||||
| 77 | } else { | ||||||||||
| 78 | 0 | ERROR ("Could not open $file in write mode") ; | |||||||||
| 79 | } | ||||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 1 | 1; | |||||||||