Posted by
Joseph Wang-2 on
URL: http://quantlib.414.s1.nabble.com/Surface-interface-tp11372p11380.html
The three abstract interfaces that I'd like to define are
class Surface : public std::binary_function<Real, Real, Real> {
public:
virtual Real operator()(Real x, Real y) const = 0;
virtual Domain* domain() const = 0;
virtual ~Surface() {};
};
class Domain : public std::binary_function<Real, Real, bool>{
public:
virtual bool includes(Real x, Real y) const = 0;
bool operator()(Real x, Real y) {return includes(x, y);}
virtual ~Domain() {};
};
class Curve : public std::unary_function<Real, Real> {
public:
virtual Real operator()(Real x) const = 0;
};
The rationale behind defining these classes is more computational than
finance. Basically if these three classes exist, then when I write a
external plotting function, I need only have the function understand
surfaces, domains, and curves, and it doesn't need to know about any of the
details behind the class.
Also you can do things like:
class RFunction : public Curve {
public:
RFunction(SEXP *);
}
class PythonFunction : public Curve {
public:
PythonFunction(Handler *);
}
One subclass in particular is
class TimeIndexedSurface : public Surface, public TimeSeries <Curve> {
public:
TimeIndexedSurface (Date referenceDate &);
void addCurve(Date, const Curve &);
}
What this would do in combination with the PDE code is that as the PDE is
calculating, it can add results to this class, and from QuantLib's point of
view it is seeing a TimeSeries of curves. An external plotting application
sees that this class is also of type Surface and can run through that
interface to plot the surface generated by a finite difference run.
The other use for this is that I have data from Shanghai warrants and I want
to see if the volatility smile evolves. So I want to slice up the data into
time bins, do a regression on each bin, and then plot the surface. For this
I need an object that could store the regressions. Most scripting languages
don't have data structures that are flexible enough (or are too flexible) to
do this.
在 Tuesday 28 November 2006 02:52,您写道:
> Hi Joseph
>
> it would be nice if you could give us a more detailed idea about how
> this class would be used, especially from the financial point of view.
>
> we're in the middle of some major refactoring of interest rate
> volatility surfaces, and I would prefer to have a clear idea about
> overlapping, if any.
>
> ciao -- Nando
>
> On 11/28/06, Joseph Wang <
[hidden email]> wrote:
> > Unless someone objects, I'd like to check in a set of classes that
> > provide a standardized interface to surfaces in quantlib. The basic
> > interface is a Surface class that returns a real in return to two real
> > inputs and provides information about the domain the Surface is valid.
> > The idea behind this is to provide a standard interface for external
> > plotting packages.
> >
> > The goal in three or four months time is to make this work with Python
> > and VTK to provide the sort of visualization which is standard in CFD,
> > medical and petroleum, but which I haven't seen yet in QF.
> >
> > The other thing that we probably should look at before 1.0 is to look at
> > the classes and see if there are any that are redundant.
> >
> >
> > --
> > -------------------------------------------------------------------------
> >------ Joseph Wang Ph.D. -
[hidden email]
> > China Derivatives Researcher and Software Developer - QuantLib
> >
http://en.wikiversity.org/wiki/User:Roadrunner> >
> >
> >
> >
> >
> > -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share
> > your opinions on IT & business topics through brief surveys - and earn
> > cash
> >
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV> > _______________________________________________
> > QuantLib-dev mailing list
> >
[hidden email]
> >
https://lists.sourceforge.net/lists/listinfo/quantlib-dev--
-------------------------------------------------------------------------------
Joseph Wang Ph.D. -
[hidden email]
China Derivatives Researcher and Software Developer - QuantLib
http://en.wikiversity.org/wiki/User:Roadrunner