PureBytes Links
Trading Reference Links
|
Well if you think about how AA works and specifically optimization
and backtesting you'll agree that backtesting runs inside
optimization. By that I mean that for each combination of parameters
that can be varied in optimize statements the backtester runs it for
each tradable that's in play whether that's a single stock or 1000
and it does this by changing the combination and then turn the
backtester loose on whatever the universe of stocks is. What's needed
then is to have a scoring & ranking routine that happens prior to
backtesting really getting underway and that routine needs to run
completely for all stocks and make the rankings available for the
bactester to use before the backtester runs for the first stock.
During the time the backtester is in play you need to have a better
mechanism then what exists natively for keeping track of the
portfolio oriented results and when the backtester finishes you need
a way to invoke a routine to evaluate the bactest. Optionally if
optimization is in play you might want to have a final evaluation
routine to rank the evaluations as it were to see which one really is
the best.
So lets see what we have and what we need in a hierarhical sense.
1. Optimizer ( Yup we have that ) ...
2. A scoring routine that needs to run for all stocks across the
entire timeline before backtest runs for the first bar of the first
stock. We don't have this but using the constructs in ABTools we can
determine what symbol is the FIRST symbol in the watchlist we are
processing and if it's the same as what the backtester has in play
then we know the backtester hasn't done anything yet and we can
sidetrack it by a simple if statement to do the scoring. The results
of scoring can be kept using a variety of ABTool constructs including
files, tables or arrays.
3. A ranking routine that orders the scores so the backtester can use
them. We don't have this either but this can either be done on the
fly with scoring or it could be done in it's entirety once the
scoring phase is complete. The former solution would be
significantly more efficient as otherwise all rankings for every
stock for every bar have to be saved until scoring is complete and
ranking can get its hands on it.
4. A backtester ( Yup we have that, and although it can keep track of
individual stock results it needs help keeping track of the portfolio
oriented results ) This part can be done in conjunction with the next
item but has to be complete before the evaluation routine begins and
the equity curve is built. It's fairly easy in the backtester to
keep track of bar by bar percentage changes in whatever we have
invested in which is by and large enough information to calculate the
overall effect on the portfolio.
5. An evaluation routine that builds the equity curve and optionally
saves them somewhere for future use in or outside AB. This can be
done in a similar manner to the way we diverted the backtester in #2
except this time we want to keep the backtester from invoking this
code until it has finished processing the LAST ticker. Again another
ABTools construct.
6. Optionally a routine that compares multiple equity curves of
optimizations.
As far as having code as a reference goes I would agree that this
simplifies things and even though what I have is functional this is
still a work in progress. Who knows by next Thursday Tomasz may have
added all this functionality as plug and play to AB.
--- In amibroker@xxxxxxxxxxxxxxx, "b519b" <b519b@xxxx> wrote:
> Fred,
>
> Well done. I have been looking for a way to do the type of testing
> in AB that you describe. Would you be willing to post some sample
> AFL code that show how to set things up so this will work? You
could
> remove the code for any trading strategies you do not wish to
share.
>
> I learn something new best by seeing working code that I can use as
> a model.
>
> Any tips or help would be much appreciated.
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <fctonetti@xxxx> wrote:
> > Steve,
> >
> > As a followup to the post below I'll state that at one point
> during
> > the development of a scoring/ranking/backtesting AA I thought
that
> > this either needed to be done in multiple AA's i.e. an explore to
> > score the stocks and rank the scores, a backtest to take the
> trades
> > based on the rankings and then an explore to do the evaluation of
> the
> > equity curve. This entails three manual steps which could be
> shorted
> > to one using OLE Automation but still leaves any desired
> optimization
> > sitting on top of the whole process swinging in the breeze or at
> best
> > being somewhat "messy" by having an external program batch
> processing
> > the modules and supplying information for the optimization. I
> have
> > since discovered however a way to put it all together in a single
> AA
> > module. Although it would still be nice to have, for me at least
> > this somewhat obviates the need for a built in AB solution for
> > portfolio trading for the time being.
> >
> > Fred
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <fctonetti@xxxx> wrote:
> > > Steve,
> > >
> > > Anything is possible if you write the code for it and Uenal
> Mutlu's
> > > ABTool provides a lot of functionality without which it would
be
> > > difficult if not impossible to do, hell it was somewhat
> difficult
> > to
> > > do with it.
> > >
> > > IMHO replacing stocks is a function of the ranking process i.e.
> if
> > > something rises to a higher rank on the list then what one is
> > holding
> > > then you switch into the new stock and remove the lowest rank
> one
> > on
> > > the list but this could also be coupled with the proviso to not
> > > switch until one gets a sell on a particular stock.
> > >
> > > Fred
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "steve_almond" <steve@xxxx>
> wrote:
> > > > Fred,
> > > >
> > > > Chart looks good to me! I'm surprised by your description of
> the
> > > > system. I thought that ranking a group of stocks and picking
> the
> > > top
> > > > n for purchase wasn't (yet) possible in AB. How did you
manage
> > > this?
> > > > How do you decide when to replace the current picks with new
> > picks?
> > > >
> > > > Thanks for any pointers.
> > > >
> > > > Steve
> > > >
> > > >
> > > >
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx, Fred Tonetti
<ftonetti@xxxx>
> > > wrote:
> > > > >
> > > > > Steve,
> > > > >
> > > > > As an alternative answer to your question ...
> > > > >
> > > > > If CAR is the goal with disregard to DD's and NDX (of
sorts)
> is
> > > the
> > > > > vehicle, it's not too difficult to obtain semi decent
> results
> > > over
> > > > that
> > > > > timeframe using a simple non optimized ranking system to
> pick
> > the
> > > > top n
> > > > > candidate stocks from the NDX as a rotating portfolio to
> trade
> > > > long and
> > > > > short (See Attached) These are hardly what I'd call
> > outstanding
> > > > results
> > > > > given the size of the DD's, but given that this was in
> essence a
> > > > > "sample" ranking criteria to drive the surrounding
> development
> > > > activity
> > > > > the results are IMHO better than expected.
> > > > >
> > > > > Fred
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs from home.
Over 14,500 titles. Free Shipping
& No Late Fees. Try Netflix for FREE!
http://us.click.yahoo.com/BVVfoB/hP.FAA/uetFAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|