A light-weight domain specific language used to analyse and modify dynts.TimeSeries. Here few script examples:
Parsing timeseries expressions is accomplished using the dynts.parse() function:
Function for parsing timeseries expressions. If succesful, it returns an instance of dynts.dsl.Expr.
For example:
>>> import dynts
>>> r = dynts.parse('GOOG/2,YHOO')
>>> r.type
'concatenationop'
>>> len(r)
2
Now lets load some data using the built-in data providers:
>>> result = dynts.evaluate(r)
>>> result.expression
goog / 2.0 , yhoo
>>> ts = result.unwind()
>>> len(ts)
2
Base class for abstract syntax nodes
Number of nodes
Return a list of dynts.dsl.Symbol instances.
Unwind expression by applying values to the abstract nodes. the kwargs dictionary can contain data which can be used to override values
Timeserie symbol. This expression is replaced by a timeserie value for the symbol
A symbol is any string expression which is not a function. For example:
>>> e = dynts.parse('0.5*GOOG')
>>> e[1].type
'symbol'
>>> e.symbols()
[GOOG]
Symbols are special types of the abstract syntax tree which defines the timeserie DSL. values of symbol are given by external data providers such as blooberg, yahoo finance, google finance and so forth.
A dynts.dsl.Expr class for enclosing group of dynts.dsl.Expr. It forms the building block of dynts.dsl.Function and other operators.
A dynts.dsl.Bracket representing a function func, an instance of dynts.dsl.FunctionBase. A function is defined a-la Python as:
func(expression, **kwargs)
where kwargs is a dictionary of input parameters. For example, the rolling-standard deviation is defined as:
std(expression,window=20)
To implement new functions, one needs to derive from the base class:
Base class for a timeseries function implementation. The only member function to implement is the __call__ method.
- __call__(args, **kwargs)¶
where args is a list of arguments (timeseries or other objects) and kwargs is a dictionary of input parameters. For example, the rolling-standard deviation is defined as:
std(expression,window=20)