Venice 0.7beta

org.mov.analyser.ga
Class GeneticAlgorithm

java.lang.Object
  extended by org.mov.analyser.ga.GeneticAlgorithm

public class GeneticAlgorithm
extends java.lang.Object

The Genetic Algorithm creates and breeds random paper trading individuals. This class runs the GA.


Constructor Summary
GeneticAlgorithm(EODQuoteBundle quoteBundle, OrderCache orderCache, Expression buyRule, Expression sellRule, TradingDate startDate, TradingDate endDate, Money initialCapital, Money stockValue, int numberStocks, Money tradeCost, int breedingPopulationSize, java.lang.String tradeValueBuy, java.lang.String tradeValueSell, GAIndividual lowest, GAIndividual highest, Variables variables)
          Get ready to run the GA.
 
Method Summary
 GAIndividual getBreedingIndividual(int index)
          Get one of the current generation's breeding individual.
 int getBreedingPopulationSize()
          Get the size of the current breeding population.
 Expression getBuyRule()
          Get the buy rule.
 int getNextBreedingPopulationSize()
          Get the size of the next generation's breeding population.
 Expression getSellRule()
          Get the sell rule.
 int nextGeneration()
          Enter the next generation.
 void nextIndividual()
          Run one iteration of the GA.
 Portfolio paperTrade(EODQuoteBundle quoteBundle, OrderCache orderCache, TradingDate startDate, TradingDate endDate, Expression buyRule, Expression sellRule, Money initialCapital, Money stockValue, int numberStocks, Money tradeCost, Variables variables, java.lang.String tradeValueBuy, java.lang.String tradeValueSell)
          Paper trade with the individual's buy and sell rules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneticAlgorithm

public GeneticAlgorithm(EODQuoteBundle quoteBundle,
                        OrderCache orderCache,
                        Expression buyRule,
                        Expression sellRule,
                        TradingDate startDate,
                        TradingDate endDate,
                        Money initialCapital,
                        Money stockValue,
                        int numberStocks,
                        Money tradeCost,
                        int breedingPopulationSize,
                        java.lang.String tradeValueBuy,
                        java.lang.String tradeValueSell,
                        GAIndividual lowest,
                        GAIndividual highest,
                        Variables variables)
Get ready to run the GA.

Parameters:
quoteBundle - the historical quote data
orderCache - cache of ordered symbols
startDate - start date of trading
endDate - last date of trading
initialCapital - initial capital in the portfolio
stockValue - the rough value of each stock holding
numberStocks - number of stocks in the portfolio
tradeCost - the cost of a trade
breedingPopulationSize - number of individuals that can breed
tradeValueBuy - value for buying a stock
tradeValueSell - value for selling a stock
lowest - lowest GA individual to know the lowest bound for generating new individuals
highest - highest GA individual to know the highest bound for generating new individuals
variables - variables containing the parameters of GA
Method Detail

nextIndividual

public void nextIndividual()
Run one iteration of the GA. This will create a single valid individual.


nextGeneration

public int nextGeneration()
Enter the next generation.


getBreedingIndividual

public GAIndividual getBreedingIndividual(int index)
Get one of the current generation's breeding individual.

Parameters:
index - of the breeding individual
Returns:
the breeding individual

getBreedingPopulationSize

public int getBreedingPopulationSize()
Get the size of the current breeding population.

Returns:
current breeding population size

getNextBreedingPopulationSize

public int getNextBreedingPopulationSize()
Get the size of the next generation's breeding population.

Returns:
future breeding population size

getBuyRule

public Expression getBuyRule()
Get the buy rule.

Returns:
buy rule expression

getSellRule

public Expression getSellRule()
Get the sell rule.

Returns:
sell rule expression

paperTrade

public Portfolio paperTrade(EODQuoteBundle quoteBundle,
                            OrderCache orderCache,
                            TradingDate startDate,
                            TradingDate endDate,
                            Expression buyRule,
                            Expression sellRule,
                            Money initialCapital,
                            Money stockValue,
                            int numberStocks,
                            Money tradeCost,
                            Variables variables,
                            java.lang.String tradeValueBuy,
                            java.lang.String tradeValueSell)
                     throws EvaluationException
Paper trade with the individual's buy and sell rules. Set the stockValue to null to trade by number of stocks in the portfolio.

Parameters:
quoteBundle - the historical quote data
orderCache - cache of ordered symbols
startDate - start date of trading
endDate - last date of trading
buyRule - expression got from buy rule defined by user
sellRule - expression got from sell rule defined by user
initialCapital - initial capital in the portfolio
stockValue - the rough value of each stock holding
numberStocks - number of stocks in the portfolio
tradeCost - the cost of a trade
variables - variables used by GA
tradeValueBuy - the buy value of a stock
tradeValueSell - the sell value of a stock
Returns:
portfolio of individual after paper trading
Throws:
EvaluationException

Venice 0.7beta