예제 #1
0
 def testPortfolioOptimizerWithMinimumVolatility(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(
         guess, self.navData, OptTarget.VOL)
     matlab_res = self.create_value_dict(self.instruments, [
         0, 0, 0, 6.99175721467524e-39, 1.87467007228981e-38,
         0.00376413514611989, 0, 7.75214182640125e-38, 0.000712597692602067,
         0, 0, 0.994237264821637, 0.00128600233964123, 7.05296610493373e-38
     ])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #2
0
 def testPortfolioOptimizerWithMinimumVolatilityWithRebalance(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(
         guess, self.navData, OptTarget.VOL, True)
     matlab_res = self.create_value_dict(self.instruments, [
         1.17549435082229e-38, 0, 0, 1.68242628961440e-37, 0,
         0.00209693665998001, 0, 1.53548949576161e-37, 0.00135190283349081,
         0, 6.31828213566980e-38, 0.994988759101536, 0.00156240140499358, 0
     ])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #3
0
 def testPortfolioOptimizerWithMaximumReturn(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(
         guess, self.navData, OptTarget.RETURN)
     matlab_res = self.create_value_dict(self.instruments, [
         4.75393550839560e-19, 0, 3.43546906184303e-19, 0, 0,
         8.36677837797548e-20, 0, 5.76673494924112e-19,
         4.05923081267658e-19, 0, 3.12250225675825e-17,
         2.41998887084620e-20, 0, 1
     ])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #4
0
 def testPortfolioOptimizerWithMaximumSharpWithRebalance(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(
         guess, self.navData, OptTarget.SHARP, True)
     matlab_res = self.create_value_dict(self.instruments, [
         2.76471048953164e-22, 7.19170303955622e-21, 2.52983701805491e-21,
         1.94636169061746e-22, 0, 0, 0, 0.000165267959303058,
         0.00137258304784842, 0, 2.06247008802505e-22, 0.995739327032537,
         0.00134638898667400, 0.00137643297363735
     ])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #5
0
 def testPortfolioOptimizerWithMaximumSharp(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(
         guess, self.navData, OptTarget.SHARP)
     matlab_res = self.create_value_dict(self.instruments, [
         3.72414607721023e-39, 5.58329252509498e-40, 8.50903300813402e-40,
         9.42738796971393e-40, 4.83561316181437e-40, 0.00102720032914267,
         4.40810381558358e-39, 0.000145735792353755, 0.000756493258973369,
         3.91725820023446e-40, 0, 0.996553125979859, 0.00117153574239032,
         0.000345908897280735
     ])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #6
0
 def testPortfolioOptimizerWithMaximumReturnWithRebalance(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(
         guess, self.navData, OptTarget.RETURN, True)
     matlab_res = self.create_value_dict(self.instruments, [
         1.59234884538490e-17, 1.64287856671892e-18, 2.31111593326468e-33,
         5.02151358940695e-17, 0, 9.41672950270667e-18,
         1.64287856671892e-18, 2.82144347121750e-17, 0,
         2.24595602784406e-17, 2.44504165203472e-16, -1.68518870133883e-34,
         0, 1.00000000000000
     ])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #7
0
 def testPortfolioOptimizerWithMinimumVolatility(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(guess, self.navData, OptTarget.VOL)
     matlab_res = self.create_value_dict(self.instruments, [0,
                                                            0,
                                                            0,
                                                            6.99175721467524e-39,
                                                            1.87467007228981e-38,
                                                            0.00376413514611989,
                                                            0,
                                                            7.75214182640125e-38,
                                                            0.000712597692602067,
                                                            0,
                                                            0,
                                                            0.994237264821637,
                                                            0.00128600233964123,
                                                            7.05296610493373e-38])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #8
0
 def testPortfolioOptimizerWithMaximumReturn(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(guess, self.navData, OptTarget.RETURN)
     matlab_res = self.create_value_dict(self.instruments, [4.75393550839560e-19,
                                                            0,
                                                            3.43546906184303e-19,
                                                            0,
                                                            0,
                                                            8.36677837797548e-20,
                                                            0,
                                                            5.76673494924112e-19,
                                                            4.05923081267658e-19,
                                                            0,
                                                            3.12250225675825e-17,
                                                            2.41998887084620e-20,
                                                            0,
                                                            1])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #9
0
 def testPortfolioOptimizerWithMaximumSharpWithRebalance(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(guess, self.navData, OptTarget.SHARP, True)
     matlab_res = self.create_value_dict(self.instruments, [2.76471048953164e-22,
                                                            7.19170303955622e-21,
                                                            2.52983701805491e-21,
                                                            1.94636169061746e-22,
                                                            0,
                                                            0,
                                                            0,
                                                            0.000165267959303058,
                                                            0.00137258304784842,
                                                            0,
                                                            2.06247008802505e-22,
                                                            0.995739327032537,
                                                            0.00134638898667400,
                                                            0.00137643297363735])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #10
0
 def testPortfolioOptimizerWithMinimumVolatilityWithRebalance(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(guess, self.navData, OptTarget.VOL, True)
     matlab_res = self.create_value_dict(self.instruments, [1.17549435082229e-38,
                                                            0,
                                                            0,
                                                            1.68242628961440e-37,
                                                            0,
                                                            0.00209693665998001,
                                                            0,
                                                            1.53548949576161e-37,
                                                            0.00135190283349081,
                                                            0,
                                                            6.31828213566980e-38,
                                                            0.994988759101536,
                                                            0.00156240140499358,
                                                            0])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #11
0
 def testPortfolioOptimizerWithMaximumReturnWithRebalance(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(guess, self.navData, OptTarget.RETURN, True)
     matlab_res = self.create_value_dict(self.instruments, [1.59234884538490e-17,
                                                            1.64287856671892e-18,
                                                            2.31111593326468e-33,
                                                            5.02151358940695e-17,
                                                            0,
                                                            9.41672950270667e-18,
                                                            1.64287856671892e-18,
                                                            2.82144347121750e-17,
                                                            0,
                                                            2.24595602784406e-17,
                                                            2.44504165203472e-16,
                                                            -1.68518870133883e-34,
                                                            0,
                                                            1.00000000000000])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)
예제 #12
0
 def testPortfolioOptimizerWithMaximumSharp(self):
     guess = [0.1 / len(self.instruments)] * len(self.instruments)
     out, fx, its, imode, smode = portfolio_optimization(guess, self.navData, OptTarget.SHARP)
     matlab_res = self.create_value_dict(self.instruments, [3.72414607721023e-39,
                                                            5.58329252509498e-40,
                                                            8.50903300813402e-40,
                                                            9.42738796971393e-40,
                                                            4.83561316181437e-40,
                                                            0.00102720032914267,
                                                            4.40810381558358e-39,
                                                            0.000145735792353755,
                                                            0.000756493258973369,
                                                            3.91725820023446e-40,
                                                            0,
                                                            0.996553125979859,
                                                            0.00117153574239032,
                                                            0.000345908897280735])
     for name in matlab_res:
         self.assertAlmostEqual(matlab_res[name], out[name]['weight'], 4)