Skip to content

addma - add moving average

Registers new moving averages to the oracle contract.

Technical Behavior

Moving average must be specified as a 4 digit precision asset with following symbol codes allowed:

  • DAYS

Window size cannot exceed the table size configured during initialization.

If the fractional part of the moving average is 0 then it will be used to calculate the SMA with specified number of time units (e.g. 60 minutes SMA, 12 hours SMA, etc.)

If the fractional part of the moving average is not 0 then it will be considered as EMA, the fractional part will be used as alpha parameter of EMA (e.g. 12.5000 hours EMA is an EMA with alpha parameter of 0.5, the decimal part 12 is mostly ignored)


EMA is currently not used and will likely be deprecated and removed

Action Parameters

final_moving_average_settingsstd::vector<eosio::asset>List of new moving averages to register

Required Permissions:

CLI - cleos

cleos push action addma '[["60.0000 MINUTES", "12.5000 HOURS"]]' -p

JavaScript - eosjs

(async () => {
    const result = await api.transact(
            actions: [
                    account: '',
                    name: 'addma',
                    authorization: [
                            actor: '',
                            permission: 'active',
                    data: {
                        final_moving_average_settings: ['60.0000 MINUTES', '12.5000 HOURS']
            blocksBehind: 3,
            expireSeconds: 30,