David Swensen Portfolio (Amibroker Code)

The original article can be found by clicking here.

Amibroker code:

The code below rebalances once every day, week, month, quarter, or year (depending on the time frame of the backtest).

SetOption("initialEquity",100000);
Leverage=1.0 ;
setOption("holdminbars",1);
SetTradeDelays( 0, 0, 0, 0 ); // 	SetTradeDelays( buydelay, selldelay, shortdelay, coverdelay ) 


if( Name() == "VTI" )
{
setPositionSize(29.95*leverage,spsPercentOfEquity);

Buy= C>0 ;
buyPrice=Close;
Sell= C>0;
sellPrice=Close ;


}


if( Name() == "VNQ" )
{
setPositionSize(19.95*leverage,spsPercentOfEquity);

Buy= C>0 ;
buyPrice=Close;
Sell= C>0;
sellPrice=Close ;


}

if( Name() == "VEA" )
{
setPositionSize(14.95*leverage,spsPercentOfEquity);

Buy= C>0 ;
buyPrice=Close;
Sell= C>0;
sellPrice=Close ;


}

if( Name() == "EEM" )
{
setPositionSize(4.95*leverage,spsPercentOfEquity);

Buy= C>0 ;
buyPrice=Close;
Sell= C>0;
sellPrice=Close ;


}

if( Name() == "IEI" )
{
setPositionSize(14.95*leverage,spsPercentOfEquity);

Buy= C>0 ;
buyPrice=Close;
Sell= C>0;
sellPrice=Close ;


}

if( Name() == "TIP" )
{
setPositionSize(14.95*leverage,spsPercentOfEquity);

Buy= C>0 ;
buyPrice=Close;
Sell= C>0;
sellPrice=Close ;


}