Esempio n. 1
0
 def runTests(self):
     for module_name in self.testNames:
         path = find_module_path(module_name)
         with open(path) as f:
             source_code = f.read()
         calc_print(source_code,
                    observation_date='2011-1-1',
                    verbose=True,
                    )
     print("Evaluating module")
Esempio n. 2
0
 def runTests(self):
     for module_name in self.testNames:
         path = find_module_path(module_name)
         with open(path) as f:
             source_code = f.read()
         calc_print(
             source_code,
             observation_date='2011-1-1',
             verbose=True,
         )
     print("Evaluating module")
Esempio n. 3
0
    def test_periodisation_none(self):
        source_code = """from quantdsl.lib.storage2 import GasStorage
        
GasStorage(Date('2011-6-1'), Date('2011-12-1'), 'GAS', 0, 0, 50000, TimeDelta('1m'), 1)
"""

        results = calc_print(
            source_code=source_code,
            observation_date='2011-1-1',
            interest_rate=2.5,
            price_process={
                'name':
                'quantdsl.priceprocess.blackscholes.BlackScholesPriceProcess',
                'market': ['GAS'],
                'sigma': [0.5],
                'curve': {
                    'GAS':
                    (('2011-1-1', 13.5), ('2011-2-1', 11.0),
                     ('2011-3-1', 10.0), ('2011-4-1', 9.0), ('2011-5-1', 7.5),
                     ('2011-6-1', 7.0), ('2011-7-1', 6.5), ('2011-8-1', 7.5),
                     ('2011-9-1', 8.5), ('2011-10-1', 10.0),
                     ('2011-11-1', 11.5), ('2011-12-1', 12.0), ('2012-1-1',
                                                                13.5),
                     ('2012-2-1', 11.0), ('2012-3-1', 10.0), ('2012-4-1', 9.0),
                     ('2012-5-1', 7.5), ('2012-6-1', 7.0), ('2012-7-1', 6.5),
                     ('2012-8-1', 7.5), ('2012-9-1', 8.5), ('2012-10-1', 10.0),
                     ('2012-11-1', 11.5), ('2012-12-1', 12.0))
                }
            },
        )

        self.assertAlmostEqual(results.fair_value.mean(), 8.6359, places=0)
        self.assertEqual(len(results.periods), 0)
Esempio n. 4
0
    def test_dependency_graph_size_limit(self):
        source_code = """
from quantdsl.lib.storage2 import GasStorage        
GasStorage(Date('2011-1-1'), Date('2011-4-1'), 'GAS', 0, 0, 50000, TimeDelta('1m'), 1)
"""

        with self.assertRaises(CallLimitError):
            calc_print(
                source_code=source_code,
                observation_date='2011-1-1',
                interest_rate=2.5,
                price_process={
                    'name':
                    'quantdsl.priceprocess.blackscholes.BlackScholesPriceProcess',
                    'market': ['GAS'],
                    'sigma': [0.5],
                    'curve': {
                        'GAS': (('2011-1-1', 13.5), )
                    }
                },
                max_dependency_graph_size=1,
            )
Esempio n. 5
0
    def test_timeout(self):
        source_code = """
from quantdsl.lib.storage2 import GasStorage        
GasStorage(Date('2011-1-1'), Date('2011-12-1'), 'GAS', 0, 0, 50000, TimeDelta('1m'), 1)
"""

        with self.assertRaises(SystemExit):
            calc_print(
                source_code=source_code,
                observation_date='2011-1-1',
                interest_rate=2.5,
                price_process={
                    'name':
                    'quantdsl.priceprocess.blackscholes.BlackScholesPriceProcess',
                    'market': ['GAS'],
                    'sigma': [0.5],
                    'curve': {
                        'GAS': (('2011-1-1', 13.5), )
                    }
                },
                periodisation='monthly',
                timeout=.5,
            )