Trading Calendars ( + bonus question on price vs returns)

Hello Alphien,

I have two questions on the framework :

1/ When you call the payout function, why do pass in returns and not prices ? Prices are unambiguous.

Looks like to pass in 1d log returns

2/ I am not comfortable with your trading calendar handling.

The prices seem to be padded rolling forward when the data is not a trading day for an asset.

Thus, if you sample these dates monthly for monthly rebalancing, you are not guaranteed that the sample date will be a trading day for all assets.

However the comments from your backtesting function hints that those days are discarded.

So we will end up randomly skipping some reabalancing dates. Not a big deal for daily rebalancings, but for monthly ones…

> Found 27 day(s) where weights are assigned but 1 or more markets are closed. These dates will be removed.


In short, the trading logic is not fully consistent with the input data logic.

Having NAs in the price time series or clean time series would allow everyone to handle the rebalancing logic.

Example: 2010-05-31 is not a trading day in the US (memorial day), but you report prices for TY and the HY ETF

TYa = getAlphathonBBs(“TYa”,asPrice = TRUE)

> tail(TYa[‘2010-05’])

> TYa

> 2010-05-24 105.9114

> 2010-05-25 106.4065

> 2010-05-26 105.9113

> 2010-05-27 105.1824

> 2010-05-28 105.5125

> 2010-05-31 105.5125



Thx

Hi Stéphane, thanks for your question.


  1. All backtesting is done on Building Blocks(or BB). Building blocks are constructed from the series of adjusted returns; more precisely, we take out any one-off events (rolls, dividends, split) from price series to build a series of pure market returns. This makes them robust for backtesting. You can check out this page for a description in the case of futures as an example. https://wiki.alphien.com/ALwiki/Introduction_to_Alphien_Pillars_and_Building_Blocks


2. I understand your concerns. As you correctly pointed out, the backtest checks whether the underlying series of the BB can be traded; if the allocation signal from your strategy is raised on a non-trading day, the allocation is discarded. It is only executed if the execution date is a trading day (remember that by default, all rebalancings are done with a lag 1, meaning the allocation raised at date T only gets executed at date T+1; see this page https://wiki.alphien.com/ALwiki/Creating_a_payout for examples).

However, you can handle the non-business day case within your payout as you suggested. As explained above, building blocks are computed from returns. If there is a non-business day at date T, the return between T-1 and T will be 0. Consequently, if the return at date T is 0, then you know it is a non-trading day. In your payout, you can handle such a condition by excluding all days that have 0 returns for instance.


Hope this helps.

Please let me know if you need more details on any points.