def test_crp(S): """ Make sure that equity of a portfolio [1,0,...,0] with NaN values is the same as asset itself. """ b = [1.] + [0.] * (len(S.columns) - 1) result = algos.CRP(b).run(S) assert abs(result.total_wealth - S[S.columns[0]].iloc[-1]) < EPS
def AlgResult(self, ag): if ag == 'OLMAR': algo = algos.OLMAR(window=5, eps=10) if ag == 'CRP': algo = algos.CRP() if ag == 'BAH': algo = algos.BAH() if ag == 'Anticor': algo = algos.Anticor(window=5) if ag == 'CORN': algo = algos.CORN(window=5) if ag == 'BCRP': algo = algos.BCRP() if ag == 'CWMR': algo = algos.CWMR(eps=10) if ag == 'PAMR': algo = algos.PAMR(eps=10) if ag == 'RMR': algo = algos.RMR(window=5, eps=10) if ag == 'UP': algo = algos.UP() if ag == 'WMAMR': algo = algos.WMAMR(window=5) if ag == 'ONS': algo = algos.ONS() if ag == 'Kelly': algo = algos.Kelly(window=5) if ag == 'EG': algo = algos.EG() if ag == 'BNN': algo = algos.BNN() if ag == 'BestSoFar': algo = algos.BestSoFar() if ag == 'BestMarkowitz': algo = algos.BestMarkowitz() result = algo.run(self.data) return result
(test / test.iloc[0, :]).plot() # # Comparing the Algorithms # We want to train on market data from a number of years, and test out of sample for a duration smaller than the train set. To get started we accept the default parameters for the respective algorithms and we essentially are just looking at two independent time periods. In the future we will want to optimize the paramaters on the train set. # In[ ]: #list all the algos olps_algos = [ algos.Anticor(), algos.BAH(), algos.BCRP(), algos.BNN(), algos.CORN(), algos.CRP( b=swensen_allocation), # Non Uniform CRP (the Swensen allocation) algos.CWMR(), algos.EG(), algos.Kelly(), algos.OLMAR(), algos.ONS(), algos.PAMR(), algos.RMR(), algos.UP() ] # In[ ]: # put all the algos in a dataframe algo_names = [a.__class__.__name__ for a in olps_algos] algo_data = [