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 [email protected], "rmicalet" <rmica...@...> 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 >
