我试图让Python中的Quantlib运行。我让它运行,但不得不进行新的干净安装,现在我正在努力让它再次运行。我认为主要问题似乎是在包装器中。
我的操作系统是Windows 10,我正在使用python 3.6.3 | Anaconda自定义(64位)和Visual Studio社区2015.Quantlib通常在VS15中编译(64位)并且还在运行。我只对Quantlib进行了编译解决方案不是完整的包。
我的QL输出是:
QuantLib-vc140-x64-mt
然后我按以下定义设置所有env变量:
INCLUDE=C:\QuantAna\boost_1_65_0
LIB=C:\QuantAna\boost_1_65_0\lib64-msvc-14.0
Path=C:\Users\mcm\Anaconda3;C:\Users\mcm\Anaconda3\Library\mingw-w64\bin;C:\Users\mcm\Anaconda3\Library\usr\bin;C:\Users\mcm\Anaconda3\Library\bin;C:\Users\mcm\Anaconda3\Scripts;C:\Users\mcm\Anaconda3\bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\mcm\Anaconda3;C:\Users\mcm\Anaconda3\Library\mingw-w64\bin;C:\Users\mcm\Anaconda3\Library\usr\bin;C:\Users\mcm\Anaconda3\Library\bin;C:\Users\mcm\Anaconda3\Scripts;C:\Users\mcm\AppData\Local\Microsoft\WindowsApps;C:\QuantAna\swigwin-3.0.12;
QL_DIR=C:\QuantAna\QuantLib-1.11
我正在使用Anaconda提示在python中运行QL,如下所示:
python setup.py wrap:
running wrap
Generating Python bindings for QuantLib...
SWIG(1) : Warning 125: Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file.
python setup.py build:
running build
running build_py
copying QuantLib\QuantLib.py -> build\lib.win-amd64-3.6\QuantLib
running build_ext
building 'QuantLib._QuantLib' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -D__WIN32__ -DWIN32 -DNDEBUG -D_WINDOWS -DNOMINMAX -IC:\Users\mcm\Anaconda3\include -IC:\Users\mcm\Anaconda3\include -IC:\QuantAna\QuantLib-1.11 "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" -IC:\QuantAna\boost_1_65_0 "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" -IC:\QuantAna\boost_1_65_0 /EHsc /TpQuantLib/quantlib_wrap.cpp /Fobuild\temp.win-amd64-3.6\Release\QuantLib/quantlib_wrap.obj /GR /FD /Zm250 /EHsc /bigobj /MD
quantlib_wrap.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\mcm\Anaconda3\libs /LIBPATH:C:\Users\mcm\Anaconda3\PCbuild\amd64 /LIBPATH:C:\QuantAna\QuantLib-1.11\lib "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" /LIBPATH:C:\QuantAna\boost_1_65_0\lib64-msvc-14.0 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" /LIBPATH:C:\QuantAna\boost_1_65_0\lib64-msvc-14.0 /EXPORT:PyInit__QuantLib build\temp.win-amd64-3.6\Release\QuantLib/quantlib_wrap.obj /OUT:build\lib.win-amd64-3.6\QuantLib\_QuantLib.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\QuantLib\_QuantLib.cp36-win_amd64.lib /subsystem:windows /machine:x64
quantlib_wrap.obj : warning LNK4197: export 'PyInit__QuantLib' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.6\Release\QuantLib\_QuantLib.cp36-win_amd64.lib and object build\temp.win-amd64-3.6\Release\QuantLib\_QuantLib.cp36-win_amd64.exp
Generating code
Finished generating code
python setup.py install:
running install
running build
running build_py
running build_ext
running install_lib
copying build\lib.win-amd64-3.6\QuantLib\QuantLib.py -> C:\Users\mcm\Anaconda3\Lib\site-packages\QuantLib
copying build\lib.win-amd64-3.6\QuantLib\_QuantLib.cp36-win_amd64.pyd -> C:\Users\mcm\Anaconda3\Lib\site-packages\QuantLib
copying build\lib.win-amd64-3.6\QuantLib\__pycache__\QuantLib.cpython-36.pyc -> C:\Users\mcm\Anaconda3\Lib\site-packages\QuantLib\__pycache__
byte-compiling C:\Users\mcm\Anaconda3\Lib\site-packages\QuantLib\QuantLib.py to QuantLib.cpython-36.pyc
running install_egg_info
Removing C:\Users\mcm\Anaconda3\Lib\site-packages\QuantLib_Python-1.11-py3.6.egg-info
Writing C:\Users\mcm\Anaconda3\Lib\site-packages\QuantLib_Python-1.11-py3.6.egg-info
python setup.py test:
运行测试时,我收到以下错误消息:
running test
running build
running build_py
running build_ext
testing QuantLib 1.11
runTest (date.DateTest)
Testing date arithmetics ... ok
runTest (daycounters.DayCountersTest)
Testing daycounters ... ok
testObservable (instruments.InstrumentTest)
Testing observability of stocks ... ok
testObservable (marketelements.MarketElementTest)
Testing observability of market elements ... ok
testObservableHandle (marketelements.MarketElementTest)
Testing observability of market element handles ... ok
testKronrod (integrals.IntegralTest)
Testing Gauss-Kronrod integration ... ok
testSegment (integrals.IntegralTest)
Testing segment integration ... ok
testSimpson (integrals.IntegralTest)
Testing Simpson integration ... ok
testTrapezoid (integrals.IntegralTest)
Testing trapezoid integration ... ok
runTest (solvers1d.Solver1DTest)
Testing 1-D solvers ... ok
testFSpreadedObs (termstructures.TermStructureTest)
Testing observability of forward-spreaded term structure ... ok
testImpliedObs (termstructures.TermStructureTest)
Testing observability of implied term structure ... ok
testZSpreadedObs (termstructures.TermStructureTest)
Testing observability of zero-spreaded term structure ... ok
testCashFlows (bonds.FixedRateBondTest)
Testing that the FixedRateBond gives the expected cash flows. ... ok
testCleanPrice (bonds.FixedRateBondTest)
Testing FixedRateBond clean price. ... ok
testCleanPriceFromZSpread (bonds.FixedRateBondTest)
Testing FixedRateBond clean price derived from Z-spread. ... ok
testDayCounter (bonds.FixedRateBondTest)
Testing FixedRateBond dayCounter() method. ... ok
testDirtyPrice (bonds.FixedRateBondTest)
Testing FixedRateBond dirty price. ... ok
testFrequency (bonds.FixedRateBondTest)
Testing FixedRateBond frequency() method. ... ok
testNextCoupon (bonds.FixedRateBondTest)
Testing FixedRateBond correct next coupon amount. ... FAIL
testNotional (bonds.FixedRateBondTest)
Testing FixedRateBond notional values. ... FAIL
testPrevCoupon (bonds.FixedRateBondTest)
Testing FixedRateBond correct previous coupon amount. ... ok
testRedemption (bonds.FixedRateBondTest)
Testing FixedRateBond redemption value and date. ... ok
testRedemptions (bonds.FixedRateBondTest)
Testing FixedRateBond redemptions. ... ok
testSimpleInspectors (bonds.FixedRateBondTest)
Testing FixedRateBond simple inspectors. ... FAIL
testBond (ratehelpers.FixedRateBondHelperTest)
Testing FixedRateBondHelper bond() method. ... FAIL
testFairRate (cms.CmsTest)
Testing Hagan-pricer flat-vol equivalence for coupons... ... ok
testParity (cms.CmsTest)
Testing put-call parity for capped-floored CMS coupons... ... ok
testConsistency (assetswap.AssetSwapTest)
Testing consistency between fair price and fair spread... ... ok
testGenericBondImplied (assetswap.AssetSwapTest)
Testing implied generic-bond value against asset-swap fair price with null spread... ... ok
testImpliedValue (assetswap.AssetSwapTest)
Testing implied bond value against asset-swap fair price with null spread... ... ok
testMASWWithGenericBond (assetswap.AssetSwapTest)
Testing market asset swap against par asset swap with generic bond... ... ok
testMarketASWSpread (assetswap.AssetSwapTest)
Testing relationship between market asset swap and par asset swap... ... ok
testSpecializedBondVsGenericBond (assetswap.AssetSwapTest)
Testing clean and dirty prices for specialized bond against equivalent generic bond... ... ok
testSpecializedBondVsGenericBondUsingAsw (assetswap.AssetSwapTest)
Testing asset-swap prices and spreads for specialized bond against equivalent generic bond... ... ok
testZSpread (assetswap.AssetSwapTest)
Testing clean and dirty price with null Z-spread against theoretical prices... ... ok
testZSpreadWithGenericBond (assetswap.AssetSwapTest)
Testing clean and dirty price with null Z-spread against theoretical prices... ... ok
testBachelierCapFloorEngine (capfloor.CapFloorTest)
Testing BachelierCapFloorEngine ... ok
testBlackCapFloorEngine (capfloor.CapFloorTest)
Testing BlackCapFloorEngine ... ok
test_blackFormula (blackformula.BlackFormulaTest)
Testing blackFormula in a simple Black-Scholes World... ... ok
test_black_formula_implied_stdev (blackformula.BlackFormulaTest)
Testing implied volatility calculator ... ok
test_single_spot_delta (blackformula.BlackDeltaCalculatorTest)
Test for a single strike for call spot delta 75 ... ok
test_spot_atm_delta_calculator (blackformula.BlackDeltaCalculatorTest)
Test for 0-delta straddle strike ... ok
======================================================================
FAIL: testNextCoupon (bonds.FixedRateBondTest)
Testing FixedRateBond correct next coupon amount.
----------------------------------------------------------------------
Traceback (most recent call last):
File "test\bonds.py", line 95, in testNextCoupon
self.assertEqual(self.bond.nextCouponRate(self.issue_date), 0.05)
AssertionError: 0.0 != 0.05
======================================================================
FAIL: testNotional (bonds.FixedRateBondTest)
Testing FixedRateBond notional values.
----------------------------------------------------------------------
Traceback (most recent call last):
File "test\bonds.py", line 90, in testNotional
self.assertEqual(self.bond.notional(), 100.0)
AssertionError: 0.0 != 100.0
======================================================================
FAIL: testSimpleInspectors (bonds.FixedRateBondTest)
Testing FixedRateBond simple inspectors.
----------------------------------------------------------------------
Traceback (most recent call last):
File "test\bonds.py", line 59, in testSimpleInspectors
self.assertEqual(self.bond.notional(), self.face_amount)
AssertionError: 0.0 != 100.0
======================================================================
FAIL: testBond (ratehelpers.FixedRateBondHelperTest)
Testing FixedRateBondHelper bond() method.`enter code here`
----------------------------------------------------------------------
Traceback (most recent call last):
File "test\ratehelpers.py", line 46, in testBond
self.assertEqual(bond.nextCouponRate(), self.coupons[0])
AssertionError: 0.0 != 0.05
----------------------------------------------------------------------
Ran 43 tests in 1.565s
FAILED (failures=4)
我不确定问题出在哪里。我尝试了很多东西,如32位或VS版本等,结果相同。此外,当在swig文件中处理某些内容(以前工作的东西)时,构建失败。因此,我认为它必须是包装中的东西。
答案 0 :(得分:2)
您的安装没有任何问题。最近出现的测试中存在一个问题(见https://github.com/lballabio/QuantLib-SWIG/issues/89)。问题已修复(https://github.com/lballabio/QuantLib-SWIG/pull/90),但修复程序仍然没有发布,因此您会看到错误。
您可以继续安装您构建的模块。