Port of Apollo backtest to R.