Ton,
you can put any value you want. It is just an example.
this is the weight per each ticket and has to be between 0 and 1.
The original code
http://www.amibroker.com/members/library/detail.php?id=1357&hilite=OptimizerSetEngine
explains the background.
Thanks for the code. Can you please give me the complete code as most of the used vars come with initialization errors ( DefW, MinW, MaxW, SteW etc. )
Kind regards, Ton.
----- Original Message -----Sent: Monday, April 11, 2016 7:31 AMSubject: Re: [amibroker] Portfolio Optimization
Below you can find the come that may do the job you are looking for. It works well on one model (only).
If you want to run it in more than one model, then you have to write an external application to get the results of each model and put them together.
The original code was posted in AB and available at:
http://www.amibroker.com/members/library/detail.php?id=1357&hilite=OptimizerSetEngine
//====================================
// Portfolio Optimization
//====================================
SW=0; Weightcurrent=0;
for ( i = 0;i < numtickers;i++ )
{
ticker = StrExtract( TickerList, i );
weight[i] = Optimize( ticker, DefW, MinW, MaxW, SteW );
SW = SW + weight[i];
}
if ( SW <= Budget AND SW>=MinBudget)
{
for ( i = 0;i < numtickers;i++ )
{
if ( StrExtract( TickerList, i ) == Name() )
weightCurrent = weight[i];
}
PositionSize = -99.99 *weightCurrent;
}
else
PositionSize = 0;
SetOption("MaxOpenPositions",numtickers);
On 10/04/2016 23:46, psytek@bell.net [amibroker] wrote:
Has anyone attempted to write a portfolio optimization program to select the best portfolio of n tickers from a watchlist of m tickers?
I know the numbers get rather large... but perhaps there are sneaky ways around this?
Herman
Posted by: jb <jbenfeld@yahoo.co.uk>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (10) |
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/
EmoticonEmoticon