Accumulator is a derivative product for purchasing shares with leverage
in a continuous and accumulating manner (often on a daily basis)
until either its settlement date is reached or the share price goes up above
some pre-agreed knock-out price.
If you are not familiar with its concept, be advised to take a look at
this wikipedia article.
A simplified version of accumulator is defined as a statechart as follows.
-
accumulator in scxml generated from the above dsl4sc definition
operation flow
Upon each day_close event,- if the share price (carried by day_close as _event.data.price) is high above ko_price,
perform the knockout (sell-off) operation and terminate (_knockout) - otherwise (_not_knockout),
- purchase shares (_over_strike or _under_strike), the amount of which varies depending on the price
- terminate normally if the expiration date is reached, or wait for a day_open event to repeat the entire process
- if the share price (carried by day_close as _event.data.price) is high above ko_price,
For the detail of the definition (and its monitors listed below), refer to this material.
In addition, several monitors are defined, also as statecharts, to ensure that the accumulator works exactly as intended.
-
monitor1: simple event-pattern checking
-
monitor2: monitor1 + event parameter validation
-
monitor3: safety and liveness
-
monitor4: anomaly detection, a sort of
-
to run the accumulator against the valid scenarios
$ shelltest accumulator.conf
send input events to accumulator via MQTT
$ shelltest passthru_accumulator.conf
-
to run the monitors against the all valid/invalid scenarios
$ shelltest monitors.conf
send input events to monitors via MQTT
$ shelltest passthru_monitors.conf
-
to run the accumulator and each monitor connected via MQTT against the scenarios
$ shelltest accumulator_monitors.conf