otp.state.tick_sequence_tick#

class TickSequenceTick(name, owner=None)[source]#

Bases: onetick.py.core._internal._state_objects._TickSequenceTickMixin, abc.ABC

Tick object that can be accessed only in per-tick script. This object is a first per-tick script function argument. This object is the loop variable of for-cycle in the code of per-tick script when for-cycle is used on tick sequence. Also tick can be defined as static local variable.

Examples

>>> def another_query():
...     return otp.Ticks(X=[1, 2, 3])
>>> def fun(tick):
...     dyn_t = otp.dynamic_tick()
...     tick['SUM'] = 0
...     for t in tick.state_vars['LIST']:
...         tick['SUM'] += t.get_long_value('X')
...     dyn_t['X'] = tick['SUM']
>>> data = otp.Tick(A=1)
>>> data.state_vars['LIST'] = otp.state.tick_list(otp.eval(another_query))
>>> data = data.script(fun)
property schema: dict#
next()[source]#
prev()[source]#
is_end()[source]#
copy(tick_object)[source]#
get_timestamp()[source]#

Get timestamp of the tick.

Examples

>>> def another_query():
...     return otp.Ticks({'A': [1, 2, 3]})
>>> def fun(tick):
...    for t in tick.state_vars['LIST']:
...        tick['TS'] = t.get_timestamp()
>>> data = otp.Tick(A=1)
>>> data.state_vars['LIST'] = otp.state.tick_list(otp.eval(another_query))
>>> data = data.script(fun)
>>> data.to_df()
        Time  A                      TS
0 2003-12-01  1 2003-12-01 00:00:00.002
Return type

onetick.py.core.column_operations.base.Operation

get_value(field_name)[source]#

Get value of the field_name of the tick.

Examples

>>> def another_query():
...     return otp.Ticks(X=[1.1, 2.2, 3.3])
>>> def fun(tick):
...     tick['SUM'] = 0
...     for t in tick.state_vars['LIST']:
...         tick['SUM'] += t.get_value('X')
>>> data = otp.Tick(A=1)
>>> data.state_vars['LIST'] = otp.state.tick_list(otp.eval(another_query))
>>> data = data.script(fun)
>>> data.to_df()
        Time  A  SUM
0 2003-12-01  1  6.6