OpenSourceRisk / Engine

Open Source Risk Engine
http://www.opensourcerisk.org
Other
476 stars 206 forks source link

Error running new example 43 #142

Open Othmane-Ch opened 1 year ago

Othmane-Ch commented 1 year ago

I have seen that a new example 43 on bonds has been added . I have this error while running it. Anybody has the same error ?

image

noonediesalone commented 1 year ago

If we've built the latest from master, then you shouldn't have this error per https://github.com/OpenSourceRisk/Engine/blob/master/OREData/ored/utilities/parsers.cpp image

Othmane-Ch commented 1 year ago

May I ask how did you build your project ? cause I have errors when building the latest version from master

"\Desktop\Engine-master\build\ALL_BUILD.vcxproj" (default target) (1) -> "\Desktop\Engine-master\build\OREAnalytics\orea\OREAnalytics-x64-mt.vcxproj" (default target) (21) -> "\Desktop\Engine-master\build\OREData\ored\OREData-x64-mt.vcxproj" (default target) (22) -> "\Desktop\Engine-master\build\QuantExt\qle\QuantExt-x64-mt.vcxproj" (default target) (23) -> (ClCompile target) -> \Desktop\Engine-master\QuantExt\qle\pricingengines\midpointcdsenginemultistate.cpp(52,5): error C2678: binary '=': no operator found which takes a left-hand operand of type 'const QuantLib::Handle' (or there is no acceptable conversion) [\Desktop\Engi ne-master\build\QuantExt\qle\QuantExt-x64-mt.vcxproj] \Desktop\Engine-master\QuantExt\qle\pricingengines\midpointcdsenginemultistate.cpp(53,5): error C3892: 'this': you cannot assign to a variable tha t is const [\Desktop\Engine-master\build\QuantExt\qle\QuantExt-x64-mt.vcxproj]

noonediesalone commented 1 year ago

It's a QL error, so try updating the submodule: git submodule foreach git pull origin master

Othmane-Ch commented 1 year ago

Works perfectly. Thank you

Othmane-Ch commented 1 year ago

While I can run the example 43, it doesn't seem to load the trades. I am using the recent version from master.This is my output :

D:\Desktop\Engine-master\Examples\Example_43>python run.py

1) Run ORE for a single Bond
Loading inputs                                    OK
Requested analytics                               CASHFLOW,EXPOSURE,NPV,XVA
Pricing: Build Market                             OK
Pricing: Build Portfolio
Error: Error in ORE analytics: Portfolio does not contain any built trades, context is 'analytic/PRICING'
Saving plot....Output\mpl_cdf_bond1.pdf
Saving plot....Output\mpl_pdf_bond1.pdf

2) Run ORE for Bond and Swap
Loading inputs                                    OK
Requested analytics                               CASHFLOW,EXPOSURE,NPV,XVA
Pricing: Build Market                             OK
Pricing: Build Portfolio                          OK
Pricing: Cashflow Report                          OK
Pricing: NPV Report                               OK
Pricing: Curves Report                            OK
XVA: Build Market                                 OK

Error: Error in ORE analytics: did not find object 'BOND_AAA' of type default curve under configuration 'collateral_eur' or 'default'
Saving plot....Output\mpl_cdf_bond_swap.pdf
Saving plot....Output\mpl_pdf_bond_swap.pdf

3) Run ORE for 3 Bonds
Loading inputs                                    OK
Requested analytics                               CASHFLOW,EXPOSURE,NPV,XVA
Pricing: Build Market                             OK
Pricing: Build Portfolio
Error: Error in ORE analytics: Portfolio does not contain any built trades, context is 'analytic/PRICING'
Saving plot....Output\mpl_cdf_bond3.pdf
Saving plot....Output\mpl_pdf_bond3.pdf

4) Run ORE for 10 bonds
Loading inputs                                    OK
Requested analytics                               CASHFLOW,EXPOSURE,NPV,XVA
Pricing: Build Market                             OK
Pricing: Build Portfolio
Error: Error in ORE analytics: Portfolio does not contain any built trades, context is 'analytic/PRICING'
Saving plot....Output\mpl_cdf_bond10.pdf
Saving plot....Output\mpl_pdf_bond10.pdf

5) Run ORE for Bond and CDS
Loading inputs                                    OK
Requested analytics                               CASHFLOW,EXPOSURE,NPV,XVA
Pricing: Build Market                             OK
Pricing: Build Portfolio
Error: Error in ORE analytics: Portfolio does not contain any built trades, context is 'analytic/PRICING'
Saving plot....Output\mpl_cdf_bond_cds.pdf
Saving plot....Output\mpl_pdf_bond_cds.pdf
Othmane-Ch commented 1 year ago

Shoutout to my boi oussama from Lydex :)

quantthingy commented 7 months ago

Still got this error (build it from master on 22 Nov 2023) 1) Run ORE for a single Bond Loading inputs OK Requested analytics CASHFLOW,EXPOSURE,NPV,XVA Pricing: Build Market OK Pricing: Build Portfolio
Error: Error in ORE analytics: Portfolio does not contain any built trades, context is 'analytic/PRICING' Traceback (most recent call last): File "/Volumes/Crucial X6/Documents SSD/ore/Examples/Example_43/run.py", line 15, in oreex.plot(targetFileName, 0, 2, 'b', label="Loss") File "/Volumes/Crucial X6/Documents SSD/ore/Examples/Example_43/../ore_examples_helper.py", line 115, in plot self.ax.plot(self.get_output_data_from_column(filename, colIdxTime, offset), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Volumes/Crucial X6/Documents SSD/ore/Examples/Example_43/../ore_examples_helper.py", line 99, in get_output_data_from_column f = open(os.path.join(os.path.join(os.getcwd(), "Output"), csv_name)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/Volumes/Crucial X6/Documents SSD/ore/Examples/Example_43/Output/credit_migration_bond1_11.csv'

rkapl123 commented 5 months ago

Well, this is due to default curve building requiring the additional Eigen3 library, the log says: ALERT [2024-Jan-28 12:19:18.654435] (...ta\ored\marketdata\todaysmarket.cpp:920) : error while building node DefaultCurve(BOND_AAA,Default/EUR/BOND_AAA) in configuration collateral_eur: default curve building failed for BOND_AAA: build attempt failed for BOND_AAA using config with priority 0: Logm(): no implementation provided, you can e.g. install Eigen and rebuild ORE to enable this function. There are instructions to install this in the userguide, it works quite well (you have to remove the build cache however), simply install vcpkg https://vcpkg.io/en/getting-started.html, then install Eigen3 with vcpkg install -–triplet x64-windows eigen3 and finally configure ORE cmake / build ORE using

set VCPKG_ROOT=C:/dev/vcpkg
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -DBOOST_INCLUDEDIR=%BOOST% -DBOOST_LIBRARYDIR=%BOOST_LIB64% -DQL_ENABLE_SESSIONS=ON -B build
cmake --build build -v --config Release
rkapl123 commented 5 months ago

In general, I would suggest to include Eigen3 and zlib in the prebuilt binary, once this is possible again (see #190 ), otherwise the examples do not run completely. In the meantime I've built a windows binary with the latest version of ORE and made it available here. Simply klick on download raw file: image

quantthingy commented 1 day ago

What about mentioning explicitly the dependency on Eigen3 for all build environment in the doc? (not just windows)

rkapl123 commented 1 day ago

Actually this is already mentioned in creditmodel.tex (separate doc). I have also included it in the userguide in #242 , line 3140 of userguide.tex.