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

[amibroker] Re: Duplicating Symbols


  • Date: Fri, 15 Jan 2010 03:32:23 -0000
  • From: "dbwyatt_1999" <dbw451@xxxxxxxxxxxxx>
  • Subject: [amibroker] Re: Duplicating Symbols

PureBytes Links

Trading Reference Links

Thanks Mike, I appreciate the time you've spent thinking about implementing multiple systems and avoiding duplicate symbols.  I originally went down the path of trying to use one symbol per market for 12 models and my system logic got out of hand.  Using a separate backtester run for each model greatly simplified my system code, but as you point out increases the overhead of managing duplicate symbols.  

You've given me some good things to think about.  I also see you left a few suggestions for coding in the other fork of this thread.  I'll take a look at it tomorrow.

Regards,

David



--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> Hmmm. Let me test my assumptions here:
> 
> > I'm already using a uniquely named watchlist for each model
> 
> > The unique symbol names are duplicates of a source symbol with incremental numbers attached (e.g. ES, ES_2, ES_3, ..., ES_12)
> 
> Those two quotes sound to me like you have
> 
> 1. one uniquely named watchlist per model.
> 2. all symbols in a given watchlist have a strict naming pattern (e.g. ES_2 for watchlist 2, ES_3 for watchlist 3).
> 
> That sounds redundant to me. Either use symbol naming pattern (e.g. trailing _2 implies model 2) OR use watchlist inclusion (e.g. inclusion in Watchlist2 implies model 2). I don't see the need for both just to determine which model to apply.
> 
> > If I put the same symbol name in two different uniquely named watchlists, then the strategy code would find that symbol in both model watchlists and not know which model to execute.
> 
> What is the difference between finding ES_2 in Watchlist2 and ES_3 in Watchlist3 to conclude that you must apply both model 2 and model 3 vs. finding ES in Watchlist2 and ES also in Watchlist3?
> 
> In both cases, the model to use is implied by the name of the watchlist in which the symbol was found (Watchlist2 implies model 2, Watchlist3 implies model 3). If ES appears in two watchlists, then you want to apply both models, which is exactly the same as having two symbols (ES_2, ES_3) since the underlying data is still just that of ES.
> 
> If you were not already looking for inclusion in a watchlist, but rather were just parsing the symbol name to determine the model (e.g. _2 implies model 2, etc), then the lookup for watchlist inclusion will be additional overhead. However, it might still be worthwhile compared to trying to manage the duplicates.
> 
> > I would think in order to use the same symbol name for each model, the master watchlist would have contain duplicate symbol names for each model.
> 
> No. Each symbol would only appear once. Your code would just test for inclusion in each watchlist (one watchlist per model) and upon finding inclusion would apply the associated model.
> 
> > I have some models that occasionally will be in positions in different directions at the same time (i.e. some models will be long while other timeframe models will be short).
> 
> This would be the only justification that I see for having duplicates. But, you might still be able to address that by using backtest mode RegularRawMulti and writing custom backtest code to handle the signals (possibly requiring low level backtester interface). This would not be a trivial undertaking. I can't even say for sure whether AB would allow it.
> 
> So, the tradeoff as I understand it is:
> 
> 1. Write code once and forget about it
> 2. Single point of failure (custom code)
> 3. Scales without code change to unlimited symbols over unlimited models
> 
> vs.
> 
> 1. AB handles the backtesting for you (major plus!)
> 2. Multiple points of failure (x symbols times y models)
> 3. Constantly update duplicate symbol histories (error prone)
> 
> Mike
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "dbwyatt_1999" <dbw451@> wrote:
> >
> > 
> > 
> > 
> > 
> > 
> > 
> > I'm already using a uniquely named watchlist for each model (in fact, I think I got the InWatchList idea from you Mike).  I'm not sure I understand how putting the same symbol in multiple watchlists would work with multiple models.  If I put the same symbol name in two different uniquely named watchlists, then the strategy code would find that symbol in both model watchlists and not know which model to execute.  I also have a master portfolio watchlist which the portfolio backtester walks through each symbol one at a time and determines the specific model for each symbol by finding it in a uniquely named watchlist.  I would think in order to use the same symbol name for each model, the master watchlist would have contain duplicate symbol names for each model.  All the models are executed in the first phase of the portfolio back-tester.  I have some models that occasionally will be in positions in different directions at the same time (i.e. some models will be long while other timeframe models will be short).  Having separate symbol names for each model allows the portfolio backtester to handle each model for each market separately in the first pass, and them apply their signals against shared equity in the second pass.   
> > 
> > If there is a way, I would prefer not duplicating the symbols.  I hashed through how to implement multiple models a few months ago on this forum and the consensus was that a separate symbol name is needed for each model, but I'm willing to revisit if there is a better way. 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> > >
> > > Hi,
> > > 
> > > Why, exactly, do you want to duplicate the symbols in the first place?
> > > 
> > > Why don't you just add the same symbol to multiple watch lists? If you are not actually changing the underlying bar data, I don't see why you would want to duplicate that data.
> > > 
> > > If your logic is dependent upon parsing the symbol names in order to determine which model to apply, you could instead check for membership within a uniquely named watchlist. This would be slower. But, the maintenance nightmare that you are describing would disappear. And, it would be easier to extend the system (i.e. adding new symbols to a given watchlist without any change of code).
> > > 
> > > Mike 
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "dbwyatt_1999" <dbw451@> wrote:
> > > >
> > > > I've attempted to code functionality to duplicate symbols using the AmiBroker OLE interface.  In my test code below, 2 symbols ($A0 and $CA) are attempted to be duplicated into symbols $A0_2, $A0_3, $CA_2, and $CA_3.  The duplication process entails:
> > > > 
> > > > 1. adding a new symbol
> > > > 2. setting the new symbol information using the source symbol information
> > > > 3. adding new symbol quotes and assigning source symbol quote values.
> > > > 
> > > > My test code creates a new symbol ($A0_2) and assigns the FullName and Currency, but does not assign any other symbol information.  The code also does not create the quotes for the new symbol.  The SaveDatabase() routine is reached and executed.  The code then generates an "unhandled application error" probably caused by RestorePriceArrays() to a new symbol that has no quotes.
> > > > 
> > > > Can anyone tell me what's wrong with the following code?
> > > > 
> > > > //
> > > > // AmiBroker OLE code to Duplicate a list of Symbols
> > > > //
> > > > DuplicateTickers = ParamTrigger("Duplicate Tickers", "Click here to Duplicate Tickers");
> > > > TickerList = ParamStr("Tickers to Duplicate","$AO,$CA");
> > > > MaxTickerNum = Param("Max Ticker Number",3,2,12,1);
> > > > 
> > > > if(DuplicateTickers)
> > > > {
> > > > 
> > > > 	AB = CreateObject("Broker.Application");
> > > > 	oStocks = AB.Stocks;
> > > > 	for (m=2; m<=MaxTickerNum; m++) // Loop through each duplicate
> > > > 	{
> > > > 		for(n=0; (Ticker=StrExtract( TickerList, n))!=""; n++) // Loop through each symbol
> > > > 		{
> > > > 			oSymbol = oStocks.Item( Ticker );
> > > > 
> > > > 			TickerNew = Ticker + "_" + m;
> > > > 			oSymbolNew = oStocks.Add( TickerNew );
> > > > 
> > > > 			oSymbolNew.FullName = oSymbol.FullName;
> > > > 			oSymbolNew.Currency = oSymbol.Currency;
> > > > 			oSymbolNew.Continuous = oSymbol.Continuous;
> > > > 			oSymbolNew.MarketID = oSymbol.MarketID;
> > > > 			oSymbolNew.GroupID = oSymbol.GroupID;
> > > > 			oSymbolNew.IndustryID = oSymbol.IndustryID;
> > > > 			oSymbolNew.DataLocalMode = oSymbol.DataLocalMode;
> > > > 			oSymbolNew.RoundLotSize = oSymbol.RoundLotSize;
> > > > 			oSymbolNew.MarginDeposit = oSymbol.MarginDeposit;
> > > > 			oSymbolNew.TickSize = oSymbol.TickSize;
> > > > 			oSymbolNew.PointValue = oSymbol.PointValue;
> > > > 
> > > > 			SetForeign( Ticker );
> > > > 			qDate = DateNum();
> > > > 			for(i=0; i<BarCount; i++)
> > > > 			{
> > > > 				oQuotations = oSymbolNew.Quotations;
> > > > 				oQuote = oQuotations.Add( qDate[i] );
> > > > 				oQuote.Open =  O[i];
> > > > 				oQuote.High =  H[i];
> > > > 				oQuote.Low =   L[i];
> > > > 				oQuote.Close = C[i];
> > > > 				oQuote.Volume = V[i];
> > > > 				oQuote.OpenInterest = OI[i];
> > > > 			}
> > > > 
> > > > 			AB.RefreshAll(); 
> > > > 			AB.SaveDatabase();
> > > > 			RestorePriceArrays();
> > > > 		}
> > > > 	}
> > > > 
> > > > }
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > 
> > > > Thanks,
> > > > 
> > > > David
> > > > 
> > > > 
> > > > 
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "dbwyatt_1999" <dbw451@> wrote:
> > > > >
> > > > > I've got a system that consists of 12 models.  For each model, I've defined a watchlist that has unique symbol names that are only used by a single model.  The unique symbol names are duplicates of a source symbol with incremental numbers attached (e.g. ES, ES_2, ES_3, ..., ES_12).  I create the duplicate symbols by starting with an ASCII file which I import, rename, import again, rename, import again, etc.  Then I have to go into Symbol information for each symbol and manually enter the contract specifications (lot size, margin, tick size, point value).
> > > > > 
> > > > > I now have a new requirement for 55 additional instruments and have obtained historical futures data from PremiumData.  The 55 instruments were very easy to load and PremiumData has predefined the contract specifications.  Now I need to somehow duplicate the 55 instruments 11 times into 660 total symbols.  I have not found a native way in AB to duplicate (or rename) symbols.  I can export the data using AFL, but import files don't include the symbol information.
> > > > > 
> > > > > Duplicating a symbol looks like it can be done using the Amibroker activeX object.  Before I embark on a new programming task, I thought I'd ask if anyone has written a script to duplicate an AB symbol:
> > > > > 
> > > > > 1. creates a new symbol.
> > > > > 2. copies the quote data from a source symbol to the new symbol.
> > > > > 3. copies the symbol information from the source symbol to the new symbol.
> > > > > 
> > > > > Ultimately, I would like to loop through a watchlist 11 times; creating and updating duplicate symbol quotes and information.  Any directions or suggestions would be great.
> > > > > 
> > > > > Thanks,
> > > > > 
> > > > > David
> > > > >
> > > >
> > >
> >
>




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

**** 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/