Main
context of the indicator. It is
possible to request additional instrument data in indicator. For that purpose there are @sec_context
decorator and
indie.SecContext
class in combination with Context.calc_on()
function.
@sec_context()
and Context.calc_on()
@sec_context
is a syntactic sugar that can be applied to a function definition which is an equivalent of
writing a class inherited from indie.SecContext
(more about the mechanics how this works can be found
here). The
body of such a decorated function becomes an entry point for calculation when a data update is occurred on the
corresponding additional instrument. Function call of Context.calc_on
creates a connection between the Main
context
and the secondary one.
Here is an example of an indicator that requests one additional instrument:
Context.calc_on
function is called from __init__
constructor method of a main or secondary
context.
Main
which is executed every time a data update on the main instrument AAPL 15m happens andSecMain
which is executed every time a data update on the secondary instrument AAPL 1D happens.Context.calc_on
has more parameters besides sec_context
and time_frame
. Here is its signature:
exchange
, ticker
and time_frame
are not given, then the corresponding values are taken from the current
instrument.