Venice 0.751beta

nz.org.venice.analyser
Class ANNPaperTrade

java.lang.Object
  extended bynz.org.venice.analyser.PaperTrade
      extended bynz.org.venice.analyser.ANNPaperTrade

public class ANNPaperTrade
extends PaperTrade

This class perform the paper trade analysis for the artificial neural network. A specific class has been developed, extended from PaperTrade PaperTrade, because ANNs have a complete different behaviour compared to other analysis based on Gondola language. ANNs need to be trained, and the training session needs to know how the things would be happened, if different choices have been taken day by day. For further information about the techniques used, you should find out the Cross Target technique (@author Prof. Pietro Terna). That is the technique used here to get the buy/sell signals. See http://web.econ.unito.it/terna/ct-era/ct-era.html.

The final portfolio will contain a single cash and a single share account. Cross Target method to get buy and sell signal through an ANN. The cross target method works in the following way: we make some guesses about buy and sell signals (actions) and about capital (effect of actions), the guesses are done by artificial neural network (ANN); then we train the ANN comparing what the ANN has guessed with the following values: the buy and sell signals are compared with the buy and sell signals which would be to get a capital equal to the capital guessed plus the percental increment wished; the capital signal is compared with the capital got trading with the guessed buy and sell signals. For the sake of simplicity in Merchant of Venice we've used a simplified version of CT technique. We do not use the capital as output of ANN, but we use only two outputs (the buy and sell signals). We pilot the buy and sell signals according to what happens in the future: we calculate if we gain enough in one of the next days (one from the next day trading until the window forecast day trading). We gain enough if and only if the earning percentage is higher than the user defined one, in one of the window forecast days. The core of the CT method has done in the setANNTrainingParameters method in this class.

Author:
Alberto Nacher

Nested Class Summary
 
Nested classes inherited from class nz.org.venice.analyser.PaperTrade
PaperTrade.Environment
 
Field Summary
 
Fields inherited from class nz.org.venice.analyser.PaperTrade
buyRule, buyValue, CASH_ACCOUNT_NAME, sellRule, sellValue, SHARE_ACCOUNT_NAME, STOCKS_PER_LINES, symbolStock
 
Method Summary
static Portfolio paperTrade(java.lang.String portfolioName, EODQuoteBundle quoteBundle, Variables variables, OrderCache orderCache, TradingDate startDate, TradingDate endDate, Money capital, int numberStocks, Money tradeCost, java.lang.String tradeValueBuy, java.lang.String tradeValueSell, ProgressDialog progress, Expression[] inputExpressions, ArtificialNeuralNetwork artificialNeuralNetwork)
          Perform paper trading using a fix number of stocks.
static Portfolio paperTrade(java.lang.String portfolioName, EODQuoteBundle quoteBundle, Variables variables, OrderCache orderCache, TradingDate startDate, TradingDate endDate, Money capital, Money stockValue, Money tradeCost, java.lang.String tradeValueBuy, java.lang.String tradeValueSell, ProgressDialog progress, Expression[] inputExpressions, ArtificialNeuralNetwork artificialNeuralNetwork)
          Perform paper trading using a fixed stock value.
static void paperTraining(java.lang.String portfolioName, EODQuoteBundle quoteBundle, Variables variables, OrderCache orderCache, TradingDate startDate, TradingDate endDate, Money capital, int numberStocks, Money tradeCost, java.lang.String tradeValueBuy, java.lang.String tradeValueSell, ProgressDialog progress, ANNTrainingPage ANNTrainingPage, Expression[] inputExpressions, ArtificialNeuralNetwork artificialNeuralNetwork)
          Perform training using a fix number of stocks.
static void paperTraining(java.lang.String portfolioName, EODQuoteBundle quoteBundle, Variables variables, OrderCache orderCache, TradingDate startDate, TradingDate endDate, Money capital, Money stockValue, Money tradeCost, java.lang.String tradeValueBuy, java.lang.String tradeValueSell, ProgressDialog progress, ANNTrainingPage ANNTrainingPage, Expression[] inputExpressions, ArtificialNeuralNetwork artificialNeuralNetwork)
          Perform training using a fixed stock value.
 
Methods inherited from class nz.org.venice.analyser.PaperTrade
buy, getCapital, getHoldingTime, getStockCapital, getTip, paperTrade, paperTrade, sell
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

paperTrade

public static Portfolio paperTrade(java.lang.String portfolioName,
                                   EODQuoteBundle quoteBundle,
                                   Variables variables,
                                   OrderCache orderCache,
                                   TradingDate startDate,
                                   TradingDate endDate,
                                   Money capital,
                                   Money stockValue,
                                   Money tradeCost,
                                   java.lang.String tradeValueBuy,
                                   java.lang.String tradeValueSell,
                                   ProgressDialog progress,
                                   Expression[] inputExpressions,
                                   ArtificialNeuralNetwork artificialNeuralNetwork)
                            throws EvaluationException
Perform paper trading using a fixed stock value.

Parameters:
portfolioName - name to call portfolio
quoteBundle - historical quote data
variables - any Gondola variables set
orderCache - cache of ordered symbols
startDate - start date of trading
endDate - last date of trading
capital - initial capital in the portfolio
stockValue - the rough value of each stock holding
tradeCost - the cost of a trade
tradeValueBuy - the value at which we want to buy
tradeValueSell - the value at which we want to sell
progress - the progress bar shown while ANN is running
inputExpressions - the input expressions of ANN
artificialNeuralNetwork - the ANN object
Returns:
the portfolio at the close of the last day's trade
Throws:
EvaluationException

paperTraining

public static void paperTraining(java.lang.String portfolioName,
                                 EODQuoteBundle quoteBundle,
                                 Variables variables,
                                 OrderCache orderCache,
                                 TradingDate startDate,
                                 TradingDate endDate,
                                 Money capital,
                                 Money stockValue,
                                 Money tradeCost,
                                 java.lang.String tradeValueBuy,
                                 java.lang.String tradeValueSell,
                                 ProgressDialog progress,
                                 ANNTrainingPage ANNTrainingPage,
                                 Expression[] inputExpressions,
                                 ArtificialNeuralNetwork artificialNeuralNetwork)
                          throws EvaluationException
Perform training using a fixed stock value.

Parameters:
portfolioName - name to call portfolio
quoteBundle - historical quote data
variables - any Gondola variables set
orderCache - cache of ordered symbols
startDate - start date of trading
endDate - last date of trading
capital - initial capital in the portfolio
stockValue - the rough value of each stock holding
tradeCost - the cost of a trade
tradeValueBuy - the value at which we want to buy
tradeValueSell - the value at which we want to sell
progress - the progress bar shown while ANN is running
ANNTrainingPage - the pointer to the training page
inputExpressions - the input expressions of ANN
artificialNeuralNetwork - the ANN object
Throws:
EvaluationException

paperTraining

public static void paperTraining(java.lang.String portfolioName,
                                 EODQuoteBundle quoteBundle,
                                 Variables variables,
                                 OrderCache orderCache,
                                 TradingDate startDate,
                                 TradingDate endDate,
                                 Money capital,
                                 int numberStocks,
                                 Money tradeCost,
                                 java.lang.String tradeValueBuy,
                                 java.lang.String tradeValueSell,
                                 ProgressDialog progress,
                                 ANNTrainingPage ANNTrainingPage,
                                 Expression[] inputExpressions,
                                 ArtificialNeuralNetwork artificialNeuralNetwork)
                          throws EvaluationException
Perform training using a fix number of stocks.

Parameters:
portfolioName - name to call portfolio
quoteBundle - historical quote data
variables - any Gondola variables set
orderCache - cache of ordered symbols
startDate - start date of trading
endDate - last date of trading
capital - initial capital in the portfolio
numberStocks - try to keep this number of stocks in the portfolio
tradeCost - the cost of a trade
tradeValueBuy - the value at which we want to buy
tradeValueSell - the value at which we want to sell
progress - the progress bar shown while ANN is running
ANNTrainingPage - the pointer to the training page
inputExpressions - the input expressions of ANN
artificialNeuralNetwork - the ANN object
Throws:
EvaluationException

paperTrade

public static Portfolio paperTrade(java.lang.String portfolioName,
                                   EODQuoteBundle quoteBundle,
                                   Variables variables,
                                   OrderCache orderCache,
                                   TradingDate startDate,
                                   TradingDate endDate,
                                   Money capital,
                                   int numberStocks,
                                   Money tradeCost,
                                   java.lang.String tradeValueBuy,
                                   java.lang.String tradeValueSell,
                                   ProgressDialog progress,
                                   Expression[] inputExpressions,
                                   ArtificialNeuralNetwork artificialNeuralNetwork)
                            throws EvaluationException
Perform paper trading using a fix number of stocks.

Parameters:
portfolioName - name to call portfolio
quoteBundle - historical quote data
variables - any Gondola variables set
orderCache - cache of ordered symbols
startDate - start date of trading
endDate - last date of trading
capital - initial capital in the portfolio
numberStocks - try to keep this number of stocks in the portfolio
tradeCost - the cost of a trade
tradeValueBuy - the value at which we want to buy
tradeValueSell - the value at which we want to sell
progress - the progress bar shown while ANN is running
inputExpressions - the input expressions of ANN
artificialNeuralNetwork - the ANN object
Returns:
the portfolio at the close of the last day's trade
Throws:
EvaluationException

Venice 0.751beta