SO
Share Optimiser
See News at the bottom of this page.
This project aims to create a sharemarket (or stockmarket) optimisation software system which:
- aims to forecast not only index and share prices, but also the uncertainty associated with those predictions;
- automatically suggests changes to an existing portfolio as new information arrives;
- maximises returns based on a specified risk (of portfolio loss);
- acknowledges that brokerage costs will limit the optimal portfolio change rate.
Scope Elements
The important elements (and associated techniques) are:
- time-series modelling/prediction/forecasting (via the following candidate techniques)
- linear time-series models with variable interval
- non-linear time-series models using feedforward neural networks
- (Extended) Kalman Filtering
- integration of stock indicators (P/E etc.) with time-series to improve prediction
- (long-term feature, since downloadable data sources for indicators seem scarce)
- uncertainty estimation and aggregation
- Principal Component Analysis (PCA) for reducing dimensions of index set
- constrained optimisation for maximising returns at a risk constraint
Software Tools
The tools are based around existing open source programming and mathematical software.
python - as the basic programming language
SciPy - for the mathematical algorithms (including numpy, matplotlib) - also see the SciPy page on the Process Control part of this wiki
NeuroLib - a fast C implementation of feedforward Neural Networks written by PeterMills
iTrade - a stockmarket portfolio management, technical analysis and plotting tool being developed by GillesDumortier
- provides basic infrastructure, conventional technical analysis, and GUI for SO system
- also uses python, numpy and matplotlib
needs plugin modifications for Australian Stock Exchange data (asx.zip) - done
Status
Done
- establish feasibility of stock price prediction (for the component of movement that is predictable)
- customisation of iTrade to cater for the local (Australian) stockmarket data acquisition.
GD: your attachment has been merged in the SVN trunk.
In progress
- develop a prediction indicator for iTrade based on an NN trained on historical data from many stocks
To Do
- integrate new indicator into iTrade's new indicator plug-in system
GD: I need to work on indicator back-end. Follow progress : tracker.
- begin multivariable-modelling for a wide ranging portfolio of indices (as a back-bone for forecasting individual share prices)
- set up scanning for all stock codes to find candidate stocks with best return/risk measures
use optimisation to calculate an "optimal" change to the portfolio (accounting for broking costs etc)
Ideas
- Design of iTrade predictive indicator
- Output in the form of predicted (1 week) price change divided by calculated prediction uncertainty (i.e. like return/risk). This automatically normalises for price etc and helps confine the indicator to a reasonable range of values.
- NN predictor:
- a single trained network for prediction of all stocks. Although not tailored to the nuances of an individual stocks, this has the advantage that much larger data-sets can be used for training, making the network more generally applicable and less biased due to the current resources boom.
- trained on most significant stocks in the market (e.g. top 200 capitalised companies, or total volume from entire stock history (to preferentially capture long historied stocks)). The stocks used for training may need to be from the target market if the markets are significantly different in stock type (e.g. NASDAQ). For a user, the best data to use for training would be from:
- specific sector stocks for which the preditions will be used (e.g. NASDAQ, or Resource stocks only). This requires the preparation of a selection of representative stock price history files for training, by the user.
- representative stocks from a specific market, e.g. Australian ASX stock-exchange. This requires the preparation of a selection of representative stock price history files for training, by the user.
- ASX general stock history. Although based stocks only from the ASX, it should be reasonably representative of world-wide stockmarket dynamics. The advantage of this option is that the user can just use a network prediction model which is distributed by the author.
- incorporate: high, low, close, volume, day-of-week, day-of-year
- Use an Non-linear AR model with increasing time-step interval for older AR terms. The terms represent average price/vol behaviour over the interval, rather than a sample at the time-step instant.
- If NN package can handle it, use clustered inputs for each interval (high, low, close, vol).
- Need to normalise the history data to allow multiple company price histories to be combined into a single training set. Normalise by taking logs, differencing, divide by 2 standard deviations (calculated from zero?).
- Consider normalising high and low (and open) to be relative to (closing) price value. How to aggregate the high and low values in larger intervals of AR model? But if the price time-series is differenced, then "price" will be represented by a rate-of-change type of value which won't be comparable to the high and low values. So high and low values should be an average relative to the price (normalised by log-price), even though price will not appear in the NN inputs (only average differenced price).
- Prediction uncertainty output is trained using a second stage of training which evaluates the absolute value of the prediction error for each pattern. Then this error is used (normalisation similar to price diff) as the training target for the second output. This error is used to normalise the prediction value to form the indicator.
- Also consider multiple prediction outputs for different intervals, e.g. 1 day, 1 week, 1 month (each with their own error).
- Use iTrade's "Investment Period" and "Risk Level" settings for directing SO portfolio optimisation.
GD: starting with the r619 trunk, these settings are for a whole portfolio and can be edited on the Portfolio properties page. See term() and risk() methods in the Portfolio object.
- Add a new Tab in "Money Management" to calculate and display risk/return.
- Use -i flag on iTrade to do a command-line, scheduled history-update for a SO candidate "portfolio". Then use this history to generate models, predictions and risks for each stock; then optimise portfolio change recommendation. All scheduled to be calculated at close of market, by command-line, ready for after-hours review.
- A chart to illustrate chart of predicted Risk vs Return for stocks in a (proposed) portfolio:
References
http://groups.google.com/group/misc.invest.financial-plan/msg/3b9d13f3d399050c?dmode=source
http://www.departments.bucknell.edu/management/apfa/Dundee%20Papers/27Schwartz.pdf - how to optimise a portfolio that beats the S&P500.
Other software sources
ffnet for NNs (uses numpy, but also needs compiled fortran, http://ffnet.sourceforge.net )
- bpnn.py for NNs (pure-python (portable), moderately fast but doesn't use numpy arrays and isn't vectorised
check http://svn.scipy.org/svn/scipy/trunk/Lib/sandbox/ann/ for developments in SciPy
- pyKF for Kalman filter
Weblog
| PeterMills | Development Halted Due to the Global Financial Crisis, it will be some time before any technical analysis of stock histories will be useful. Thus, work on this project has been suspended indefinitely. I've put it back into CategoryIdea (for later review). |
2009-03-07 20:25:01 | ||
| PeterMills | In reply to 128 Given the brevity of your sig, it seems a little ironic to be asking such questions without giving a reason. Never-the-less, I'm a charitable person, so here goes: My background is in Engineering Process Control, including time-series modelling and model identification, both phenomenological and black-box. I'm not sure how to answer the "who are you?" - my sig is my name. There is nothing specific re P/E in my descriptions. It is used merely as an example of the type of indicator that is common in stockmarket "technical analysis". If it provides any sort of predictive information, it might be useful as an input (with some pre-processing) to a NN prediction model. |
2008-05-18 20:36:41 | ||
| 128 | Who are you? What is your background? Your use of the term indicator in connection with the P/E ratio seems to imply a certain subtlety; please expand. |
2008-04-28 12:53:56 X | ||
| PeterMills | Source of undelayed real-time quotes for ASX Looks like e-Trade provides undelayed quotes in a relatively plain html format which should be easily parseable. The link for this is: https://invest.etrade.com.au/QuotesAndResearch/Shares/Quote.aspx?symbol=CODE&tab=Quotes where CODE is the ASX ticker code. |
2007-07-30 11:37:15 | ||
| PeterMills | Yahoo history update for ASX fixed now! It seems that a change in iTrade code from using http://ichart.finance.yahoo.com/table.csv to http://download.finance.yahoo.com/d/quotes.csv as the URL lead-in, needed to be reverted back to the ichart original. I'm not sure why it has changed, nor why it needs to change back for ASX codes (others as well?). |
2007-06-21 01:47:46 | ||
| PeterMills | Yahoo update for ASX broken! The URL generated by itrade_import_yahoo.py in version 0.4.6: http://download.finance.yahoo.com/d/quotes.csv?a=00&b=11&c=2007&d=05&e=20&f=2007&s=CBA.AX&y=0&g=d&ignore=.csv doesn't work. If the normal Yahoo web site is used to get price history, the URL looks like: http://ichart.finance.yahoo.com/table.csv?s=RIO.AX&d=5&e=20&f=2007&g=d&a=0&b=4&c=2000&ignore=.csv |
2007-06-21 01:11:39 | ||
| PeterMills | Hi Rafael. This is not a group as such, just a personal project. This project is about better prediction and indicators as well as optimisation of a portfolio. I'm presently developing it (slowly) to be an add on to the iTrade project (see above in Software Tools). iTrade could be considered a team - there seems to be several contributors, but Gilles is the primary developer. |
2007-06-03 21:03:47 | ||
| c-69-140-13-32 | I am Rafael Queral and would like to know more about this project. Does this project work in windows 2K and XL? How do I join this group? Please send your answers to queralra@hotmail.com. Thank you. |
2007-06-02 02:14:19 X | ||
