|
WebCab Bonds v2.01 (J2SE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--webcab.lib.finance.pricing.contexts.ContextGraph
This class implements a graph of contexts. Each model produces a context graph which is
processed also by the pricing algorithm and finally is sent to the contract as
a parameter in its GeneralContract#getAccumulatedCashflow or
FixedExchangeMomentsContract#getPayoff.
The contract implementor can use the graph to access information about the state variables
and compute the payoff using it. The elementary models usually
produce only one node - a Context (exception: the HJM model).
When constructing a compound model (see @link CompoundModel} the nodes produced
by the submodels are used to make a single large context graph.
AverageModel computes its variable (the average) using another state variable.
The average is dependent upon the other variable. The two variables are provided by different models -
so this is an inter-model dependecy. All inter-model relationships (dependencies, correlations) are
controlled via the compound model (implements the CompoundModel interface).
You can specify what variable is used to
compute the average with a call to CompoundModel.addDependency(java.lang.String, java.lang.String). An arrow from
node1 (the dependee context) to name2 (the dependent context) will be
automatically added in the context graph produced by the compound model.
Each node of the graph (an individual context) keeps some of the model state variables. Each
node offers access to different categories of information deduced using the variables. The information
offered can be the value of a variable or the result of some determinist algorithm using the
variables as inputs (e.g. ForwardRateContext uses an interpolation algorithm to compute
a forward rate of specified maturity).
The information offered is classified in standard categories (its signification is standardized) -
e.g. price, volatility, spot rate, forward rate curve, numeraire, average, extremum, trigger, etc. A
single context (a node in the graph) can offer more than one category of information deduced from its
variables. Each category has an interface associated with it, providing a means to access the information.
Usually these interfaces have one or more get() methods. They usually have no parameters
and have a double result, although this is not a restriction.
| Constructor Summary | |
ContextGraph(Context context1,
Context context2)
Constructs a new ContextGraph resulting from the union of the two nodes received as parmeters. |
|
ContextGraph(ContextGraph[] graphs,
int nInitialized,
Vector dependencies)
|
|
| Method Summary | |
void |
addDependency(String node1,
String node2)
This method should not be used directly. |
void |
addHardDependency(String node1,
String node2)
This method should not be used directly. |
ContextGraph |
applyContextGraphToVariables(double[] variables,
double[] memoryVariables)
|
void |
applyDeltaContextGraph(ContextGraph deltaContextGraph)
|
Object |
clone()
|
ContextGraph |
copySchema()
|
Context[] |
findAllByType(int type)
Searches for all contexts providing a specified category. |
Context |
findByIndex(int index)
Returns the node with the specified index in the context graph. |
Context |
findByName(String name)
Searches for a node in the context graph, using its name. |
Context |
findByType(int type,
int index)
Serches for the contexts providing a specified category; the index-th context found is returned. |
Context |
findFirstByType(int type)
Returns the first context found supporting a specified category. |
int |
findIndexByName(String name)
Returns the index of a node with a given name in the context graph. |
double |
getMemoryVariable(int index)
Returns the value of the index-th internal variable. |
int |
getNMemoryVariables()
Returns the total number of internal variables administered by all contexts. |
int |
getNNodes()
Returns the total number of contexts in the graph. |
Context |
getNode(int index)
Identical with findByIndex(int) |
int |
getNVariables()
Returns the total number of variables kept by all the contexts in the graph. |
double[] |
getUpdatedMemoryVariables(double t,
double dt)
|
double |
getVariable(int index)
Returns the value of the index-th variable. |
void |
setMemoryVariable(int index,
double value)
|
void |
setMemoryVariables(double[] values)
|
void |
setVariable(int index,
double value)
|
String |
toString()
|
ContextGraph |
union(ContextGraph graph)
|
static ContextGraph |
union(ContextGraph[] g,
int nInitialized)
|
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ContextGraph(ContextGraph[] graphs,
int nInitialized,
Vector dependencies)
public ContextGraph(Context context1,
Context context2)
context1 - The first context (node)context2 - The second context (node)| Method Detail |
public ContextGraph applyContextGraphToVariables(double[] variables,
double[] memoryVariables)
public void applyDeltaContextGraph(ContextGraph deltaContextGraph)
throws BondsException
BondsException
public void addDependency(String node1,
String node2)
throws ContextNotFoundException
CompoundModel.addDependency(java.lang.String, java.lang.String) instead.
ContextNotFoundException
public void addHardDependency(String node1,
String node2)
throws ContextNotFoundException
CompoundModel.addHardDependency(java.lang.String, java.lang.String) instead.
ContextNotFoundExceptionpublic Object clone()
clone in class Object
public ContextGraph copySchema()
throws InvalidParametersException
InvalidParametersException
public Context findByName(String name)
throws ContextNotFoundException
name - the node's name
ContextNotFoundException - thrown if the node was not found
public int findIndexByName(String name)
throws ContextNotFoundException
name - String
ContextNotFoundException - thrown if the node was not found
public Context findByIndex(int index)
throws ContextNotFoundException
index - the index (begining with 0)
ContextNotFoundException
public Context findByType(int type,
int index)
throws ContextNotFoundException
index-th context found is returned.
type - the category idindex - the index (begining with 0)
ContextNotFoundException
public Context[] findAllByType(int type)
throws ContextNotFoundException
type - the category id
ContextNotFoundException
public Context findFirstByType(int type)
throws ContextNotFoundException
type - the category id
ContextNotFoundException
public Context getNode(int index)
throws ContextNotFoundException
findByIndex(int)
index - the index (begining with 0)
ContextNotFoundExceptionpublic int getNNodes()
public int getNVariables()
public int getNMemoryVariables()
public double getVariable(int index)
index-th variable.
index - the index (begining with 0)
public double getMemoryVariable(int index)
index-th internal variable.
index - the index (begining with 0)
public void setVariable(int index,
double value)
public void setMemoryVariable(int index,
double value)
public void setMemoryVariables(double[] values)
throws InvalidParametersException
InvalidParametersException
public double[] getUpdatedMemoryVariables(double t,
double dt)
throws BondsException
BondsExceptionpublic String toString()
toString in class Object
public ContextGraph union(ContextGraph graph)
throws BondsException
BondsException
public static ContextGraph union(ContextGraph[] g,
int nInitialized)
throws BondsException
BondsException
|
WebCab Bonds v2.01 (J2SE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||