Download as a PDF

Transcript
53
?sp500_close(__D,__T0),ibm_close(__D,__T1),
__D0 = 3.000000 * __T0 / 12.000000 +
dateuntranslate(__D,__DATESTRING),
print(__DATESTRING,__D0),fail.
__T1,
4.4 Generating Aggregates
Aggregates currently take the following form when translated into CORAL:
seqaverage(BDate,EDate,SeriesOrPortfolio,Answer).
The aggregate takes a begin date, an end date, and a symbol indicating what
it is operating on and returns the answer in the last argument. By default, the
aggregate behaves as if it were acting on a series. If the 3rd argument is a function
symbol, e.g.
port_position(ibm_close),
the aggregate behaves as if it were
acting on a portfolio.
This distinction is made because properties on series are stored as a single array. For example, the closing price data for the stock ABC is stored as a single array. During translation, the phrase close
of abc
becomes the symbol abc_close
which represents the name of the relation from which to obtain the data. On the
other hand, portfolios do not contain any data; instead it contains references to
the series that comprise the portfolio. In order to get data out of a portfolio, some
operation must be applied to it. Therefore, in order for a portfolio to have any
meaning, the operation to be applied to it must be included with it in order for
the aggregate to act on it.