Accumulator

class zvt.contract.factor.Accumulator(acc_window: int = 1)

Bases: Indicator

__init__(acc_window: int = 1) None
Parameters:

acc_window – the window size of acc for computing,default is 1

acc(input_df: ~pandas.core.frame.DataFrame, acc_df: ~pandas.core.frame.DataFrame, states: dict) -> (<class 'pandas.core.frame.DataFrame'>, <class 'dict'>)
Parameters:
  • input_df – new input

  • acc_df – previous result

  • states – current states of the entity

Returns:

new result and states

acc_one(entity_id, df: ~pandas.core.frame.DataFrame, acc_df: ~pandas.core.frame.DataFrame, state: dict) -> (<class 'pandas.core.frame.DataFrame'>, <class 'dict'>)

df format:

             col1    col2    col3    ...
timestamp
             1.2     0.5     0.3     ...
             1.0     0.7     0.2     ...

the new result and state

Parameters:
  • df – current input df

  • entity_id – current computing entity_id

  • acc_df – current result of the entity_id

  • state – current state of the entity_id

Returns:

new result and state of the entity_id