Пример #1
0
    def test_smoother(self):

        np.random.seed(1234)
        sim = cfp.simulate(self.market_params, size=1000)
        md = cfp.model(self.market_params)
        sm = md.smoother(sim)

        self.assertEqual(len(sm), 1000)
        self.assertAlmostEqual(sm[0], 15.927989016176651)
        self.assertAlmostEqual(sm[-1], 14.188584761204664)
Пример #2
0
    def test_filter(self):

        np.random.seed(1234)
        sim = cfp.simulate(self.market_params, size=1000)
        md = cfp.model(self.market_params)
        kf = md.filter(sim)

        self.assertEqual(len(kf), 1000)
        self.assertAlmostEqual(kf[0], 15.9319643025965)
        self.assertAlmostEqual(kf[-1], 14.146247907494123)
Пример #3
0
    def test_predict(self):

        np.random.seed(1234)
        sim = cfp.simulate(self.market_params, size=1000)
        md = cfp.model(self.market_params)
        pred = md.predict(data=sim, horizon=10)

        self.assertEqual(len(pred), 1000)
        self.assertAlmostEqual(pred[0], 14.309777001178249)
        self.assertAlmostEqual(pred[-11], 14.292866700911807)
        self.assertTrue(np.isnan(pred[-10]))
Пример #4
0
    def test_emax_debug(self):

        np.random.seed(1234)
        md = cfp.model(self.market_params)
        sim = cfp.simulate(self.market_params, size=100)
        df = md.emax_debug(sim, 10, 1e-10)

        self.assertEqual(len(df), 36)
        self.assertEqual(len(df['a.eta']), 10)
        self.assertAlmostEqual(df['a.eta'][0], 0.9717456011583988)
        self.assertAlmostEqual(df['a.eta'][9], 1.017014876796524)
        self.assertAlmostEqual(df['s.eta'][0], 0.003830140840219957)
        self.assertAlmostEqual(df['psi.25'][0], 16.114983829824222)
        self.assertAlmostEqual(df['psi.25'][9], 16.289168581902302)
Пример #5
0
    def test_emax(self):

        np.random.seed(1234)
        sim = cfp.simulate(self.market_params, size=1000)
        md = cfp.model(self.market_params)
        res = md.emax(sim, 100, 1e-8)

        self.assertAlmostEqual(len(res.psi), 26)
        self.assertAlmostEqual(res.a_eta, 0.8780664351205582)
        self.assertAlmostEqual(res.a_mu, 0.5843683622567167)
        self.assertAlmostEqual(res.s_eta, 0.0016218036289216205)
        self.assertAlmostEqual(res.s_mu, 0.10553455705671508)
        self.assertAlmostEqual(res.pi,
                               [-0.11646425697054973, 0.5083643647969468])
        self.assertAlmostEqual(res.sigma,
                               [5.844641110702882e-05, 0.0013662016517574371])
        self.assertAlmostEqual(res.psi[0], 15.289625725386964)
        self.assertAlmostEqual(res.psi[25], 15.862185130118702)