PureBytes Links
Trading Reference Links
|
Here's skeleton code for a vector-oriented interest rate.
This would be better if it converted the interest rate to recognize difference between bar lengths and compounding periods per year. For example, the quoted rate is annual, the bar length is a week, and interest is paid 1/month on the average daily cash balance in the account. By contrast, the code below assumes the number of bars per year is also the number of compounding periods per year.
Still, it's a start and requires no money market fund data series or composite.
Looking forward to your feedback. :)
///////////////////
interestsym = StrToUpper( ParamStr( "InterestSym", "!IRX" ) );
intrate_decimal = Foreign( interestsym, "Close", 1 ) / 100;
scalar_decimal = Param( "Interest Scalar", 1, 0, 1.0, 0.05, 0.05 );
ippy = Param( "IntPeriods/Year", 52, 1, 366, 1, 1 );
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio || Status("action") == actionExOptimizePortfolio )
{
interestpmt=0;
bo = GetBacktesterObject();
bo.PreProcess();
for( bar = 0; bar < BarCount-1; bar++ )
{
bo.ProcessTradeSignals( bar );
cash[bar] = bo.Cash;
rate[bar] = ( intrate_decimal[bar] * scalar_decimal[bar] ) / ippy[bar];
interestpmt[bar] = NZ( cash[bar] * rate[bar] );
bo.Cash += interestpmt[bar];
}// for bar
bo.PostProcess();
interestoncash = LastValue( Cum( interestpmt ) );
bo.AddCustomMetric( "Cash interest", interestoncash );
}// if aaction
///////////////////
--- In amibroker@xxxxxxxxxxxxxxx, "whitneybroach" <WhitneyBroach@xxx> wrote:
>
> Fred / Tomasz,
>
> I'm not finding that to be the case, at least with the limited money
> market fund data that I have.
>
> My approach so far is to take a Sell signal from the system as a Buy
> of the fund. When the fund is sold on a later bar, AFL thinks the
> gain is zero. The money fund price is almost constant and there is no
> yield income series for AFL to use to add value to the equity curve.
>
> To work around this while looking for an update on suggestion #944,
> I've tried to generate a simulated money fund series
> with code below. This seems to work except that, in the case of
> weekly series, it produces an incorrect result around the September
> 2001 market interruption. Any suggestions for improvement?
>
> (OBTW: Fred, I tried to email you weeks ago about IO and did not
> succeed. Any suggestions?)
>
> Best,
> Whitney
> //////////////////////////////////////////////
> /*
> Money market fund simulator
>
> Given a yield vector and a factor, produce a price series that
> simulates bar-bar gains from purchasing a money
> market fund and selling on some subsequent bar.
>
>
>
> */
>
> function moneymarketfundsim( rate_decimal, scalar, biy ) // biy = bars
> in year
> {
> local bar;
> local bcm1; bcm1 = BarCount() - 1;
> local bar_mul;
> local mm_price;
> bar_mul = ( ( scalar * rate_decimal ) / biy ) + 1;
> mm_price = 0;
> mm_price[0] = 1;
> for( bar = 1; bar <= bcm1; bar++ )
> {
> mm_price[bar] = mm_price[bar-1] * bar_mul[bar];
> }
> return mm_price;
> }// function moneymarketfundsim
>
> // test with explore
> /*
> // sym_commpaper_3m is weekly bars of 3-month commercial paper yield
> rate_d = Foreign( sym_commpaper_3m, "close", fixup = 0 ) / 100;
> scalar = 0.9; // simulate 90% of index yield
> mmf = moneymarketfundsim( rate_d, scalar, 52 );
> Plot( mmf, "mmkt", colorGreen, styleLine );
> Filter = 1;
> AddColumn( mmf, "mmf", 1.4 );
> */
> //////////////////////////////////////////////
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@> wrote:
> >
> > This is simple enough to do already by switching to a money market fund
> > on sells / covers. As far as constant dollar or inflation related
> > results go this can be dealt with if desired using the available CPI
> > data which are available back at least as far as the 1800's.
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "whitneybroach" <WhitneyBroach@>
> > wrote:
> > >
> > > Your feedback is welcome about this suggestion for a vector-based
> > > interest rate feature in AFL:
> > > <http://www.amibroker.com/feedback/view_bug.php?bug_id=944>. The
> > > longer the backtest or the more cash a system holds, the more
> > > pertinent the difference in interest payments.
> > >
> > > The suggestion doesn't mention this, but a related feature might be an
> > > inflation vector as well for reporting real (vs nominal) test results.
> > >
> > > Best regards,
> > > Whitney
> > >
> >
>
------------------------------------
**** 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:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto: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/
|