|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mov.analyser.PaperTrade
public class PaperTrade
Paper trades stocks using historical quote data and buy and sell indicators. Paper or back trading is a good way of testing the effectiveness of indicators without risking money. This class allows the user to supply historical quote data and buy and sell indicators. The class will then trade using the given indicators and return the final portfolio.
The final portfolio will contain a single cash and a single share account.
Nested Class Summary | |
---|---|
protected class |
PaperTrade.Environment
|
Field Summary | |
---|---|
protected static boolean[] |
buyRule
|
protected static double[] |
buyValue
|
protected static java.lang.String |
CASH_ACCOUNT_NAME
|
protected static boolean[] |
sellRule
|
protected static double[] |
sellValue
|
protected static java.lang.String |
SHARE_ACCOUNT_NAME
|
static int |
STOCKS_PER_LINES
|
protected static java.lang.String[] |
symbolStock
|
Constructor Summary | |
---|---|
protected |
PaperTrade()
|
Method Summary | |
---|---|
protected static boolean |
buy(PaperTrade.Environment environment,
Variables variables,
Symbol symbol,
Money amount,
Money tradeCost,
double buyPrice,
int day)
Attempt to buy the given symbol. |
protected static double |
getCapital(Portfolio portfolio,
EODQuoteBundle quoteBundle,
int dateOffset)
Return the actual capital of the portfolio. |
protected static int |
getHoldingTime(PaperTrade.Environment environment,
StockHolding stockHolding,
int dateOffset)
Return the number of days we have held the given stock. |
protected static double |
getStockCapital(PaperTrade.Environment environment,
StockHolding stockHolding,
Symbol symbol,
int dateOffset)
Return the actual capital of the given stock. |
static java.lang.String |
getTip()
Return a string representing the tip for next day trading. |
static Portfolio |
paperTrade(java.lang.String portfolioName,
EODQuoteBundle quoteBundle,
Variables variables,
OrderCache orderCache,
TradingDate startDate,
TradingDate endDate,
Expression buy,
Expression sell,
Money capital,
int numberStocks,
Money tradeCost,
java.lang.String tradeValueBuy,
java.lang.String tradeValueSell)
Perform paper trading keeping the number of stocks in the portfolio roughly constant. |
static Portfolio |
paperTrade(java.lang.String portfolioName,
EODQuoteBundle quoteBundle,
Variables variables,
OrderCache orderCache,
TradingDate startDate,
TradingDate endDate,
Expression buy,
Expression sell,
Money capital,
Money stockValue,
Money tradeCost,
java.lang.String tradeValueBuy,
java.lang.String tradeValueSell)
Perform paper trading using a fixed stock value. |
protected static void |
sell(PaperTrade.Environment environment,
Variables variables,
StockHolding stockHolding,
Money tradeCost,
double sellPrice,
int day)
Attempt to sell the given stock holding. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String CASH_ACCOUNT_NAME
protected static final java.lang.String SHARE_ACCOUNT_NAME
public static final int STOCKS_PER_LINES
protected static java.lang.String[] symbolStock
protected static boolean[] buyRule
protected static boolean[] sellRule
protected static double[] buyValue
protected static double[] sellValue
Constructor Detail |
---|
protected PaperTrade()
Method Detail |
---|
protected static void sell(PaperTrade.Environment environment, Variables variables, StockHolding stockHolding, Money tradeCost, double sellPrice, int day) throws EvaluationException, MissingQuoteException
environment
- the paper trade environmentstockHolding
- the stock holding to selltradeCost
- the cost of a tradeday
- date of trade
EvaluationException
MissingQuoteException
protected static boolean buy(PaperTrade.Environment environment, Variables variables, Symbol symbol, Money amount, Money tradeCost, double buyPrice, int day) throws EvaluationException, MissingQuoteException
environment
- the paper trade environmentsymbol
- the stock to buyamount
- the amount to spend on the stocktradeCost
- the cost of a trade (not including the stock price)day
- date of trade
true
if we had enough money to acquire the stock.
EvaluationException
MissingQuoteException
protected static int getHoldingTime(PaperTrade.Environment environment, StockHolding stockHolding, int dateOffset)
environment
- the paper trade environmentstockHolding
- to querydateOffset
- current date
protected static double getStockCapital(PaperTrade.Environment environment, StockHolding stockHolding, Symbol symbol, int dateOffset)
environment
- the paper trade environmentstockHolding
- to querydateOffset
- current datesymbol
- the stock of whom you want to know the capital owned
protected static double getCapital(Portfolio portfolio, EODQuoteBundle quoteBundle, int dateOffset)
portfolio
- the paper trade portfolioquoteBundle
- historical quote datadateOffset
- current date
public static Portfolio paperTrade(java.lang.String portfolioName, EODQuoteBundle quoteBundle, Variables variables, OrderCache orderCache, TradingDate startDate, TradingDate endDate, Expression buy, Expression sell, Money capital, Money stockValue, Money tradeCost, java.lang.String tradeValueBuy, java.lang.String tradeValueSell) throws EvaluationException
stockValue
.
portfolioName
- name to call portfolioquoteBundle
- historical quote datavariables
- any Gondola variables setorderCache
- cache of ordered symbolsstartDate
- start date of tradingendDate
- last date of tradingbuy
- the buy indicatorsell
- the sell indicatorcapital
- initial capital in the portfoliostockValue
- the rough value of each stock holdingtradeCost
- the cost of a trade
EvaluationException
public static Portfolio paperTrade(java.lang.String portfolioName, EODQuoteBundle quoteBundle, Variables variables, OrderCache orderCache, TradingDate startDate, TradingDate endDate, Expression buy, Expression sell, Money capital, int numberStocks, Money tradeCost, java.lang.String tradeValueBuy, java.lang.String tradeValueSell) throws EvaluationException
numberStocks
, and will try to have all of them at roughly the same value.
portfolioName
- name to call portfolioquoteBundle
- historical quote datavariables
- any Gondola variables setorderCache
- cache of ordered symbolsstartDate
- start date of tradingendDate
- last date of tradingbuy
- the buy indicatorsell
- the sell indicatorcapital
- initial capital in the portfolionumberStocks
- try to keep this number of stocks in the portfoliotradeCost
- the cost of a trade
EvaluationException
public static java.lang.String getTip()
|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |