| org.unizone.source | ![]() |
org.unizone.0.4160
Instance of Type
Inheriting from SourceAdapterSingleTimeseries
| Type data | Value |
| org.uninode.Type.displayPattern | {att:org.unizone.source.Source.displayName} |
| org.unizone.source.Source.valueAttribute | |
| org.uninode.Resource.resourceType | |
| org.uninode.Resource.label | |
| org.uninode.Resource.resourceOf | List{} |
| org.uninode.Listable.resources | Reference[org.uninode.Listable.resources] of org.unizone.source.Volatility |
| Attribute summary | Defined in | Uninode® Id | Properties | Default | |
| Reference[org.uninode.Listable.resources] | resources | Listable | org.uninode.0.2001 | type | |
| String | toString This is the display string. | Node | org.uninode.0.102 | ||
| Type | type The type of an object determines the behaviour and attributes of the object. | Node | org.uninode.0.101 | ||
| String | uri | Node | org.uninode.0.103 | ||
| String | label | Resource | org.uninode.0.2041 | type | |
| List[Type] | resourceOf | Resource | org.uninode.0.2042 | type | |
| Signature | resourceType This defines the type of resource. It can be 'view', 'adapter' or 'action' | Resource | org.uninode.0.2043 | type | |
| String | displayName The display name is the name that is shown in lists, displays and graphs. | Source | org.unizone.0.4001 | essential | |
| Attribute | valueAttribute The value attribute is used for determining the default value that should be used for displaying this source in a graph. | Source | org.unizone.0.4011 | type inheritValue | |
| Signature | valueType The value type determines which axes should be used in graphs. | Source | org.unizone.0.4002 | inheritValue | |
| Source | source | SourceAdapterSingle | org.unizone.0.4051 | ||
| Method summary | Defined in | Overrides | Properties | |
| void | activate | Listable | ||
| void | checkRange | SourceAdapterSingle | Source | |
| void | designEditor(WidgetWorkspace ws) | Listable | ||
| void | generateScript(ScriptGenerationInfo info) | SourceAdapterSingle | ScriptGenerator | |
| Real | get(DateTime timestamp) | SourceAdapterSingleTimeseries | ||
| Boolean | isResourceOf(Listable listable, Signature aspect) | Mixable | type | |
| Listable | mixOn(Mixable mix) | Mixable | ||
| Listable | mixWith(Mixable mix) | Mixable | ||
| void | put(DateTime timestamp, Real value) | SourceAdapterSingleTimeseries | ||
| String | resourceString | Listable | introspection | |
| void | setSource(Source source) | SourceAdapterSingle | ||
| Source | source | SourceAdapterSingle | ||
| void | XXXcom.nodelab.java.sourceadaptersingle.CheckRange | SourceAdapterSingle | ||
| Signature | XXXcom.nodelab.java.sourceadaptersingle.ValueType | SourceAdapterSingle | ||
| void | com.nodelab.java.source.Activate | Source | Listable | |
| Listable | com.nodelab.java.source.MixWithMi | Source | Mixable | |
| Script summary |
org.unizone.0.8554/*
instance Value[Int] days;
constructor() {
TimeSeries:();
instance days = new Value(Int, 30);
}
constructor(Source src, Int days) {
TimeSeries:();
setNextSource(src);
instance days = new Value(Int, days);
}
Void setDays(Int days) {
instance days = new Value(Int, days);
changedHistory();
}
class Boolean isResourceOf(Listable node, Symbol aspect) {
if (aspect == #adaptors) return true;
false;
}
class String resourceLabel() "Name of resource" {
"volatility";
}
String resourceString() "Description of resource" {
instance days.value.toString + " days volatility of " + nextSource().toString();
}
Mixable mixWith(Mixable item) {
if (item.class.subclassOf(Source)) {
setNextSource(Source{item});
return this;
}
return TimeSeries:mixWith(item);
}
Symbol valueType() {
nextSource().valueType()
}
Void designEditor(WidgetWorkspace ws) {
ws.addLabel(new Place(0, 0).setPadding(5, 5), "Days");
ws.addField(new Place(1, 0).setPadding(20, 5), instance days, null);
}
trace Void prepareData(Time from, Time to, Symbol resolution) {
Source src = nextSource();
Producer.report("Preparing " + toString());
external cond_history_from = from.addDays(1-instance days.value);
external cond_history_to = to;
Set[Time] dates = new Set(Time);
src.collectSteps(#cond_history, dates);
if (dates.size < 2) return;
Array[Real] values = new Array(Real, dates.size);
0 .to(values.size - 1, trace Void(Int i) {
external cond_history = dates.at(i);
values.set(i, src.aspectReal(#value));
});
Array[Real] diffs = new Array(Real, dates.size);
Real value = values.at(0);
Time time = dates.at(0);
Real trailValue;
Time trailTime;
1 .to(diffs.size - 1, trace Void(Int i) {
trailValue = value;
trailTime = time;
value = values.at(i);
time = dates.at(i);
if (value != null && trailValue != null)
diffs.set(i, (value.ln - trailValue.ln) / (time.subtractTime(trailTime)/365).sqrt);
});
Real sx = 0.0;
Real sx2 = 0.0;
Int count = 0;
Int index = 1;
Int fromIndex = 0;
Int toIndex = -1;
Real s2;
while (index < dates.size - 1 && dates.at(index) < from) index = index + 1;
while (index < diffs.size) {
while (toIndex < index) {
toIndex = toIndex + 1;
value = diffs.at(toIndex);
if (value != null) {
sx = sx + value;
sx2 = sx2 + value * value;
count = count + 1;
}
}
Time fromTime = dates.at(toIndex).addDays(-instance days.value);
while (dates.at(fromIndex) < fromTime) {
value = diffs.at(fromIndex);
if (value != null) {
sx = sx - value;
sx2 = sx2 - value * value;
count = count - 1;
}
fromIndex = fromIndex + 1;
}
if (count > 1)
s2 = (sx2 - sx * sx / count) / (count - 1);
else
s2 = 0.0;
TimeData data = new TimeData(this, dates.at(index));
if (s2 > 0.0)
data.setAspect(#value, s2.sqrt * 100);
else
data.setAspect(#value, null);
addData(data);
index = index + 1;
}
Producer.report("");
}
String instanceScript(InstanceScriptInfo info) {
nextSource().instanceScript(info); // create variables
info.objectId(this, AdaptorVolatility, "vlt");
}
String initScript(InstanceScriptInfo info) {
String prefix = info.methodPrefix(this);
" " + prefix + "setNextSource(" + nextSource().instanceScript(info) + ");
" + prefix + "setDays(" + instance days.value.toString + ");
";
}
*/ |