Hi all,
I am working on a project of visualizing quantlib, like tree, term structure. However I cannot initialize some of class e.g EqualJumpsBinomialTree. it seems not wrapped in C#. I need a way to access lattice. Any suggestion? Thanks for your time archlight Regards |
Because of the way Quantlib is written, not every class or method signature is exposed via SWiG. You will probably have to extend the SWiG files, which isn't too hard once you get the hang of it.
|
Hi
I tried Python swig. I can build and install it and run sample code (swap.i) without problem. However after I modified volalilities.i to add class SwaptionVolCube2, I got error below (I can build and install) -------------things I change in volalilities.i --------------------------------------------------------- %include indexes.i ( I add this header otherwise it won't compile) %{ using QuantLib::SwaptionVolCube2; typedef boost::shared_ptr<SwaptionVolatilityStructure> SwaptionVolCube2Ptr; %} %rename(SwaptionVolCube2) SwaptionVolCube2Ptr; class SwaptionVolCube2Ptr : public boost::shared_ptr<SwaptionVolatilityStructure> { public: %extend { SwaptionVolCube2Ptr(const Handle<SwaptionVolatilityStructure>& atmVolStructure, const std::vector<Period>& optionTenors, const std::vector<Period>& swapTenors, const std::vector<Spread>& strikeSpreads, const std::vector<std::vector<Handle<Quote> > >& volSpreads, const boost::shared_ptr<SwapIndex>& swapIndexBase, const boost::shared_ptr<SwapIndex>& shortSwapIndexBase, bool vegaWeightedSmileFit) { return new SwaptionVolCube2Ptr( new SwaptionVolCube2(atmVolStructure,optionTenors,swapTenors, strikeSpreads,volSpreads, swapIndexBase, shortSwapIndexBase, vegaWeightedSmileFit)); } } }; --------------------------------------------------------------------------------------------------- Traceback (most recent call last): File "swap.py", line 215, in <module> report(spot,'depo-fut-swap') File "swap.py", line 200, in report formatRate(swap.fairSpread(),4), File "C:\Python27\lib\site-packages\QuantLib\QuantLib.py", line 10406, in fair Spread def fairSpread(self): return _QuantLib.VanillaSwap_fairSpread(self) RuntimeError: result not available I have no idea how to proceed. your help is much appreciated. Regards
|
On Wed, 2011-03-02 at 20:15 -0800, archlight wrote:
> However after I modified volalilities.i to add class SwaptionVolCube2, I > got error below (I can build and install) [...] > def fairSpread(self): return _QuantLib.VanillaSwap_fairSpread(self) > RuntimeError: result not available > I have no idea how to proceed. your help is much appreciated. The build seems to have worked. For some reason, the swap can't calculate the result. Any chance you can show us the Python code that leads to the error? Luigi -- Call on God, but row away from the rocks. -- Indian proverb ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
It is the swap.py from examples folder. I am using swig2.0.1 executable.
by the way, how do I represent std::vector<std::vector<Handle > > in python. I am using numpy matrix but it says parameter type not matched I found something in vector.i but there is no nested vector example. Regards
|
On Thu, 2011-03-03 at 00:20 -0800, archlight wrote:
> It is the swap.py from examples folder. I am using swig2.0.1 executable. Does it work if you don't modify volatilities.i and compile the original files instead? > by the way, how do I represent std::vector<std::vector<Handle > > in python. > I am using numpy matrix but it says parameter type not matched > > I found something in vector.i but there is no nested vector example. You must declare to swig that you'll use it--something like %template() std::vector<std::vector<Handle<Quote> > >; if I'm not mistaken. After this, you should be able to pass a list of lists of handles where std::vector<std::vector<Handle > > is required. Luigi -- Glendower: I can call spirits from the vasty deep. Hotspur: Why, so can I, or so can any man; But will they come when you do call for them? -- King Henry the Fourth Part I, Act III, Scene I ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luigi,
Thanks for your reply. it is working with quantlib_wrapper in the download package. if I use swig to generate myself, it has such problem even though I don't touch any interface files. is it swig version issue? I will give a try on template directive when i get back home and give feed back here Regards On Thu, Mar 3, 2011 at 5:41 PM, Luigi Ballabio <[hidden email]> wrote: On Thu, 2011-03-03 at 00:20 -0800, archlight wrote: ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Thu, 2011-03-03 at 18:08 +0800, ren wei wrote:
> Hi Luigi, > > Thanks for your reply. it is working with quantlib_wrapper in the > download package. if I use swig to generate myself, it has such > problem even though I don't touch any interface files. > > is it swig version issue? Possibly. What SWIG version and QuantLib version are you using? Luigi -- Prediction is very difficult, especially if it's about the future. -- Niels Bohr ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I am using swig 2.0.1 and quantlib compiled by VC 2008 as required by python 2.7
What version do you use to generate quantlib_wrapper? maybe I should back date to that version Regards
On Thu, Mar 3, 2011 at 9:39 PM, Luigi Ballabio <[hidden email]> wrote:
------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi
I have been stuck on this for quite some time. I managed to get it compiled. but I get error RuntimeError: Boost assertion failed: px != 0 basically i took two approaches.
1) pass boost::shared_ptr<Index> in SwaptionVolCube2 constructor and dynamically cast to boost::shared_ptr<SwapIndex>. the reason is EuriborSwapIsdaFixA is casted as boost::shared_ptr<Index> but SwaptionVolCube2 accepts only SwapIndex
2) change export_swap_instance macro and cast EuriborSwapIsdaFixA as boost::shared_ptr<SwapIndex> so it can pass in constuctor attached are two version interface file and testing python, please take a look when you have a time
Regards On Thu, Mar 3, 2011 at 11:10 PM, ren wei <[hidden email]> wrote: I am using swig 2.0.1 and quantlib compiled by VC 2008 as required by python 2.7 ------------------------------------------------------------------------------ What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users cmscaps.py (5K) Download Attachment indexes.i (18K) Download Attachment volatilities.i (25K) Download Attachment volatilities_v1.0.i (25K) Download Attachment indexes_v1.0.i (18K) Download Attachment |
Probably you have already sort it out, but just in case..... I am trying to do the same you did (try to port the cms to Python), and I had similar difficulties. But I am able to create a SwaptionVolCube2 with the approach 1 that you pointed out below. I tried to execute your python but with my interfaces and get the same Boost assertion error (altough I don't understand why). I've look at it and I replaced your atmVol declaration for the following one and the error dissapears. atmVol = SwaptionVolatilityStructureHandle(SwaptionVolatilityMatrix(calendar, Following, atmOptionTenors, atmSwapTenors, Matrix(m), Actual365Fixed())); To do so you will need to include the following overload depending if you input a matrix or a vector of vectors. SwaptionVolatilityMatrixPtr(const Calendar& calendar, BusinessDayConvention bdc, const std::vector<Period>& optionTenors, const std::vector<Period>& swapTenors, const std::vector<std::vector<Handle<Quote> > >& vols, const DayCounter& dayCounter){ return new SwaptionVolatilityMatrixPtr( new SwaptionVolatilityMatrix(calendar,bdc,optionTenors,swapTenors,vols,dayCounter)); } SwaptionVolatilityMatrixPtr( const Calendar& calendar, BusinessDayConvention bdc, const std::vector<Period>& optionTenors, const std::vector<Period>& swapTenors, const Matrix& vols, const DayCounter& dayCounter){ return new SwaptionVolatilityMatrixPtr( new SwaptionVolatilityMatrix(calendar,bdc,optionTenors,swapTenors,vols,dayCounter)); } } I additionally solved the initial vector of vector problems with the following as suggested by Francis in a recent thread. In marketelements.i
namespace std {
%template(QuoteVector)
vector<boost::shared_ptr<Quote> >;
%template(QuoteHandleVector) vector<Handle<Quote>
>;
%template(RelinkableQuoteHandleVector)
vector<RelinkableHandle<Quote> >;
// Additional lines required:
// -----------------------------------
%template(QuoteVVector)
vector<vector<boost::shared_ptr<Quote> > >;
%template(QuoteHandleVVector)
vector<vector<Handle<Quote> > >;
%template(RelinkableQuoteHandleVVector)
vector<vector<RelinkableHandle<Quote> > >;
}
I hope it helps. If I ever finnish the cms test for python i will post it (together with the required interfaces). I am currently stuck with some casting issues in SwaptionVolCube1 and MakeCms that I cannot figure it out. Lluís El 07/03/2011 15:43, ren wei escribió: Hi ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Thank you so much, Lluis. I was frustrated for a while and moved to other experimenting other products. with your help, I can come back and look at it again.
Regards Ren Wei On Wed, Jul 13, 2011 at 6:24 AM, Lluis Pujol <[hidden email]> wrote:
------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by archlight
Would you be so kind and share the compiled lib and dlls with us (version 1.1.xx) of the quantlib for C#.
i am having hard time getting it work. i get to compile but examples won't run. would be great if i can get the pre compiled dlls and libs so that i work with it until i learn swig. Thank you. |
Rajc144 <[hidden email]> writes: > Would you be so kind and share the compiled lib and dlls with us (version > 1.1.xx) of the quantlib for C#. There is a recent build here: http://www.bnikolic.co.uk/ql/csharp.html Best, Bojan -- Bojan Nikolic || http://www.bnikolic.co.uk/ql ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |