简体   繁体   English

C ++ Quantlib输出到控制台窗口

[英]C++ Quantlib output to console window

I am learning how to use quantlib to price derivatives. 我正在学习如何使用Quantlib为衍生产品定价。 What is the best way to output some of the Quantlib specific classes to console window? 将某些Quantlib特定类输出到控制台窗口的最佳方法是什么? For example 例如

shared_ptr<YieldTermStructure> forwardCurve(new InterpolatedDiscountCurve<LogLinear>(dates,discountFactor,Actual360())); 
Handle<YieldTermStructure> forwardingTermStructure(forwardCurve);
shared_ptr<IborIndex> euribor(new Euribor(3*Months,forwardingTermStructure));

What will be the best way for me to output forwardCurve to and euribor to console window? 对我而言,将forwardCurve输出到控制台窗口并向控制台窗口输出的最佳方法是什么? Then I can see the intermediate result of the code to see if they are as expected. 然后,我可以看到代码的中间结果,以查看它们是否符合预期。

Many thanks. 非常感谢。

There's no predefined way to output those classes to console, but you can use their inspector to output the relevant data (so, eg, you can call forwardCurve->times() and forwardCurve->discounts() to inspect the values you're interpolating) or you can call their methods to see the results of their calculations (eg, forwardCurve->discount(d) to retrieve the discount factor at a given date, or euribor->fixing(d) to retrieve the expected index fixing). 没有预定义的方法可以将这些类输出到控制台,但是您可以使用其检查器来输出相关数据(例如,可以调用forwardCurve->times()forwardCurve->discounts()来检查您要的值插值),也可以调用它们的方法以查看其计算结果(例如, forwardCurve->discount(d)以获取给定日期的折现因子,或euribor->fixing(d)以获取预期的索引固定) 。 The returned values can be written to console. 返回的值可以写入控制台。

As an alternative, you might consider stepping through the code inside a debugger. 或者,您可以考虑逐步调试器中的代码。 In modern IDEs, this will give you the same information more easily. 在现代IDE中,这将使您更轻松地获得相同的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM