# -*- coding: utf-8 -*- import cmake_example as m assert m.__version__ == "0.0.1" assert m.add(1, 2) == 3 assert m.subtract(1, 2) == -1
import subprocess subprocess.check_call(['pip', 'install', './cmake_example'], shell=True) import cmake_example as m a = m.add(3.0, 1.3232) print("the sum of two double is " + str(a)) b = m.square(4) print("the square of one double is " + str(b)) maturity = 0.5 BS = m.BS(maturity) print("the option price calculated by BS formula is " + str(BS)) initEquityPrice = 10 numTimeSteps = 6 timetoExpiry = 6 drift = 0.1 volatility = 0.1 EPG = m.EquityPriceGenerator(initEquityPrice, numTimeSteps, timetoExpiry, drift, volatility) print("EquityPriceGenerator initiated") print(EPG) price1 = EPG.operator(1) print("the sequence of prices calculated by Monte Carlo formula is " + str(price1)) strikePrice = 42 exercisePrice = 40 interestRate = 0.1
def test_add(self): self.assertAlmostEqual(m.add_pi(1, 2), 3 + 3.1415926, 0.00001) self.assertEqual(m.add(1, 2), 3)
def test_main(): assert m.__version__ == "0.0.1" assert m.add(1, 2) == 3 assert m.subtract(1, 2) == -1
import cmake_example as m assert m.add(1, 2) == (1 + 2) assert m.subtract(1, 2) == (1 - 2) assert m.multiply(7, 5) == (7 * 5) assert m.divide(1, 2) == (1 / 2) assert m.factorial(3) == 6