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

[amibroker] Re: Is this system possible in Amibroker?


  • Date: Wed, 06 Jan 2010 02:07:11 -0000
  • From: "rmicalet" <rmicalet@xxxxxxxxxxx>
  • Subject: [amibroker] Re: Is this system possible in Amibroker?

PureBytes Links

Trading Reference Links

I would ultimately like the system to send trades through Interactive Brokers, but it doesn't necessarily have to do any bookkeeping or monitoring (other than figuring out when to enter or exit). 

It's an S&P 500 sector ETF model so there are only 9 ETFs to consider, but there are too many moving parts to track the model manually--although I could probably just use IB's Excel DDE to read in live prices and run the system in real-time that way. However, I was really hoping to be able to implement it in Amibroker in order to backtest different entry and exit options using intraday data (right now it enters at the close and exits at the open or the close).

Since there are only 9 ETFs, would it be possible to bypass the rotational backtesting mode and simply code this up using the "foreign()" function and "for" loops? Ranking 9 assets shouldn't be too much of a problem (particularly if amibroker has a function like Exel's "large" and "small", whereby one can identify the Nth largest or smallest element of an array).



--- In amibroker@xxxxxxxxxxxxxxx, "droskill" <droskill@xxx> wrote:
>
> I think most of what you talk about is possible - some of it will be challenging, but I still think doable.
> 
> Running the system in real time will likely take the most work - would you want the system to interact with a broker to make the trades and then monitor the positions?  That will be challenging.
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "rmicalet" <rmicalet@> wrote:
> >
> > I have a rotational trading system that gets creative in the position
> > sizing. I was wondering if the following is possible in Amibroker:
> > 
> > 
> >     1. Rank a (small) universe of stocks by a single factor
> > 
> >     2. Select the top x% and bottom x% to go long and short, respectively
> >     3. Weight the individual long and short positions inversely
> > proportionally to their n-day volatility. For example, let's say the
> > system wants to go long and short two stocks on each side. Let IVL1 be
> > the n-day inverse volatility of long stock 1, IVL2, IVS1, and IVS2 be
> > the n-day inverse volatilities of long stock 2, short stock 1, and short
> > stock 2, respectively. Further, let WL1, WL2, WS1, and WS2 be the
> > percent weights of long stocks 1 and 2 and short stocks 1 and 2,
> > respectively. Then, the system wants WL1 = IVL1/(IVL1 + IVL2); WL2 =
> > IVL2/(IVL1 + IVL2); WS1 = IVS1/(IVS1 + IVS2); WS2 = IVS2/(IVS1 + IVS2).
> >     4. Then, as a further refinement, the system wants to beta-adjust the
> > short positions relative to the long positions. That is, if the
> > portfolio of long stocks (weighted according to their volatilities) have
> > an m-day beta of B with the portfolio of short stocks (again, weighted
> > according to their volatilities), the system wants to create a
> > long/short portfolio that has B dollars short for every dollar long.
> >     5. The system wants to buy on the close
> >     6. The system will exit at the following day's open if the portfolio
> > is up at the open, otherwise it will to hold until the following day's
> > close, when it will repeat steps 1 through 5
> > I'd like to both backtest the system (I've backtested it previously in
> > Excel/VBA) and run it in real-time in Amibroker. I'd be grateful for any
> > insight as to whether the weighting scheme (both the
> > inverse-volatility-based weighting, and the beta adjustment) is doable
> > in Amibroker, and if so, how complex a program I'd be looking at. The
> > rest of the system seems relatively straightforward.
> > 
> > In case steps 3 and 4 above were not clear, here's a little more detail.
> > After finding WL1, WL2, WS1, and WS2, I'd like to form two time series
> > of historical returns. The first time series take the historical returns
> > of the two long stocks and combines them using WL1 and WL2 (i.e., long
> > portfolio, PL = WL1*R1 + WL2*R2, where R1 and R2 are the time series of
> > returns for long stock 1 and 2, respectively). The second does the same
> > for the short stocks using WS1 and WS2. Then given the two portfolios,
> > PL (long) and PS (short), I want to find the beta of PL to PS. Finally,
> > I want to have the ultimate portfolio, P, to be as follows: P = PL -
> > B*PS (where B is the beta of PL to PS). The final weights with the beta
> > included would be:
> > 
> > WL1 = IVL1/(IVL1 + IVL2)
> > WL2 = IVL2/(IVL1 + IVL2)
> > WS1 = B*IVS1/(IVS1 + IVS2)
> > WS2 = B*IVS2/(IVS1 + IVS2)
> > 
> > (But, of course, one needs to find the weights sans B first in order to
> > find B.) Would be grateful for any pointers as to how to go about
> > implementing this, if it's indeed possible.
> > 
> > Regards,
> > Ray
> >
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/