[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Ranking/BackTesting & Optimizing (for Fred)



PureBytes Links

Trading Reference Links

Herman,

I agree with your analogy in essence and as a retort one could say 
that the engine might not go far without the rest of the car either, 
but at least in some cases this isn't true.  For example it is of 
course possible to write systems that perform well to trade single 
vehicles whether that be ETF's, index oriented funds, some other 
specialized group of funds, currencies, eMinis etc. etc.  This is 
where I've been and what I've traded in the past few years because it 
greatly simplifies the work load i.e. you only have to be correct 
about one thing, is the market going up or down as opposed to which 
one do I pick and is it going up or down.  This to a large degree is 
in agreement with UM's statement that one only need to know where 
it's going tomorrow, not the next day or next week etc., one bar at a 
time is plenty and some would argue that the bars don't need to be 
any where near a full day in duration.  The above has gotten somewhat 
off topic but to get back on topic I would suggest that there are 
chart patterns and/or other conditions that show up repeatedly that 
have a high degree for success if one can be in the right place at 
the right time.  These are just as observable and successful in an 
index as they are in individual stocks but they of course occur much 
less frequently there and a scoring / ranking mechanism can be used 
among other things to identify situations like this across a broad 
base of tradables.  

--- In amibroker@xxxxxxxxxxxxxxx, "Herman vandenBergen" <psytek@xxxx> 
wrote:
> Hello,
> 
> Regarding Ranking Systems... it is a marvelous idea and last year i 
spent a
> lot of time implementing a system. I found, like with so many other 
ideas,
> that once you have what you thought was most important someting 
else that
> appeared easy turns out to be a big challenge.
> 
> Let us assume we have a working Ranking system, the way I see it's
> functioning is that it backtests one or more Trading systems on a 
large
> number of stocks, it collects statistics, and tables it for random 
access
> and sorting. Nice right? All we have to do is pick the best equity 
curve,
> with the smallest DD, and what else we treasure. We shuffle the 
table, and
> calculate a composite equity curve for the dynamic portfolio 
created by
> trading only the best n stocks and rotating them to always keep the 
top n in
> the portfolio.
> 
> Suppose you have that mechanism in place then comes the time to 
create a
> "Ranking" formula. You recall this has come up a few times before. 
This is a
> big challenge. To dynamically switch stocks at 1-3 weeks interval 
requires a
> fast acting formula. Equity curves can be just as noisy as stock 
prices. I
> tried the standard Equity rating formulas, they are too slow. You 
need an
> "Equity-Trading system", something like a trend following system 
but more
> responsive.
> 
> Anyway, before anybody spends a lot of time developing a Ranking 
system it
> might be wise to play with some equity Ranking formulas - because i 
think
> these are more difficult to perfect than the mechanics of shuffling 
stocks
> and creating composite equity curves. The Ranking mechanism is 
purily
> mechanical, no real problems to solve; all you need is technical 
expertise.
> 
> A good Ranking formula is a different story, it is like developing 
a trading
> system; it requires some artistry. A Ranking-Machine without a good
> Ranking-Formula is like a car without an engine :-) it won't go 
very far.
> 
> Herman.
> 
> 
> 
> 
> -----Original Message-----
> From: Fred [mailto:fctonetti@x...]
> Sent: May 12, 2003 3:19 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: Ranking/BackTesting & Optimizing (for Fred)
> 
> 
> 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
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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/


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/YoVfrB/XP.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/