GeniusTrader

Frequently Asked Questions

nb: the basis for this page hasn't been revised in a long, long, long, long time.

so if you have any questions to add, or if you've got a problem without an answer here, or think you can help improve the presentation, etc please post a note on the geniustrader-devel mailing list (you have to subscribe to post to -devel). Instructions for subscribing are here.

You are also welcome to send me (ras) a note directly if you prefer that alternative.


thanks. and remember, gt is a community effort.


q. how can i search the development archive mail list?

a. the new mail list archives (the devel and system-traders lists) are now at sourceforge mailing lists. Use the search capabilities provided via the Mailing Lists tab and the Search Mailing Lists selection.


q. how the hell do i use genius trader?

a. First, you will need a source of stock prices data that is current date wise if you intend to do perform technical analysis on stocks in the current date/time period.

Second, it depends on what you want to do with GT, it is a rather powerful, but complex, technical analysis toolkit and application set. We recommend you refer to screen shots for detailed examples of what GT can be used for and how to do it. Some of the primary commands are described in more detail in subsequent questions, so keep reading ...

old answer

a. first, read everything available via the web site http://geniustrader.org/. at some point you might want to review the genius trader material at http://www.olfsworld.com. you should look at the on-line docs (pod) in the Scripts directory, next you will need to look at the on-line docs (pod) in the API (GT) directory along with the actual perl source. finally, you should review both mail list archives geniustrader-devel and geniustrader-system-traders. Subscribe to one or both as you wish. You can review the mailing list archives from the geniustrade sourceforge website from geniustrader development and use the 'Mailing Lists' tab to access the list archives.

but to answer your question, in general you can use

graphic.pl to gnerate charts for stocks (symbols) with technical analysis plots of a myriad of indicators and signals, plus you can create your own indicators and signals by defining them using GT sys-sig-indic descriptions (think easylanguage (TM) but completely different)

scan.pl is used to scan for possible investment opportunities or for warning flags for stocks already owned.

backtest.pl is used to backtest defined GT trading systems.

manage_portfolio.pl is used to manage stock positions you have in your brokerage account.

the display_*.pl commands are generally useful for debug and development of GT sys-sig-indic descriptions.


q. How do I use beancounter with geniustrader?

a. refer to the Beancounter setup page in the ''Users Wiki'' for details.


q. i've got some stocks, is there anyway i can "pre-load" them into a GT "portfolio" and have GT manage them?

a. sure, but you will have to do some work manually first. see the pod for script manage_portfolio.pl. you will want to look at the ways to pass data to it from whatever sources you might have. probably the best choice is to fire up an editor, and cut and paste the needed data from whatever sources you've got into a file and then run

$ ./manage_portfolio.pl portfolio_file file source_file

where 'portfolio_file' will become your new gt portfolio file. 'file' is the manage_portfolio command and 'source_file' is the source file that you've prepared from your trading records you want to import. the pod man page for manage_portfolio.pl ($ perldoc manage_portfolio.pl) explains the required format for 'source_file'.

Note: a gt portfolio file is an xml file (a gt portfolio object) and is automatically compressed (gzip). so if you want to see it's contents you will have to decompress it first.


q. how do i use scan.pl?

a. $ ./scan.pl market_file 2002-07-04 systems_file

the 'market_file' contains symbols, one per line, for this example it's just one line:

13000

the date (e.g. 2002-07-04) must be within the time period covered by the sample database which for 13000 ranges from "1993-01-04" to "2002-10-04" inclusive.

'systems_file' must describe "systems" in the sense of "GT::Systems" or "signals" (GT::Signals) descriptions.

Here are three examples of GT "systems" or "signals" descriptions (recall that GT provides abbreviations -- SY == systems, S == signals and although not used here G == Generic): note: the 2nd one is totally lame, but valid

SY:TFS 50 10 S:Generic:True S:Generic:Above {I:ADX/1} {I:Generic:PeriodAgo 1 {I:ADX/1}}

so in 'systems_file' add say, the first and last, of the three lines above and run the command line shown above. locally here's what i'm getting:

Buy signal: SY:TFS 50 10 Sell signal: SY:TFS 50 10 Signal: S:G:Above {I:ADX 14 {I:Prices HIGH} {I:Prices LOW} {I:Prices CLOSE}} {I:G:PeriodAgo 1 {I:ADX 14 {I:Prices HIGH} {I:Prices LOW} {I:Prices CLOSE}}} 13000 alcatel before it acquired lucent

NB: the string ''alcatel before it acquired lucent'' at the end of this example comes from $HOME/.gt/sharenames which provides GT::DB::Text a way to translate a 'symbol' (e.g. database filename) into a company name. without a sharenames file with a 13000 entry you will not get this string.


q: How would I find all stocks that are trading above both their 30 day and 150 day EMAs?

a. this is the task scan.pl was created for. first create the file 'stocklist_file' that contains the list of all the stock symbols (codes) you want to examine (one symbol per line). next create the file 'signal_file' that contains the following gt sys-sig-indic description (a signal) that will indicate true when the specified date ''YYYY-MM-DD'' closing price is above both the 30 day and the 150 EMA indicator values.

S:G:And {S:G:Above {I:Prices} {I:EMA 30}} {S:G:Above {I:Prices} {I:EMA 150}}

run the following command where you replace the date of interest for the placeholder YYYY-MM-DD:

$ scan.pl signal_file YYYY-MM-DD stocklist_file


q. what is display_indicator.pl for? How is it used?

a. as implied by the name display_indicator.pl will 'display' the result of an 'indicator' specification, for a given security.

generally the display_*.pl gt script apps are for developing, testing, evaluating the specific gt sys-sig-indic description under consideration. display_indicator.pl for indicators, display_signal.pl for signals and display_system.pl for systems. these apps at least as far as this gt user is concerned are not intended for any other purpose.

usage examples:
$ ./display_indicator.pl --verbose I:MACD JCP
Calculating indicator MACD[12,26,{I:Prices CLOSE}] ... MACD[12,26,{I:Prices CLOSE}][2003-03-12] = -0.316065416085134 MACDSignal[9,{I:Prices CLOSE}][2003-03-12] = -0.350523730085381 MACDDifference[12,26,9,{I:Prices CLOSE}][2003-03-12] = 0.0345 ...

$ ./display_indicator.pl --verbose {I:AROON} JCP
Calculating indicator AroonUp[25,{I:Prices HIGH},{I:Prices LOW}] ... AroonUp[25,{I:Prices HIGH},{I:Prices LOW}][2003-03-12] = 48.0000 AroonDown[25,{I:Prices HIGH},{I:Prices LOW}][2003-03-12] = 28.0000 AroonOsc[25,{I:Prices HIGH},{I:Prices LOW}][2003-03-12] = 20.0000 ...


q. what is display_signal.pl for? How is it used?

a. as implied by the name display_signal.pl will 'display' the result of a 'signal' specification, for a given security.

signals usually require the generation of one or more indicators as well, however the intermediate indicator results are not displayed (see display_indicator.pl)

examples:

$ ./display_signal.pl --verbose S:Generic::CrossOverUp JCP '{I:EMA 5}' '{I:EMA 20}'
Testing signal CrossOverUp[{I:EMA 5 {I:Prices CLOSE}},{I:EMA 20 {I:Prices CLOSE}}] ... CrossOverUp[{I:EMA 5 {I:Prices CLOSE}},{I:EMA 20 {I:Prices CLOSE}}][2003-03-12] = no CrossOverUp[{I:EMA 5 {I:Prices CLOSE}},{I:EMA 20 {I:Prices CLOSE}}][2003-03-13] = yes CrossOverUp[{I:EMA 5 {I:Prices CLOSE}},{I:EMA 20 {I:Prices CLOSE}}][2003-03-14] = no CrossOverUp[{I:EMA 5 {I:Prices CLOSE}},{I:EMA 20 {I:Prices CLOSE}}][2003-03-17] = no CrossOverUp[{I:EMA 5 {I:Prices CLOSE}},{I:EMA 20 {I:Prices CLOSE}}][2003-03-18] = no ...

$ ./display_signal.pl --verbose Signals::Generic::CrossOverUp JCP \ '{I:EMA 5 {I:Prices OPEN}}' '{I:EMA 20 {I:Prices HI}}'
Testing signal CrossOverUp[{I:EMA 5 {I:Prices OPEN}},{I:EMA 20 {I:Prices HI}}] ... CrossOverUp[{I:EMA 5 {I:Prices OPEN}},{I:EMA 20 {I:Prices HI}}][2003-03-12] = no CrossOverUp[{I:EMA 5 {I:Prices OPEN}},{I:EMA 20 {I:Prices HI}}][2003-03-13] = no CrossOverUp[{I:EMA 5 {I:Prices OPEN}},{I:EMA 20 {I:Prices HI}}][2003-03-14] = yes CrossOverUp[{I:EMA 5 {I:Prices OPEN}},{I:EMA 20 {I:Prices HI}}][2003-03-17] = no CrossOverUp[{I:EMA 5 {I:Prices OPEN}},{I:EMA 20 {I:Prices HI}}][2003-03-18] = no ...

$ ./display_signal.pl --verbose \ S:Generic:Above JCP '{I:ADX}' '{I:ADX}' '{I:Generic:PeriodAgo ADX 1}'
Testing signal Above[{I:ADX 14 {I:Prices HIGH} {I:Prices LOW} {I:Prices CLOSE}}, {I:ADX 14 {I:Prices HIGH} {I:Prices LOW} {I:Prices CLOSE}},{I:Generic:PeriodAgo ADX 1}] ... Illegal division by zero at ../GT/Indicators/ADX.pm line 113.

the script app display_system.pl is similar only it works on a gt system specification (e.g. two signals by default, the first denotes

   ''open long position order''
the second denotes
   ''open short position order''


q. ok, so how about a display_system.pl example or three?

a. --to be provided--


q. Is there a way to generate arbitrary or random entry signals?

a. You can use Signals::Generic::True, which will return one signal for each trading period.

a. A new signal can be created that returns sprintf("%.0f", rand(1)).

i don't understand please amplify ...
--to be provided--


q. practical references to work with genetic algorithms (ga) applied to market trading ...

a. Katz, Jeffrey Owen, Ph.D., McCormick, Donna L., 'The Encyclopedia of Trading Strategies', 2000. (ISBN 0-07-058099-5)
   Trading on the Edge: Neural Genetic and Fuzzy ... - Guido Deboeck
   Genetic Algorithms and Investment Strategies - Richard J Bauer
   Genetic Algorithms and Genetic Programming in ... - Shu Heng Chen


q. i'm getting errors from perl, what can i do to help myself?

best advice is to seek help from getniustrader-devel mail list

be sure to provide adequate information so someone there might be able to attempt to duplicate your problem(s). things like

OLD OBSOLETE ANSWER

NOTE: Carp::Datum has been depreciated

a. set the variable GTDEBUG to 1, this enables Carp::Datum. loads of output will be generated, but it might point you in an appropriate direction.
shells (bash, sh, ksh): $ GTDEBUG=1 command >db.log
c shells (csh, tcsh, ): % setenv GTDEBUG 1; command >&db.log
beforewarned: the quantity of data will be significant so dump it into a file for subsequent analysis.


q. i'm confused -- what are all the files and file formats that gt uses? and where are all these files kept?

try $ perldoc ../GT/Docs/gt_files.pod

the "Users Wiki" has a page or two on files and file formats as well.


q. i'm in the dark -- what is all this alphabet soup?

Aliases::Global::TFS SY:TFS 50 10 | CS:SY:TFS

Aliases::Global::TFS[] SY:TFS #1 #2|CS:SY:TFS #1|CS:Stop:Fixed #3

this section needs a lot of work to correct text as well as html formatting

file line continuation should be in all newer versions of gt

a. aliases are used to provide

   1) shorthand for very long complex sys-sig-indic descriptions.
   2) added complexity to make gt even more difficult to learn.
   3) allow one to easily vary parameters in commonly employed sys-sig-indic descriptions.

one can define aliases for elements of the genius trader system. Aliases can use the built-in abbreviations or the long names. (see abbreviation-data)

there are two forms of aliases, system and object, each are different.

aliases can perform limited arithmetic using the 4 basic operators:

+ (add), - (subtract), * (multiply) and / (divide).

aliases defined in files must appear on the same line -- the only ways to shorten the total length of them are:

   1) use the component abbreviations.
   2) embed object aliases inside system aliases.

trading system aliases

   The syntax of a trading system alias has the following 5 components:
      system
      orderfactory
      tradefilter
      closestrategy
      moneymanagement

   where the only required components are system and closestrategy.
   this implies that tradefilter, moneymanagement, and orderfactory
   have defaults and are optional in a trade system alias.

   some of the components can have multiples, meaning two or more
   closestrategies, tradefilters, etc are allowed.

   The default components are:
     tradefilter -- to-be-supplied
     moneymanagement -- to-be-supplied
     orderfactory -- to-be-supplied

   Each component is separated (delimited) with the vertical bar '|' character.

also see perldoc GT/Tools.pm and backtest.pl

the first system alias listed above defines a minimal system ( a system and a closestrategy ) where the system is the TFS with standard TFS indicators TETHER and VOSC. the parameters are set to 50 and 10 respectively.

the second alias system alters the system some what by allowing the user to introduce parameters at runtime. this alias could be used as follows:

./backtest.pl --timeframe=day 'TFS[ 10,10, 10 ]' CAT

to define the default TFS that uses the value 10 for the system indicators TETHER and VOSC and two closestrategies; the first the standard TFS TETHER indicator with a value of 10 and the second a fixed stop value of 10 percent of the initial position price.

nb: the params must be with '[' and ']' and must be comma (',') separated

object aliases

examples:

in file ~/.gt/aliases/indicators (the standard configuration file ???) you could write:

Aliases::Indicators::MyMean { I:Generic:Eval ( #1 + #2 ) / 2 }

then your indicator alias I:MyMean could be used as follows:

{ @I:MyMean 50 { I:RSI } }

which would use 50 and the result of { I:RSI } as parameters for the mean computataion, or, if the parameters are unneeded:

"@I:MyMean"

creating aliases with parameters:

space delimit every token (word or operator)

each variable parameter (e.g. #1, #2 ...) are in fixed order and is introduced by the '#' symbol. the replacement order will be in accordance with their numberic identify, meaning the second input 'value' will be inserted into the alias expansion where the token '#2' appears.


q. ok i think i understand aliases, but i cannot get them to work

a. in your $HOME/.gt/options add as two lines

Aliases::Global::TFS SY:TFS 50 10 | CS:SY:TFS
Aliases::Global::TFS[] SY:TFS #1 #2|CS:SY:TFS #1|CS:Stop:Fixed #3

notice the difference -- the first alias hasn't the [] nor any #digit fields. the [] flags the aliases ability to pass user arguments from the command line, the #digit fields note which argument is placed at that point in the alias.

For example, if some gt app script command line contained 'TFS[9,12,15]' on it (including quotes to escape the brackets from the shell) the alias expansion would yield:
SY:TFS 9 12 | CS:SY:TFS 9 | CS:Stop:Fixed 15
which corresponds to the
Aliases::Global::TFS[]
alias with the first value (9) inserted at the #1 locations, 12 for #2 and 15 for #3.

Note that extra (unused) #arguments is not considered an error, too few however is.

You cannot elect to use the built-in default argument once a #digit field is defined in an alias. Which means you will need to provide a value for each #digit argument in a [] type alias.

actual usage examples:

in $HOME/.gt/options define the SMA[] trading system as:

Aliases::Global::SMA[] SY:SMA | TF:AcceptAll | CS:Stop:Breakeven #1 #2

this command will run an analysis on the SMA trading system on symbol SBUX:

% ./backtest.pl --timeframe=day 'SMA[6,4]' SBUX

with a file containing SBUX (one line) named 'scan_symbol' and a trading system defined as SY:SMA | TF:AcceptAll (one line) in a file named 'scan_system', the command

% ./scan.pl --timeframe=day scan_symbol 2007-04-03 scan_system

would run the pre-defined trading-system SMA (refer to ../GT/Systems/SMA.pm) using built-in default arguments along with the AcceptAll tradefilter on symbol SBUX and report 'open long' and 'open short' signals for 2007-04-03.

NOTE: 20aug2011: scan.pl may be failing to correctly parse built-in trading system sys-sig-indic desc such as SY:SMA | TF:AcceptAll when the trading system is not passed any parameters and includes some other trading-system component, as in this example the trade filter. this issue appears to occur only when the trading system is one of the trivial pre-coded ones such as SY:SMA, SY:TTS, SY:TFS, SY:MacdDiff, SY:ADX, SY:ADX2, SY:Stochastic, SY:AlwaysInTheMarket and SY:Swing::Trend. the known work-around is to always pass parameter values. a general fix for this problem is being developed, if you have found instances of this problem or other manifestations of it not described here please notify the gt -devel mailing list to elevate the problems' priority ...


q. ok what about those other object aliases that start with @ symbol

a. --to be provided--


q. what about signals?

a. signals can be quite complex, for example

Signals::Generic::And \ { S:Generic:Repeated {S:Prices:InsideDay} 2 } \ { S:Generic:Above {I:ADX} 30 } \ { S:Generic:Above {I:ADX/2} {I:ADX/3} }

this signal might be triggered when there are two inside days (inside day = lower high and higher low than yesterday) in succession and the ADX indicator is above 30 and +DI is higher than -DI.

another example:

S:Generic:Repeated 13000 {S:Generic:Above {I:RSI} 75} 3

defines a signal that triggers when the RSI has been above 75 for the 3 previous days.


q. this stuff is all perl, but the syntax is strange. what gives?

a 1. well if you are referring to the gt sys-sig-indic descriptions and the similar graphic directives these are NOT perl but they do resemble it.

to display geniustrader pod use the perldoc command:
for example:
$ perldoc [-t] scan.pl
$ perldoc [-t] manage_porfolio.pl
$ perldoc [-t] ../GT/Indicator/SMA
$ perldoc [-t] ../GT/Docs/gt_sig-sys-desc.pod

a 2. on the other hand GT is written using perl favoring object oriented design. here is a list of perl object oriented documentation references:

  man perlboot -- Beginner's Object-Oriented Tutorial
  man perltoot -- Tom's object-oriented tutorial for perl
  man perltootc -- Tom's OO Tutorial for Class Data in Perl
  man perlobj -- Perl objects
  man perlbot -- Bag'o Object Tricks (the BOT)

for more basic stuff about perl ...
  man perlreftut -- essential perl refences
  man perlref -- perl refences
  man perlsub -- perl subroutines
  man perlmod -- packages


q. what is this GT::ArgsTree thing anyway?

a. GT::ArgsTree is the component that provides GT with amazing power and flexibility. when an gt object (meaning a system, signal, indicator, order, position, porfolio, closestrategy, moneymanager, tradefilter, orderfactory, broker ) is required and must be "calculated" (computed) the GT::ArgsTree syntax is used:

     "{" ''object-specification'' ''object_arg_list'' "}"
where "{" and "}" are literal curly brackets,
''object-specification'' is a sys-sig-indic desc or alias and
''object_arg_list'' are any arguments which might be null.


q. how do i cut losses with gt

long question
one of the books i've come across that discusses charting and ta trading emphasized the need to cut losses on losing positions as soon as the trade is determined to be in the wrong direction. in fact, the author (don't know who, but book had a full chapter on when to sell) went so far as to recommend that losses should be taken between 6 and 8 percent of the original investment. how can i define an indicator or signal to handle this situation.

a. actually, once GT has "placed the order" and a position has been opened, the GT Systems signals are no longer involved. at this point a closestrategy (one or more) is monitoring the "position" in accordance with your "exit strategy" as defined by specifying various closestrategies, along with the defined moneymanagers, orderfactories and maybe even tradefilters.

the exit strategy you inquire about is already predefined:

CloseStrategy::Stop::Fixed ''value''

where ''value'' defaults to 4 percent of the initial position. to define a stop loss exit strategy at 7 percent use:

CloseStrategy::Stop::Fixed 7

similar closestrategy are PartialGain and PartialStop which can be used to implement partial (to full) gain capture and loss stops.


q. that answer about cutting losses is kinda out of context -- can you give a more complete example of a trading system that implements that exit strategy?

a. sure, but NB these trading-systems are just cuts+pastes without any testing ...

SY:TFS 9 12 | CS:SY:TFS 9 | CS:Stop:Fixed 7
SY:TFS 9 12 | TF:AcceptAll | CS:PartialGain 20 0.25 | CS:Stop:Fixed 7


q. Can I run GeniusTrader on Mac OSX ? If yes how ?

a. Yes you can. It has been reported that best results might be obtained using a perl other than the one shipped with OSX. Search the geniustrader-devel mailing list archive for more specific information, but OSX is a lot like a *nix platform, so refer to the setup and configuration recommendations for *nix.


q. Can I run GeniusTrader on Windows ? If yes how ?

a. Yes you can, but why would you want to? Follow the instructions on the Install & Setup for *dows.

If you care about the inner details of how it works, try the following: