ApplyUnaryTsOp function
The ApplyUnaryTsOp function applies a unary arithmetic function to a time series.
Syntax
ApplyUnaryTsOp(func_name lvarchar,
ts TimeSeries)
returns TimeSeries;
- func_name
- The name of the unary arithmetic function.
- ts
- The time series to act on.
Description
This function operates in an analogous fashion to the unary arithmetic functions that have been overloaded to operate on time series. See the description of these functions in the section Unary arithmetic functions for more information. For example, Logn(ts1) is equivalent to ApplyUnaryTsOp(‘Logn', ts1).
Returns
A time series of the same type as the supplied time series.
Example
The following example uses ApplyUnaryTSOp with
the Logn function:
create row type simple_series( stock_id int, data TimeSeries(one_real));
create table daily_high of type simple_series;
insert into daily_high
select stock_id,
Apply( '$0.high',
NULL::datetime year to fraction(5),
NULL::datetime year to fraction(5),
stock_data)::TimeSeries(one_real)
from daily_stocks;
create table daily_low of type simple_series;
insert into daily_low
select stock_id,
Apply( '$0.low',
NULL::datetime year to fraction(5),
NULL::datetime year to fraction(5),
stock_data)::TimeSeries(one_real)
from daily_stocks;
create table daily_avg of type simple_series;
insert into daily_avg
select l.stock_id, ApplyBinaryTSOp("plus", l.data, h.data)/2
from daily_low l, daily_high h
where l.stock_id = h.stock_id;
create table log_high of type simple_series;
insert into log_high
select stock_id, ApplyUnaryTsOp( "logn",
data) from daily_avg;